pub unsafe extern "C" fn cudaDevSmResourceSplit(
result: *mut cudaDevResource,
nbGroups: c_uint,
input: *const cudaDevResource,
remainder: *mut cudaDevResource,
flags: c_uint,
groupParams: *mut cudaDevSmResourceGroupParams,
) -> cudaError_tExpand description
Splits a cudaDevResourceType::cudaDevResourceTypeSm resource into structured groups.
This API will split a resource of cudaDevResourceType::cudaDevResourceTypeSm into nbGroups structured device resource groups (the result array), as well as an optional remainder, according to a set of requirements specified in the groupParams array. The term “structured” is a trait that specifies the result has SMs that are co-scheduled together. This co-scheduling can be specified via the coscheduledSmCount field of the groupParams structure, while the smCount will specify how many SMs are required in total for that result. The remainder is always “unstructured”, it does not have any set guarantees with respect to co-scheduling and those properties will need to either be queried via the occupancy set of APIs or further split into structured groups by this API.
The API has a discovery mode for use cases where it is difficult to know ahead of time what the SM count should be. Discovery happens when the smCount field of a given groupParams array entry is set to 0 - the smCount will be filled in by the API with the derived SM count according to the provided groupParams fields and constraints. Discovery can be used with both a valid result array and with a NULL result pointer value. The latter is useful in situations where the smCount will end up being zero, which is an invalid value to create a result entry with, but allowed for discovery purposes when the result is NULL.
The groupParams array is evaluated from index 0 to nbGroups - 1. For each index in the groupParams array, the API will evaluate which SMs may be a good fit based on constraints and assign those SMs to result. This evaluation order is important to consider when using discovery mode, as it helps discover the remaining SMs.
For a valid call:
Example params and their effect:
A groupParams array element is defined in the following order:
The difference between a catch-all param group as the last entry and the remainder is in two aspects:
Splitting an input into N groups, can be accomplished by repeatedly splitting off 1 group and re-splitting the remainder (a bisect operation). However, it’s recommended to accomplish this with a single call wherever possible.
§Parameters
result: Output array ofcudaDevResourceresources. Can be NULL, alongside an smCount of 0, for discovery purpose.nbGroups: Specifies the number of groups inresultandgroupParams.input: Input SM resource to be split. Must be a validcudaDevResourceType::cudaDevResourceTypeSmresource.remainder: If splitting the input resource leaves any SMs, the remainder is placed in here.flags: Flags specifying how the API should behave. The value should be 0 for now.groupParams: Description of how the SMs should be split and assigned to the corresponding result entry.