Collective Communication
Huawei Collective Communication Library (HCCL) is a high-performance collective communication library based on Ascend hardware. It provides a high-performance and high-reliability communication solution for computing clusters.
This section briefly describes HCCL. For details about how to use HCCL, see the HCCL Collective Communication Library User Guide.
Key Functions
- Provides high-performance collective communication and point-to-point communication in single-server and multi-server environments.
- Supports collective communication primitives such as AllReduce, Broadcast, AllGather, ReduceScatter, AlltoAll, Send, and Receive.
- Supports communication algorithms such as Ring, Mesh, and Recursive Halving-Doubling (RHD).
- Supports high-speed communication links such as HCCS, RoCE, PCIe, and Unified Bus (UB).
- Supports two execution modes: single-operator and graph.
- Supports custom development of communication operators.
Software Architecture
HCCL is a core component of CANN and provides a high-performance and high-reliability communication solution for NPU clusters. HCCL supports multiple AI frameworks and implements efficient interconnection between multiple Ascend AI processors. The following figure shows the HCCL architecture.

- HCCL: includes built-in communication operators and extended communication operators, and provides external communication operator APIs.
- Built-in communication operators: basic communication operators provided by HCCL, including collective communication operators and point-to-point communication operators.
- Extended communication operators: communication operators customized using the APIs provided by the HCOMM library.
- HCOMM library: uses the layered decoupling design to divide communication capabilities into the control plane and data plane capabilities.
- Control plane: provides topology information query and communication resource management functions.
- Data plane: provides data movement and computing functions such as local operations, inter-operator synchronization, and communication operations.
The control plane provides communication resources, and the data plane provides methods for operating resources. The provided APIs enable communication operator developers to focus on service innovation without paying attention to complex implementation details at the bottom layer of the chip.
Get Started
The following uses the AllReduce operator as an example to describe how to use it in single-operator execution mode, helping users quickly experience the collective communication function.
- AllReduce Operator
The AllReduce operation performs reduction (sum, prod, max, and min) over the input data of all ranks in a communicator, and then sends the result to the output buffers of all ranks.

Note: Each rank has only one input.
- Sample
You can click Link to obtain the complete sample code. In this sample, a communication domain is created based on the root node information, and an AI server is managed in a process. Each NPU device is managed by a thread. The following functions are provided:
- Detects devices and queries the number of available devices by calling aclrtGetDeviceCount().
- The rank0 is used as the root node, and rootInfo identification information of the root node is generated by using the HcclGetRootInfo () interface.
- Initializes the communicator in each thread based on rootInfo by calling HcclCommInitRootInfo().
- Calls HcclAllReduce() to add the input data of all ranks in the communicator, sends the result to all ranks, and prints the result.
- Compilation and Running
Run the following commands in the sample code directory:
1 2
make make test
- Result Analysis
The data of each rank is initialized to 0–7. After the AllReduce operation, the result of each rank is the sum of the data at the corresponding positions of all ranks (the data of eight ranks is added).
Found 8 NPU device(s) available rankId: 0, output: [ 0 8 16 24 32 40 48 56 ] rankId: 1, output: [ 0 8 16 24 32 40 48 56 ] rankId: 2, output: [ 0 8 16 24 32 40 48 56 ] rankId: 3, output: [ 0 8 16 24 32 40 48 56 ] rankId: 4, output: [ 0 8 16 24 32 40 48 56 ] rankId: 5, output: [ 0 8 16 24 32 40 48 56 ] rankId: 6, output: [ 0 8 16 24 32 40 48 56 ] rankId: 7, output: [ 0 8 16 24 32 40 48 56 ]