cuda.bindings._v2.driver.dev_sm_resource_split#
- cuda.bindings._v2.driver.dev_sm_resource_split(
- unsigned int nb_groups,
- input,
- unsigned int flags,
- group_params,
Splits a
CU_DEV_RESOURCE_TYPE_SMresource into structured groups.This API will split a resource of
CU_DEV_RESOURCE_TYPE_SMintonb_groupsstructured device resource groups (theresultarray), as well as an optionalremainder, according to a set of requirements specified in thegroup_paramsarray. The term “structured” is a trait that specifies theresulthas SMs that are co-scheduled together. This co-scheduling can be specified via thecoscheduledSmCountfield of thegroup_paramsstructure, while thesmCountwill 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 thesmCountfield of a givengroup_paramsarray entry is set to 0 - the smCount will be filled in by the API with the derived SM count according to the providedgroup_paramsfields and constraints. Discovery can be used with both a valid result array and with a NULLresultpointer 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 theresultis NULL. Thegroup_paramsarray is evaluated from index 0 tonb_groups- 1. For each index in thegroup_paramsarray, the API will evaluate which SMs may be a good fit based on constraints and assign those SMs toresult. This evaluation order is important to consider when using discovery mode, as it helps discover the remaining SMs. For a valid call:.resultshould point to aCUdevResourcearray of sizenb_groups, or alternatively, may be NULL, if the developer wishes for only the group_params entries to be updated.inputshould be a validCU_DEV_RESOURCE_TYPE_SMresource that originates from querying the green context, device context, or device.The
remaindergroup may be NULL.There are no API
flagsat this time, so the value passed in should be 0.A
CU_DEV_SM_RESOURCE_GROUP_PARAMSarray of sizenb_groups. Each entry must be zero-initialized.smCount:must be either 0 or in the range of [2,inputSmCount] where inputSmCount is the amount of SMs theinputresource has.smCountmust be a multiple of 2, as well as a multiple ofcoscheduledSmCountif it is nonzero. When assigning SMs to a group (and if results are expected by having theresultparameter set),smCountcannot end up with 0 or a value less thancoscheduledSmCountotherwise CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION will be returned.coscheduledSmCount:allows grouping SMs together in order to be able to launch clusters on Compute Architecture 9.0+. The default value may be queried from the device’sCU_DEV_RESOURCE_TYPE_SMresource (8 on Compute Architecture 9.0+ and 2 otherwise). The maximum is 32 on Compute Architecture 9.0+ and 2 otherwise. AcoscheduledSmCountof 0 uses the default value internally while preserving 0 ingroup_params. Cluster occupancy will be derived from the resulting SM topology.preferredCoscheduledSmCount:Attempts to mergecoscheduledSmCountgroups into larger groups, in order to make use ofpreferredClusterDimensionson Compute Architecture 10.0+. The default value is set tocoscheduledSmCount.flags:.CU_DEV_SM_RESOURCE_GROUP_BACKFILL:Treats constraints as a hint, ignoring them if necessary to reach the requestedsmCount. LetssmCountbe a non-multiple ofcoscheduledSmCount, filling the difference between SM count and already assigned co-scheduled groupings with other SMs. This lets any resulting group behave similar to theremaindergroup for example. When used withCU_DEV_SM_RESOURCE_GROUP_LOCALITY_DOMAIN_ID, backfill fills up to the requestedsmCountusing the target locality domain first, then SMs not attributed to any locality domain, then SMs from other locality domains. If no SMs can be found in the requested locality domain, CUDA_ERROR_INVALID_RESOURCE_CONFIGURATION is returned.CU_DEV_SM_RESOURCE_GROUP_LOCALITY_DOMAIN_ID:Specifies that the SM partition should be localized to the specifiedlocalityDomainId.localityDomainId:Specifies the locality domain that the partitioned SMs must be located on. Only valid when CU_DEV_SM_RESOURCE_GROUP_LOCALITY_DOMAIN_ID is set in flags.
Example params and their effect:. A group_params array element is defined in the following order:. **View CUDA Toolkit Documentation for a C++ code example**. **View CUDA Toolkit Documentation for a C++ code example**. **View CUDA Toolkit Documentation for a C++ code example**. **View CUDA Toolkit Documentation for a C++ code example**. The difference between a catch-all param group as the last entry and the remainder is in two aspects:.
The remainder may be NULL / _TYPE_INVALID (if there are no SMs remaining), while a result group must always be valid.
The remainder does not have a structure, while the result group will always need to adhere to a structure of coscheduledSmCount (even if its just 2), and therefore must always have enough coscheduled SMs to cover that requirement (even with the
CU_DEV_SM_RESOURCE_GROUP_BACKFILLflag enabled).
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:
nb_groups (unsigned int) – Specifies the number of groups in
resultandgroup_params.input (intptr_t) – Input SM resource to be split. Must be a valid
CU_DEV_RESOURCE_TYPE_SMresource.flags (unsigned int) – Flags specifying how the API should behave. The value should be 0 for now.
group_params (intptr_t) – Description of how the SMs should be split and assigned to the corresponding result entry.
- Returns:
- CUdevResource_v1: Output array of
CUdevResourceresources. Can be NULL, alongside an smCount of 0, for discovery purpose.
- CUdevResource_v1: Output array of
- CUdevResource_v1: If splitting the input resource leaves any SMs,
the remainder is placed in here.
- Return type:
A 2-tuple containing
See also
cuDevSmResourceSplit