HcommAcquireComm
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
x |
√ |
|
√ |
|
x |
|
x |
|
x |
For
Function
Obtains the corresponding communicator based on the passed commId and locks the communicator to prevent it from being obtained repeatedly.
Prototype
1 | int32_t HcommAcquireComm(const char* commId) |
Parameters
Parameter |
Input/Output |
Description |
|---|---|---|
commId |
Input |
Communicator ID. |
Returns
int32_t: 0 on success; else, failure.
Restrictions
- This API can be called on the device only in AICPU mode.
- HcommAcquireComm and HcommReleaseComm correspond to the lock and unlock actions, respectively, and must be called in pairs. The API internally intercepts repeated lock actions to prevent the same communicator from being occupied by multiple threads at the same time.
Example
This function needs to be compiled and used on the device:
// Kernel function executed on the AICPU
extern "C" unsigned int HcclAicpuKernel(const char* commId)
{
// Lock the communicator to prevent it from being used concurrently.
if (HcommAcquireComm(commId) != HCCL_SUCCESS) {
return 1;
}
// Execute task orchestration.
// ...
// Release the communicator.
if (HcommReleaseComm(commId) != HCCL_SUCCESS) {
return 1;
}
return 0;
}
Parent topic: Others