Instance Property

maxTotalThreadsPerThreadgroup

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

Declaration

var maxTotalThreadsPerThreadgroup: Int { get set }

Discussion

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.

var stageInputDescriptor: MTLStageInputOutputDescriptor?

The organization of input and output data for the compute function.

var buffers: MTLPipelineBufferDescriptorArray

The buffer mutability options for a compute pipeline's kernel function.

class MTLPipelineBufferDescriptor

An object that contains the mutability options for buffers used in a render or compute pass.

Beta Software

This documentation contains preliminary information about an API or technology in development. This information is subject to change, and software implemented according to this documentation should be tested with final operating system software.

Learn more about using Apple's beta software