Contents

dispatchThreadgroups(_:threadsPerThreadgroup:)

Encodes a compute dispatch command using a grid aligned to threadgroup boundaries.

Declaration

func dispatchThreadgroups(_ threadgroupsPerGrid: MTLSize, threadsPerThreadgroup: MTLSize)

Parameters

  • threadgroupsPerGrid:

    An Mtlsize instance that represents the number of threads for each grid dimension.

  • threadsPerThreadgroup:

    An Mtlsize instance that represents the number of threads in a threadgroup.

Mentioned in

Discussion

Metal calculates the number of threads in a grid by multiplying threadsPerThreadgroup by threadgroupsPerGrid.

If the size of your data doesn’t match the size of the grid, perform boundary checks in your compute function to avoid accessing data out of bounds. See Calculating threadgroup and grid sizes for an example.

See Also

Dispatching kernel calls directly