Class MetalCooperativeGroups
- Namespace
- DotCompute.Backends.Metal.Execution
- Assembly
- DotCompute.Backends.Metal.dll
Metal cooperative groups manager for synchronization primitives. Provides grid-wide synchronization, threadgroup coordination, and Metal barrier optimization. Equivalent to CUDA cooperative groups for Metal compute kernels.
public sealed class MetalCooperativeGroups : IDisposable
- Inheritance
-
MetalCooperativeGroups
- Implements
- Inherited Members
- Extension Methods
Constructors
MetalCooperativeGroups(nint, ILogger<MetalCooperativeGroups>)
public MetalCooperativeGroups(nint device, ILogger<MetalCooperativeGroups> logger)
Parameters
devicenintloggerILogger<MetalCooperativeGroups>
Methods
CreateSyncPoint(nint, string)
Creates a synchronization point in the command buffer.
public void CreateSyncPoint(nint commandBuffer, string label)
Parameters
Dispose()
Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.
public void Dispose()
GetMetrics()
Gets synchronization metrics.
public CooperativeGroupsMetrics GetMetrics()
Returns
GetThreadgroupSize(nint)
Gets the maximum threadgroup size supported by the device.
public int GetThreadgroupSize(nint device)
Parameters
devicenint
Returns
GridSyncAsync(nint, CancellationToken)
Performs grid-wide synchronization across all threadgroups. Equivalent to CUDA cooperative groups grid_sync.
public Task GridSyncAsync(nint commandBuffer, CancellationToken cancellationToken = default)
Parameters
commandBuffernintcancellationTokenCancellationToken
Returns
SupportsGridSync(nint)
Checks if grid-wide synchronization is supported. Metal supports this through command buffer synchronization.
public bool SupportsGridSync(nint device)
Parameters
devicenint
Returns
ThreadgroupBarrier(nint)
Inserts a threadgroup memory barrier in the command encoder. Equivalent to __syncthreads() in CUDA.
public void ThreadgroupBarrier(nint commandEncoder)
Parameters
commandEncodernint
WaitForSyncPointAsync(nint, CancellationToken)
Waits for a synchronization point to complete.
public Task WaitForSyncPointAsync(nint commandBuffer, CancellationToken cancellationToken = default)
Parameters
commandBuffernintcancellationTokenCancellationToken