Class ICompiledKernelExtensions
- Namespace
- DotCompute.Core.Extensions
- Assembly
- DotCompute.Core.dll
Extension methods for ICompiledKernel to provide backward compatibility, additional methods required by tests and legacy code, and convenient overloads for common kernel execution scenarios.
public static class ICompiledKernelExtensions
- Inheritance
-
ICompiledKernelExtensions
- Inherited Members
Methods
ExecuteAsync(ICompiledKernel, KernelArguments, KernelExecutionOptions, CancellationToken)
Executes the kernel with execution options.
public static ValueTask ExecuteAsync(this ICompiledKernel kernel, KernelArguments arguments, KernelExecutionOptions options, CancellationToken cancellationToken = default)
Parameters
kernelICompiledKernelThe compiled kernel to execute
argumentsKernelArgumentsKernel arguments
optionsKernelExecutionOptionsExecution options
cancellationTokenCancellationTokenCancellation token
Returns
- ValueTask
A ValueTask representing the asynchronous operation
ExecuteAsync(ICompiledKernel, KernelArguments, int[], int[]?, CancellationToken)
Executes the kernel with work group dimensions for OpenCL-style execution.
public static ValueTask ExecuteAsync(this ICompiledKernel kernel, KernelArguments arguments, int[] globalWorkSize, int[]? localWorkSize = null, CancellationToken cancellationToken = default)
Parameters
kernelICompiledKernelThe compiled kernel to execute
argumentsKernelArgumentsKernel arguments
globalWorkSizeint[]Global work size dimensions
localWorkSizeint[]Local work size dimensions (optional)
cancellationTokenCancellationTokenCancellation token
Returns
- ValueTask
A ValueTask representing the asynchronous operation
ExecuteAsync(ICompiledKernel, object, CancellationToken)
Bridge method for LINQ-style execution parameters compatibility. This handles cases where KernelExecutionParameters from the LINQ project is used.
[UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Dynamic property lookup for LINQ-style execution parameters is intentional for duck-typed compatibility")]
public static Task ExecuteAsync(this ICompiledKernel kernel, object parameters, CancellationToken cancellationToken = default)
Parameters
kernelICompiledKernelThe compiled kernel to execute
parametersobjectExecution parameters object (duck-typed compatibility)
cancellationTokenCancellationTokenCancellation token
Returns
- Task
A Task representing the asynchronous operation
ExecuteAsync<TArg1>(ICompiledKernel, TArg1, CancellationToken)
Executes the kernel with typed parameters for better compile-time safety.
public static ValueTask ExecuteAsync<TArg1>(this ICompiledKernel kernel, TArg1 arg1, CancellationToken cancellationToken = default)
Parameters
kernelICompiledKernelThe compiled kernel to execute
arg1TArg1First kernel argument
cancellationTokenCancellationTokenCancellation token
Returns
- ValueTask
A ValueTask representing the asynchronous operation
Type Parameters
TArg1Type of the first argument
ExecuteAsync<TArg1, TArg2>(ICompiledKernel, TArg1, TArg2, CancellationToken)
Executes the kernel with two typed parameters.
public static ValueTask ExecuteAsync<TArg1, TArg2>(this ICompiledKernel kernel, TArg1 arg1, TArg2 arg2, CancellationToken cancellationToken = default)
Parameters
kernelICompiledKernelThe compiled kernel to execute
arg1TArg1First kernel argument
arg2TArg2Second kernel argument
cancellationTokenCancellationTokenCancellation token
Returns
- ValueTask
A ValueTask representing the asynchronous operation
Type Parameters
TArg1Type of the first argument
TArg2Type of the second argument
ExecuteAsync<TArg1, TArg2, TArg3>(ICompiledKernel, TArg1, TArg2, TArg3, CancellationToken)
Executes the kernel with three typed parameters.
public static ValueTask ExecuteAsync<TArg1, TArg2, TArg3>(this ICompiledKernel kernel, TArg1 arg1, TArg2 arg2, TArg3 arg3, CancellationToken cancellationToken = default)
Parameters
kernelICompiledKernelThe compiled kernel to execute
arg1TArg1First kernel argument
arg2TArg2Second kernel argument
arg3TArg3Third kernel argument
cancellationTokenCancellationTokenCancellation token
Returns
- ValueTask
A ValueTask representing the asynchronous operation
Type Parameters
TArg1Type of the first argument
TArg2Type of the second argument
TArg3Type of the third argument
GetMetadataAsync(ICompiledKernel)
Gets metadata about the kernel for profiling and debugging.
public static ValueTask<Dictionary<string, object>> GetMetadataAsync(this ICompiledKernel kernel)
Parameters
kernelICompiledKernelThe compiled kernel
Returns
- ValueTask<Dictionary<string, object>>
A dictionary containing kernel metadata
IsDisposed(ICompiledKernel)
Checks if the kernel has been disposed.
[UnconditionalSuppressMessage("Trimming", "IL2075", Justification = "Dynamic property lookup for kernel disposal detection is intentional for different kernel implementations")]
public static bool IsDisposed(this ICompiledKernel kernel)
Parameters
kernelICompiledKernelThe compiled kernel
Returns
- bool
True if the kernel is disposed, false otherwise
LaunchAsync(ICompiledKernel, KernelArguments, CancellationToken)
Launches the kernel asynchronously with the given arguments. This is an alias for the ExecuteAsync method to match test expectations.
public static ValueTask LaunchAsync(this ICompiledKernel kernel, KernelArguments arguments, CancellationToken cancellationToken = default)
Parameters
kernelICompiledKernelThe compiled kernel to execute
argumentsKernelArgumentsThe kernel arguments
cancellationTokenCancellationTokenCancellation token
Returns
- ValueTask
A ValueTask representing the asynchronous operation
LaunchAsync(ICompiledKernel, object, IComputeExecution, params object[])
Launches the kernel with launch configuration and execution context support. This overload supports CUDA streams for concurrent execution. Uses IComputeExecution interface to match test expectations.
public static ValueTask LaunchAsync(this ICompiledKernel kernel, object launchConfig, IComputeExecution stream, params object[] arguments)
Parameters
kernelICompiledKernelThe compiled kernel to execute
launchConfigobjectLaunch configuration (grid/block dimensions)
streamIComputeExecutionCUDA stream or execution context (IComputeExecution interface)
argumentsobject[]Variable number of kernel arguments
Returns
- ValueTask
A ValueTask representing the asynchronous operation
LaunchAsync(ICompiledKernel, object, params object[])
Launches the kernel with launch configuration and buffer arguments (non-generic version). This overload takes precedence for tests and avoids generic type inference issues.
public static ValueTask LaunchAsync(this ICompiledKernel kernel, object launchConfig, params object[] arguments)
Parameters
kernelICompiledKernelThe compiled kernel to execute
launchConfigobjectLaunch configuration (grid/block dimensions)
argumentsobject[]Variable number of kernel arguments
Returns
- ValueTask
A ValueTask representing the asynchronous operation
LaunchAsync(ICompiledKernel, (int x, int y, int z), (int x, int y, int z), KernelArguments, CancellationToken)
Launches the kernel with a specific grid and block configuration. This provides additional overload for more explicit kernel launch parameters.
public static ValueTask LaunchAsync(this ICompiledKernel kernel, (int x, int y, int z) gridDim, (int x, int y, int z) blockDim, KernelArguments arguments, CancellationToken cancellationToken = default)
Parameters
kernelICompiledKernelThe compiled kernel to execute
gridDim(int x, int y, int z)Grid dimensions (x, y, z)
blockDim(int x, int y, int z)Block dimensions (x, y, z)
argumentsKernelArgumentsThe kernel arguments
cancellationTokenCancellationTokenCancellation token
Returns
- ValueTask
A ValueTask representing the asynchronous operation
LaunchAsync<T>(ICompiledKernel, object, params object[])
Launches the kernel with launch configuration and buffer arguments (generic version). This matches the test signature for vector operations with type safety.
public static ValueTask LaunchAsync<T>(this ICompiledKernel kernel, object launchConfig, params object[] arguments) where T : unmanaged
Parameters
kernelICompiledKernelThe compiled kernel to execute
launchConfigobjectLaunch configuration (grid/block dimensions)
argumentsobject[]Variable number of kernel arguments
Returns
- ValueTask
A ValueTask representing the asynchronous operation
Type Parameters
TThe data type for type safety