BroadcastOperation
Applicable Products
Hardware Model |
Supported |
Description |
|---|---|---|
Atlas 350 accelerator cards |
x |
- |
√ |
- |
|
√ |
- |
|
√ |
Only lccl is supported. |
|
√ |
Only hccl is supported. |
|
x |
- |
|
x |
- |
Description
Broadcast the data on the primary communication card to each of the other cards. This operator performs in-place operation. The memory address of the output tensor is the same as that of the input tensor.
This operator involves multi-device operations. You can configure HCCL environment variables as required. For details, see Collective Communication in CANN Environment Variables.
Application Scenarios
One-to-many broadcast. Primary node 0 sends the same data to other nodes.

Example
- Parameter setting
rankRoot=0 rankSize=2
- Input and output
npu0 (primary device): x=[67,60,-75] output=[67,60,-75] npu1: x=[0,0,0] output=[67,60,-75]
Definition
1 2 3 4 5 6 7 8 9 10 11 | struct BroadcastParam { int rank = 0; int rankSize = 0; int rankRoot = 0; HcclComm hcclComm = nullptr; CommMode commMode = COMM_MULTI_PROCESS; std::string backend = "hccl"; std::string rankTableFile; std::string commDomain; uint8_t rsv[64] = {0}; }; |
Parameters
Member |
Type |
Default Value |
Description |
|---|---|---|---|
rank |
int |
0 |
Rank of the current device within the communicator. |
rankSize |
int |
0 |
Number of devices. |
rankRoot |
int |
0 |
Root rank for the operation. |
hcclComm |
HcclComm |
nullptr |
Pointer to the HCCL communicator. By default, this parameter is left blank. The ATB is created by users. If the user wants to manage the communicator, the communicator pointer needs to be passed. The ATB uses the passed communicator pointer to execute the communication operator. |
commMode |
CommMode |
COMM_MULTI_PROCESS |
Communication mode. For details, see CommMode. In the scenario where hccl multi-thread is applied, a communicator can only be imported externally. |
backend |
string |
hccl |
Communication backend. hccl and lccl are supported. The LCCL function will be deleted in later versions. You are advised to use the HCCL function. When backend is set to hccl, When backend is set to lccl:
|
rankTableFile |
string |
- |
Path of the configuration file for cluster information, which applies to single-node and multi-node communication scenarios. Currently, only the HCCL backend is supported. If a rank table is configured for a single-node system, the rank table is used to initialize the communicator. |
commDomain |
string |
- |
Communicator name used by a communication device group when there are multiple communicators. When the backend is lccl and commMode is multi-process, commDomain must be set to a value ranging from 0 to 65535. The memory size of the communicator can be set for performance optimization. The configuration format is commDomain:commDomain size (MB). For example, 0:400. When the configurations of multiple operators in the same communicator conflict, the configuration of the first operator executed in the communicator is used. Restriction: The default value is 200. Currently, the value cannot be less than 200. |
rsv[64] |
uint8_t |
{0} |
Reserved |
Input
Parameter |
Dimension |
Data Type |
Format |
Description |
|---|---|---|---|---|
x |
[dim_0, dim_1, ..., dim_n] |
|
ND |
Input tensor |
Constraints
rank, rankSize, and rankRoot must meet the following conditions:
- 0 ≤ rank < rankSize
- 0 ≤ rankRoot < rankSize
- If there are multiple users, ATB_SHARE_MEMORY_NAME_SUFFIX (see ATB Environment Variables) needs to be used to distinguish the shared memory and synchronize initialization information.
- When the communication operator of the ATB exits abnormally, run the following commands to clear the residual data to avoid affecting subsequent operations.
rm -rf /dev/shm/sem.lccl* rm -rf /dev/shm/sem.hccl* ipcrm -a
- Currently, multiple HCCP process instances cannot run on a single device, and multiple communication operators cannot run on a single device at the same time. For example, when a communication operator is running, multiple models cannot run on the same card.