BroadcastOperation
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 . For details about how to configure TLS, see the HCCN Tool API Reference of the corresponding device.
This operator is not supported by the
Application Scenarios
One-to-many broadcast mode. Primary node 0 sends the same data to other nodes.

Example
Parameter setting
rankRoot=0 rankSize=2
Input and output
npu0 (primary communication card): x=[67,60,-75] output=[67,60,-75] npu1: x=[0,0,0] output=[67,60,-75]
Definition
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 |
Communication ID of the current card. |
rankSize |
int |
0 |
Number of communication cards |
rankRoot |
int |
0 |
Primary communication rank. |
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. Only hccl and lccl are supported. |
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 ranktable is configured for a single-node system, the ranktable is used to initialize the communicator. For details, see . |
commDomain |
string |
- |
Communicator name used by a communication device group when there are multiple communicators. When backend is set to lccl and commMode is multi-process, commDomain must be set to a number ranging from 0 to 63. When commMode is multi-thread, deterministic computing is not supported. In this case, LCCL_DETERMINISTIC must be set to 0 or false. In the multi-process/multi-thread multi-communicator concurrency scenario, LCCL_PARALLEL must be set to 1 or true. After the multi-communicator parallelism is used, LCCL_PARALLEL must be set to 0 or false. Otherwise, the performance in basic scenarios deteriorates. |
rsv[64] |
uint8_t |
{0} |
Reserved |
Input
Parameter |
Dimension |
Data Type |
Format |
Description |
|---|---|---|---|---|
x |
[-1,…,-1] The value -1 indicates that the size of the current dimension is not restricted. |
|
ND |
Input tensor |
Restrictions
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.