HcclAlltoAllVC
Applicability
|
Product |
Supported |
|---|---|
|
Atlas 350 Accelerator Card |
√ |
|
|
√ |
|
|
√ |
|
|
☓ |
|
|
☓ |
|
|
☓ |
For
Function
Sends data (with customizable size) to all ranks in the communicator and receives data from all ranks. Unlike AlltoAllV, AlltoAllVC uses the input parameter sendCountMatrix to pass the RX and TX parameters of all ranks.

Prototype
1
|
HcclResult HcclAlltoAllVC(const void *sendBuf, const void *sendCountMatrix, HcclDataType sendType, const void *recvBuf, HcclDataType recvType, HcclComm comm, aclrtStream stream) |
Parameters
|
Parameter |
Input/Output |
Description |
|---|---|---|
|
sendBuf |
Input |
Address of the send buffer. |
|
sendCountMatrix |
Input |
Two-dimensional uint64 array, indicating the amount of data to be sent. The array shape is [rankSize][rankSize]. sendCountMatrix[i][j] = n indicates that n data elements is sent from rank i to rank j. For example, if sendType is float32, sendCountMatrix[i][j] = n indicates that n float32 data elements is sent from rank i rank j. |
|
sendType |
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. |
|
recvBuf |
Output |
Address of the buffer to receive collective communication results. The addresses configured for recvBuf and sendBuf must be different. |
|
recvType |
Input |
Data type of the data to be received, 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. |
|
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 performance of the AlltoAllVC operation is related to the size of the buffer for storing shared data between NPUs. When the communication data size exceeds the buffer size, the performance deteriorates significantly. If the AlltoAllVC communication data size in the service is large, you are advised to increase the buffer size appropriately by setting environment variable HCCL_BUFFSIZE to improve the communication performance.
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 |
// 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); // Set the amount of data to be sent and received. The amount of data to be sent is the same as that of data to be received. std::vector<uint64_t> sendCountMatrix(rankSize * rankSize); for (uint32_t i = 0; i < rankSize; ++i) { for (uint32_t j = 0; j < rankSize; ++j) { sendCountMatrix[i * rankSize + j] = count / rankSize; } } // Perform AlltoAllVC to send data of the same size to all ranks in the communicator and receive data of the same size from all ranks. The data size can be customized. HcclAlltoAllVC(sendBuf, sendCountMatrix.data(), HCCL_DATA_TYPE_FP32, recvBuf, 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. |