Table of Contents

Class BaseCompiledKernel

Namespace
DotCompute.Core
Assembly
DotCompute.Core.dll

Base class for compiled kernels, consolidating common patterns.

public abstract class BaseCompiledKernel : ICompiledKernel, IAsyncDisposable, IDisposable
Inheritance
BaseCompiledKernel
Implements
Inherited Members
Extension Methods

Constructors

BaseCompiledKernel(string, IReadOnlyList<KernelParameter>, IAccelerator)

Initializes a new instance of the BaseCompiledKernel class.

protected BaseCompiledKernel(string name, IReadOnlyList<KernelParameter> parameters, IAccelerator accelerator)

Parameters

name string
parameters IReadOnlyList<KernelParameter>
accelerator IAccelerator

Properties

Accelerator

public IAccelerator Accelerator { get; }

Property Value

IAccelerator

Id

Gets the kernel unique identifier.

public Guid Id { get; protected init; }

Property Value

Guid

IsDisposed

Gets whether this kernel has been disposed.

public bool IsDisposed { get; }

Property Value

bool

Name

Gets the kernel name.

public string Name { get; }

Property Value

string

Parameters

public IReadOnlyList<KernelParameter> Parameters { get; }

Property Value

IReadOnlyList<KernelParameter>

Methods

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

Dispose(bool)

Disposes the kernel.

protected virtual void Dispose(bool disposing)

Parameters

disposing bool

DisposeAsync()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources asynchronously.

public ValueTask DisposeAsync()

Returns

ValueTask

A task that represents the asynchronous dispose operation.

DisposeCore()

Core disposal logic to be implemented by derived classes.

protected virtual void DisposeCore()

ExecuteAsync(KernelArguments, KernelExecutionOptions?, CancellationToken)

public virtual ValueTask<KernelExecutionResult> ExecuteAsync(KernelArguments arguments, KernelExecutionOptions? options = null, CancellationToken cancellationToken = default)

Parameters

arguments KernelArguments
options KernelExecutionOptions
cancellationToken CancellationToken

Returns

ValueTask<KernelExecutionResult>

ExecuteAsync(KernelArguments, CancellationToken)

Executes the kernel with given arguments. Derived classes must implement this to provide their specific execution logic.

public abstract ValueTask ExecuteAsync(KernelArguments arguments, CancellationToken cancellationToken = default)

Parameters

arguments KernelArguments

The kernel arguments for execution.

cancellationToken CancellationToken

A cancellation token for the operation.

Returns

ValueTask

A task representing the asynchronous execution operation.

Exceptions

ArgumentNullException

Thrown when arguments is null.

ObjectDisposedException

Thrown when the accelerator has been disposed.

ExecuteCoreAsync(KernelArguments, KernelExecutionOptions, CancellationToken)

Core execution logic to be implemented by derived classes.

protected abstract ValueTask<KernelExecutionResult> ExecuteCoreAsync(KernelArguments arguments, KernelExecutionOptions options, CancellationToken cancellationToken)

Parameters

arguments KernelArguments
options KernelExecutionOptions
cancellationToken CancellationToken

Returns

ValueTask<KernelExecutionResult>

ThrowIfDisposed()

Throws if the kernel has been disposed.

protected void ThrowIfDisposed()

ValidateArguments(KernelArguments)

Validates kernel arguments against parameters.

protected virtual void ValidateArguments(KernelArguments arguments)

Parameters

arguments KernelArguments