maxTotalThreadsPerThreadgroup
A property that limits the number of threads you can dispatch in a threadgroup for the compute function.
Declaration
var maxTotalThreadsPerThreadgroup: Int { get set }Discussion
Metal automatically selects a maximum threadgroup size when you set this value to 0.
Your shader can also configure the maximum number of threads per threadgroup with the [[max_total_threads_per_threadgroup]] attribute. See the Metal Shading Language Specification for more information.
By default, this property’s value is 0, which instructs Metal to calculate the maximum number of threads per threadgroup based on the device’s capabilities and the compute shader’s memory usage.
The maxTotalThreadsPerThreadgroup property of an MTLComputePipelineState instance reports the maximum number of threads you can dispatch in a threadgroup for that specific compute shader.
Metal may return an error if this value exceeds the available resources for the device, or Metal may lower the thread limit when creating the compute pipeline state, which can reduce runtime performance.