Table of Contents

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

device nint
logger ILogger<MetalCooperativeGroups>

Methods

CreateSyncPoint(nint, string)

Creates a synchronization point in the command buffer.

public void CreateSyncPoint(nint commandBuffer, string label)

Parameters

commandBuffer nint
label string

Dispose()

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

public void Dispose()

GetMetrics()

Gets synchronization metrics.

public CooperativeGroupsMetrics GetMetrics()

Returns

CooperativeGroupsMetrics

GetThreadgroupSize(nint)

Gets the maximum threadgroup size supported by the device.

public int GetThreadgroupSize(nint device)

Parameters

device nint

Returns

int

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

commandBuffer nint
cancellationToken CancellationToken

Returns

Task

SupportsGridSync(nint)

Checks if grid-wide synchronization is supported. Metal supports this through command buffer synchronization.

public bool SupportsGridSync(nint device)

Parameters

device nint

Returns

bool

ThreadgroupBarrier(nint)

Inserts a threadgroup memory barrier in the command encoder. Equivalent to __syncthreads() in CUDA.

public void ThreadgroupBarrier(nint commandEncoder)

Parameters

commandEncoder nint

WaitForSyncPointAsync(nint, CancellationToken)

Waits for a synchronization point to complete.

public Task WaitForSyncPointAsync(nint commandBuffer, CancellationToken cancellationToken = default)

Parameters

commandBuffer nint
cancellationToken CancellationToken

Returns

Task