Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
☓ |
|
☓ |
|
√ |
For
Completes sending and receiving tasks in batches on the current rank. The sending and receiving tasks of the current rank are asynchronous and do not block each other.
1 | HcclResult HcclBatchSendRecv(HcclSendRecvItem* sendRecvInfo, uint32_t itemNum, HcclComm comm, aclrtStream stream) |
Parameter |
Input/Output |
Description |
|---|---|---|
sendRecvInfo |
Input |
Start address of the list of sending and receiving tasks to be distributed in the rank. HcclSendRecvItem type. For details, see HcclSendRecvItem. Note that the int128 data type is not supported by the Atlas 350 Accelerator Card. |
itemNum |
Input |
Number of tasks to be received and sent by the rank. |
comm |
Input |
Communicator where the operation is performed. |
stream |
Input |
Stream of the rank. |
HcclResult: HCCL_SUCCESS on success, or else failure.
export HCCL_INTRA_ROCE_ENABLE=1 export HCCL_INTRA_PCIE_ENABLE=0
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 | // Allocate device memory for collective communication. void *sendBuf = nullptr; void *recvBuf = nullptr; uint64_t count = 8; size_t mallocSize = count * sizeof(float); aclrtMalloc((void **)&sendBuf, mallocSize, ACL_MEM_MALLOC_HUGE_ONLY); aclrtMalloc((void **)&recvBuf, mallocSize, ACL_MEM_MALLOC_HUGE_ONLY); // 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 to send data to the next rank and receive data from the previous rank. // HcclBatchSendRecv can deliver multiple RX and TX tasks on the local rank at the same time. uint32_t next = (deviceId + 1) % count; uint32_t prev = (deviceId - 1 + count) % count; HcclSendRecvItem sendRecvInfo[2]; sendRecvInfo[0] = HcclSendRecvItem{HCCL_SEND, sendBuf, count, HCCL_DATA_TYPE_FP32, next}; sendRecvInfo[1] = HcclSendRecvItem{HCCL_RECV, recvBuf, count, HCCL_DATA_TYPE_FP32, prev}; HcclBatchSendRecv(sendRecvInfo, 2, hcclComm, stream); // Wait until the collective communication task in the task flow is complete. ACLCHECK(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. |