Class OpenCLKernelPipeline
- Namespace
- DotCompute.Backends.OpenCL.Execution
- Assembly
- DotCompute.Backends.OpenCL.dll
Production-grade multi-kernel execution pipeline with dependency resolution, automatic optimization, and comprehensive profiling.
public sealed class OpenCLKernelPipeline : IAsyncDisposable
- Inheritance
-
OpenCLKernelPipeline
- Implements
- Inherited Members
Remarks
The OpenCLKernelPipeline enables complex multi-stage compute workflows with:
- Automatic dependency resolution via topological sorting
- Parallel execution of independent stages
- Intermediate buffer management and reuse
- Event-based synchronization for optimal throughput
- Pipeline-level profiling with stage breakdown
- Cycle detection to prevent invalid pipelines
- Automatic kernel fusion opportunities identification
- Memory reuse optimization across stages
Example use cases: - Image processing pipelines (blur → sharpen → color correct) - Machine learning inference (preprocess → inference → postprocess) - Scientific simulations (initialize → iterate → analyze) - Data processing workflows (load → transform → reduce)
Constructors
OpenCLKernelPipeline(OpenCLKernelExecutionEngine, OpenCLMemoryPoolManager, OpenCLProfiler, ILogger<OpenCLKernelPipeline>)
Initializes a new instance of the OpenCLKernelPipeline class.
public OpenCLKernelPipeline(OpenCLKernelExecutionEngine executor, OpenCLMemoryPoolManager memoryPool, OpenCLProfiler profiler, ILogger<OpenCLKernelPipeline> logger)
Parameters
executorOpenCLKernelExecutionEngineKernel execution engine for running stages.
memoryPoolOpenCLMemoryPoolManagerMemory pool manager for intermediate buffers.
profilerOpenCLProfilerProfiler for performance metrics.
loggerILogger<OpenCLKernelPipeline>Logger for diagnostic information.
Exceptions
- ArgumentNullException
Thrown if any parameter is null.
Methods
CreatePipeline(string)
Creates a new pipeline builder for constructing multi-kernel workflows.
public OpenCLKernelPipeline.PipelineBuilder CreatePipeline(string name)
Parameters
namestringDescriptive name for the pipeline.
Returns
- OpenCLKernelPipeline.PipelineBuilder
A pipeline builder for configuring stages and dependencies.
Exceptions
- ArgumentException
Thrown if name is null or whitespace.
DisposeAsync()
Asynchronously disposes the pipeline manager and releases all resources.
public ValueTask DisposeAsync()
Returns
ExecutePipelineAsync(Pipeline, Dictionary<string, object>, CancellationToken)
Executes a configured pipeline with automatic dependency resolution and optimization.
public Task<OpenCLKernelPipeline.PipelineResult> ExecutePipelineAsync(OpenCLKernelPipeline.Pipeline pipeline, Dictionary<string, object> inputs, CancellationToken cancellationToken = default)
Parameters
pipelineOpenCLKernelPipeline.PipelineThe pipeline to execute.
inputsDictionary<string, object>Input buffers and parameters for the pipeline.
cancellationTokenCancellationTokenCancellation token for async operations.
Returns
- Task<OpenCLKernelPipeline.PipelineResult>
Pipeline execution result containing outputs and profiling data.
Exceptions
- ArgumentNullException
Thrown if pipeline or inputs is null.
- OpenCLPipelineException
Thrown if pipeline validation or execution fails.
GetStatistics()
Gets comprehensive pipeline execution statistics.
public OpenCLKernelPipeline.PipelineStatistics GetStatistics()
Returns
- OpenCLKernelPipeline.PipelineStatistics
Statistics about pipeline usage and performance.