dispatchThreadgroups(_:threadsPerThreadgroup:)
Encodes a compute dispatch command using a grid aligned to threadgroup boundaries.
Declaration
func dispatchThreadgroups(_ threadgroupsPerGrid: MTLSize, threadsPerThreadgroup: MTLSize)Parameters
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.