Class KernelConfiguration
- Namespace
- DotCompute.Abstractions.Kernels
- Assembly
- DotCompute.Abstractions.dll
Represents kernel configuration settings that control how a kernel is compiled and executed. This includes optimization levels, execution dimensions, and device-specific options.
public class KernelConfiguration
- Inheritance
-
KernelConfiguration
- Inherited Members
Constructors
KernelConfiguration()
Initializes a new instance of the KernelConfiguration class with default settings.
public KernelConfiguration()
KernelConfiguration(Dim3, Dim3)
Initializes a new instance of the KernelConfiguration class with the specified execution dimensions.
public KernelConfiguration(Dim3 gridDim, Dim3 blockDim)
Parameters
gridDimDim3The grid dimensions that define the overall execution space.
blockDimDim3The block dimensions that define the local execution group size.
Remarks
This constructor is commonly used for GPU kernels where execution is organized in a hierarchical grid-block structure. The grid dimension defines the number of blocks, and the block dimension defines the number of threads per block.
Properties
Name
Gets or sets the kernel name for identification purposes.
public string Name { get; set; }
Property Value
- string
The name of the kernel, or an empty string if not specified.
OptimizationLevel
Gets or sets the optimization level to use during kernel compilation.
public OptimizationLevel OptimizationLevel { get; set; }
Property Value
- OptimizationLevel
The optimization level that controls compilation behavior and performance characteristics.
Options
Gets or sets kernel-specific configuration options.
public Dictionary<string, object> Options { get; }
Property Value
- Dictionary<string, object>
A dictionary containing kernel-specific options such as grid dimensions, block dimensions, shared memory size, and other execution parameters.
Methods
GetBlockDimension()
Gets the block dimension from the options, if specified.
public Dim3? GetBlockDimension()
Returns
- Dim3?
The block dimension, or null if not configured.
GetGridDimension()
Gets the grid dimension from the options, if specified.
public Dim3? GetGridDimension()
Returns
- Dim3?
The grid dimension, or null if not configured.
GetOption<T>(string)
Gets a strongly-typed option value from the configuration.
public T? GetOption<T>(string key)
Parameters
keystringThe option key to retrieve.
Returns
- T
The option value cast to the specified type, or the default value for the type if not found.
Type Parameters
TThe expected type of the option value.
RemoveOption(string)
Removes an option from the configuration.
public bool RemoveOption(string key)
Parameters
keystringThe option key to remove.
Returns
- bool
True if the option was found and removed; otherwise, false.
Exceptions
- ArgumentNullException
Thrown when
keyis null.
SetExecutionDimensions(Dim3, Dim3)
Sets the grid and block dimensions for kernel execution.
public void SetExecutionDimensions(Dim3 gridDim, Dim3 blockDim)
Parameters
SetOption(string, object)
Sets an option value in the configuration.
public void SetOption(string key, object value)
Parameters
Exceptions
- ArgumentNullException
Thrown when
keyis null.