Interface IMetalCommandExecutor
- Namespace
- DotCompute.Backends.Metal.Execution.Interfaces
- Assembly
- DotCompute.Backends.Metal.dll
Abstraction for Metal command execution operations. This interface decouples graph execution logic from low-level Metal API calls, enabling testability and potential support for other GPU backends.
public interface IMetalCommandExecutor
Methods
CommitAndWaitAsync(nint, CancellationToken)
Commits a command buffer and waits for completion.
Task CommitAndWaitAsync(nint commandBuffer, CancellationToken cancellationToken = default)
Parameters
commandBuffernintThe command buffer to commit.
cancellationTokenCancellationTokenOptional cancellation token.
Returns
- Task
A task that completes when the command buffer finishes execution.
CopyBuffer(nint, nint, long, nint, long, long)
Copies data between Metal buffers.
void CopyBuffer(nint encoder, nint sourceBuffer, long sourceOffset, nint destBuffer, long destOffset, long size)
Parameters
encodernintThe blit encoder.
sourceBuffernintSource buffer handle.
sourceOffsetlongOffset in source buffer.
destBuffernintDestination buffer handle.
destOffsetlongOffset in destination buffer.
sizelongNumber of bytes to copy.
CreateBlitCommandEncoder(nint)
Creates a blit command encoder for memory operations.
nint CreateBlitCommandEncoder(nint commandBuffer)
Parameters
commandBuffernintThe command buffer.
Returns
- nint
Handle to the created blit encoder.
CreateCommandBuffer(nint)
Creates a Metal command buffer from the command queue.
nint CreateCommandBuffer(nint commandQueue)
Parameters
commandQueuenintThe Metal command queue.
Returns
- nint
Handle to the created command buffer.
CreateComputeCommandEncoder(nint)
Creates a compute command encoder for kernel execution.
nint CreateComputeCommandEncoder(nint commandBuffer)
Parameters
commandBuffernintThe command buffer.
Returns
- nint
Handle to the created compute encoder.
DispatchThreadgroups(nint, MTLSize, MTLSize)
Dispatches compute threadgroups for kernel execution.
void DispatchThreadgroups(nint encoder, MTLSize threadgroupsPerGrid, MTLSize threadsPerThreadgroup)
Parameters
encodernintThe compute encoder.
threadgroupsPerGridMTLSizeNumber of threadgroups per grid.
threadsPerThreadgroupMTLSizeNumber of threads per threadgroup.
EndEncoding(nint)
Ends command encoding.
void EndEncoding(nint encoder)
Parameters
encodernintThe encoder to end.
FillBuffer(nint, nint, byte, long)
Fills a Metal buffer with a specific byte value.
void FillBuffer(nint encoder, nint buffer, byte value, long size)
Parameters
encodernintThe blit encoder.
buffernintBuffer handle.
valuebyteFill value.
sizelongNumber of bytes to fill.
ReleaseCommandBuffer(nint)
Releases a command buffer and its resources.
void ReleaseCommandBuffer(nint commandBuffer)
Parameters
commandBuffernintThe command buffer to release.
SetComputePipelineState(nint, object)
Sets the compute pipeline state for kernel execution.
void SetComputePipelineState(nint encoder, object kernel)
Parameters
SetKernelArgument(nint, int, object)
Sets a kernel argument at the specified index.
void SetKernelArgument(nint encoder, int index, object argument)