HcclSend
Applicability
|
Product |
Supported |
|---|---|
|
Atlas 350 Accelerator Card |
√ |
|
|
√ |
|
|
√ |
|
|
☓ |
|
|
☓ |
|
|
√ |
For
Function
Sends the data at the specified location on the current rank to the specified location on the destination rank.
Prototype
1
|
HcclResult HcclSend(void* sendBuf, uint64_t count, HcclDataType dataType, uint32_t destRank, HcclComm comm, aclrtStream stream) |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
sendBuf |
Input |
Address of the send buffer. |
|
count |
Input |
Number of data records to be sent. |
|
dataType |
Input |
Data type of the data to be sent, which is of the HcclDataType type. Atlas 350 Accelerator Card: The supported data types are int8, uint8, int16, uint16, int32, uint32, int64, uint64, float8-e5m2, float8-e4m3, float8-e8m0, hifloat8, float16, float32, float64, and bfp16. |
|
destRank |
Input |
ID of the destination rank in the communicator. |
|
comm |
Input |
Communicator where the operation is performed. |
|
stream |
Input |
Stream of the rank. |
Returns
HcclResult: HCCL_SUCCESS on success, or else failure.
Constraints
The HcclSend and HcclRecv interfaces are invoked synchronously and must be used in pairs. That is, after a process calls the HcclSend interface, the process can call the next interface only after the corresponding HcclRecv interface receives data, as shown in the following figure.

Call Example
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
void *sendBuf = nullptr; void *recvBuf = nullptr; uint64_t count = 8; size_t mallocSize = count * sizeof(float); // Initialize the communicator. uint32_t rankSize = 8; HcclComm hcclComm; HcclCommInitRootInfo(rankSize, &rootInfo, deviceId, &hcclComm); // Create a task flow. aclrtStream stream; aclrtCreateStream(&stream); // Perform the Send/Recv operation. Devices 0, 2, 4, and 6 send data, and devices 1, 3, 5, and 7 receive data. // The HcclSend and HcclRecv APIs are called synchronously and must be used in pairs. if (deviceId % 2 == 0) { // Allocate the device memory for storing the input data. aclrtMalloc(&sendBuf, mallocSize, ACL_MEM_MALLOC_HUGE_ONLY); // Initialize the input data. aclrtMemcpy(sendBuf, mallocSize, hostBuf, mallocSize, ACL_MEMCPY_HOST_TO_DEVICE); // Perform the Send operation. HcclSend(sendBuf, count, HCCL_DATA_TYPE_FP32, deviceId + 1, hcclComm, stream); } else { // Allocate the device memory for receiving data. aclrtMalloc(&recvBuf, mallocSize, ACL_MEM_MALLOC_HUGE_ONLY); // Perform the Recv operation. HcclRecv(recvBuf, count, HCCL_DATA_TYPE_FP32, deviceId - 1, hcclComm, stream); } // Wait until the collective communication task in the task flow is complete. aclrtSynchronizeStream(stream); // Free resources. aclrtFree(sendBuf); // Free the device memory. aclrtFree(recvBuf); // Free the device memory. aclrtDestroyStream(stream); // Destroy the task flow. HcclCommDestroy(hcclComm); // Destroy the communicator. |