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
namestringparametersIReadOnlyList<KernelParameter>acceleratorIAccelerator
Properties
Accelerator
public IAccelerator Accelerator { get; }
Property Value
Id
Gets the kernel unique identifier.
public Guid Id { get; protected init; }
Property Value
IsDisposed
Gets whether this kernel has been disposed.
public bool IsDisposed { get; }
Property Value
Name
Gets the kernel name.
public string Name { get; }
Property Value
Parameters
public IReadOnlyList<KernelParameter> Parameters { get; }
Property Value
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
disposingbool
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
argumentsKernelArgumentsoptionsKernelExecutionOptionscancellationTokenCancellationToken
Returns
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
argumentsKernelArgumentsThe kernel arguments for execution.
cancellationTokenCancellationTokenA 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
argumentsKernelArgumentsoptionsKernelExecutionOptionscancellationTokenCancellationToken
Returns
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
argumentsKernelArguments