Class MetalCommandExecutor
- Namespace
- DotCompute.Backends.Metal.Execution
- Assembly
- DotCompute.Backends.Metal.dll
Production implementation of IMetalCommandExecutor that makes actual Metal native API calls.
public sealed class MetalCommandExecutor : IMetalCommandExecutor
- Inheritance
-
MetalCommandExecutor
- Implements
- Inherited Members
Constructors
MetalCommandExecutor(ILogger<MetalCommandExecutor>)
public MetalCommandExecutor(ILogger<MetalCommandExecutor> logger)
Parameters
loggerILogger<MetalCommandExecutor>
Methods
CommitAndWaitAsync(nint, CancellationToken)
Commits a command buffer and waits for completion.
public 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.
public 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.
public 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.
public 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.
public 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.
public 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.
public void EndEncoding(nint encoder)
Parameters
encodernintThe encoder to end.
FillBuffer(nint, nint, byte, long)
Fills a Metal buffer with a specific byte value.
public 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.
public void ReleaseCommandBuffer(nint commandBuffer)
Parameters
commandBuffernintThe command buffer to release.
SetComputePipelineState(nint, object)
Sets the compute pipeline state for kernel execution.
public void SetComputePipelineState(nint encoder, object kernel)
Parameters
SetKernelArgument(nint, int, object)
Sets a kernel argument at the specified index.
public void SetKernelArgument(nint encoder, int index, object argument)