Product |
Supported |
|---|---|
√ |
|
√ |
|
☓ |
|
√ |
|
√ |
For
For the
Re-sorts the inputs of all ranks in the communicator by rank ID, combines the inputs, and sends the results to the outputs of all ranks.

For the AllGather operation, each rank receives a set of data that is resorted by rank ID, that is, AllGather outputs of all ranks are the same.
1 | HcclResult HcclAllGather(void *sendBuf, void *recvBuf, uint64_t sendCount, HcclDataType dataType, HcclComm comm, aclrtStream stream) |
Parameter |
Input/Output |
Description |
|---|---|---|
sendBuf |
Input |
Address of the send buffer. |
recvBuf |
Output |
Address of the buffer to receive collective communication result. |
sendCount |
Input |
sendBuf size involved in the AllGather operation. The size of recvBuf data is calculated as: sendCount × rank size. |
dataType |
Input |
Data type of the Allgather operation, which is of the HcclDataType type. Atlas 300I Duo inference card: The supported data types are int8, uint8, int16, uint16, int32, uint32, int64, uint64, float16, float32, and float64. |
comm |
Input |
Communicator where the operation is performed. |
stream |
Input |
Stream of the rank. |
HcclResult: HCCL_SUCCESS on success; else, failure.
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 | // Allocate device memory for collective communication. void *sendBuf = nullptr, *recvBuf = nullptr; uint32_t rankSize = 8; uint64_t sendCount = 1; // Number of data records sent by each rank. size_t sendSize = sendCount * sizeof(float); size_t recvSize = rankSize * sendCount * sizeof(float); aclrtMalloc(&sendBuf, sendSize, ACL_MEM_MALLOC_HUGE_ONLY); aclrtMalloc(&recvBuf, recvSize, ACL_MEM_MALLOC_HUGE_ONLY); // Initialize the communicator and streams. HcclComm hcclComm; HcclCommInitRootInfo(rankSize, &rootInfo, devId, &hcclComm); // Create a task flow. aclrtStream stream; aclrtCreateStream(&stream); // Execute AllGather to stitch sendBuf of all ranks in the communicator by the sequence of rank IDs, and send the result to recvBuf of all ranks. HcclAllGather(sendBuf, recvBuf, sendCount, HCCL_DATA_TYPE_FP32, 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. |