Table of Contents

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

kernel ICompiledKernel

The compiled kernel to execute

arguments KernelArguments

Kernel arguments

options KernelExecutionOptions

Execution options

cancellationToken CancellationToken

Cancellation 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

kernel ICompiledKernel

The compiled kernel to execute

arguments KernelArguments

Kernel arguments

globalWorkSize int[]

Global work size dimensions

localWorkSize int[]

Local work size dimensions (optional)

cancellationToken CancellationToken

Cancellation 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

kernel ICompiledKernel

The compiled kernel to execute

parameters object

Execution parameters object (duck-typed compatibility)

cancellationToken CancellationToken

Cancellation 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

kernel ICompiledKernel

The compiled kernel to execute

arg1 TArg1

First kernel argument

cancellationToken CancellationToken

Cancellation token

Returns

ValueTask

A ValueTask representing the asynchronous operation

Type Parameters

TArg1

Type 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

kernel ICompiledKernel

The compiled kernel to execute

arg1 TArg1

First kernel argument

arg2 TArg2

Second kernel argument

cancellationToken CancellationToken

Cancellation token

Returns

ValueTask

A ValueTask representing the asynchronous operation

Type Parameters

TArg1

Type of the first argument

TArg2

Type 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

kernel ICompiledKernel

The compiled kernel to execute

arg1 TArg1

First kernel argument

arg2 TArg2

Second kernel argument

arg3 TArg3

Third kernel argument

cancellationToken CancellationToken

Cancellation token

Returns

ValueTask

A ValueTask representing the asynchronous operation

Type Parameters

TArg1

Type of the first argument

TArg2

Type of the second argument

TArg3

Type 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

kernel ICompiledKernel

The 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

kernel ICompiledKernel

The 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

kernel ICompiledKernel

The compiled kernel to execute

arguments KernelArguments

The kernel arguments

cancellationToken CancellationToken

Cancellation 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

kernel ICompiledKernel

The compiled kernel to execute

launchConfig object

Launch configuration (grid/block dimensions)

stream IComputeExecution

CUDA stream or execution context (IComputeExecution interface)

arguments object[]

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

kernel ICompiledKernel

The compiled kernel to execute

launchConfig object

Launch configuration (grid/block dimensions)

arguments object[]

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

kernel ICompiledKernel

The 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)

arguments KernelArguments

The kernel arguments

cancellationToken CancellationToken

Cancellation 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

kernel ICompiledKernel

The compiled kernel to execute

launchConfig object

Launch configuration (grid/block dimensions)

arguments object[]

Variable number of kernel arguments

Returns

ValueTask

A ValueTask representing the asynchronous operation

Type Parameters

T

The data type for type safety