HcommAcquireComm

Applicability

Product

Supported

Atlas 350 Accelerator Card

x

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product

x

Atlas training product

x

For Atlas A2 training product/Atlas A2 inference product, only the Atlas 800T A2 training server, Atlas 900 A2 PoD cluster basic unit, and Atlas 200T A2 Box16 heterogeneous subrack are supported.

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

  1. This API can be called on the device only in AICPU mode.
  2. 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;
}