HcclAllReduce

Description

Adds the input data of all nodes in the communicator (or performs other reduction operations) and sends the result to the output buffer of all nodes. The reduction operation type is specified by the op parameter.

Prototype

HcclResult HcclAllReduce(void *sendBuf, void *recvBuf, uint64_t count, HcclDataType dataType, HcclReduceOp op, HcclComm comm, aclrtStream stream)

Parameters

Parameter

Input/Output

Description

sendBuf

Input

Address of the buffer to send source data.

recvBuf

Output

Address of the buffer to receive collective communication result.

count

Input

Number of data elements to perform AllReduce operation. For example, if only one int32 data element is involved, then count = 1.

dataType

Input

Data type of the AllReduce operation, which is of the HcclDataType type.

Atlas Training Series Product : The supported data types are int8, int32, int64, float16, and float32.

op

Input

Reduction operation type. Currently, the following operation types are supported: sum, prod, max, and min.

NOTE:

comm

Input

Communicator where the operation is performed.

stream

Input

Stream of the rank.

Returns

HcclResult: HCCL_SUCCESS on success; else, failure.

Constraints

  • The ranks must have the same count, dataType, and op.
  • Each rank has only one input.

Applicability

Atlas Training Series Product

Example

For details, see the HcclAllReduce operation code example of each communicator initialization mode in Example Code.