Instance Property


The maximum number of threads allowed for a threadgroup dispatched to the compute function.


var maxTotalThreadsPerThreadgroup: Int { get set }


By default, when you create a MTLComputePipelineState object, Metal calculates the maximum number of threads per threadgroup that you can dispatch to it. This total is based on the characteristics of the MTLDevice and the compute function's use of thread and threadgroup memory. Metal tries to keep the program running within the GPU's available computing resources. For example, if you declare a large number of variables for each thread, then to keep the threadgroup running within the GPU's resources, Metal might allocate fewer threads per threadgroup.

Set this property if you want to allocate more threads per threadgroup than Metal allocates by default. Metal may return an error if the state object cannot be created or it may create a state object that has poor performance when used as part of a compute operation. Profile your app to determine whether setting this value provides acceptable performance.

See Also

Specifying the Compute Function and Associated Data

var computeFunction: MTLFunction?

The compute function to be compiled into the pipeline state object.

var threadGroupSizeIsMultipleOfThreadExecutionWidth: Bool

A Boolean that indicates whether the threadgroup size must always be a multiple of the thread execution width.