HcclRankGraphGetRanksByLayer

Applicability

Product

Supported

Atlas 350 Accelerator Card

Atlas A3 training product/Atlas A3 inference product

Atlas A2 training product/Atlas A2 inference product

Atlas 200I/500 A2 inference product

x

Atlas inference product

x

Atlas training product

x

For Atlas A2 training product/Atlas A2 inference product, only the Atlas 800T A2 training server, Atlas 900 A2 PoD cluster basic unit, and Atlas 200T A2 Box16 heterogeneous subrack are supported.

Function

Returns the list of all rank IDs and the number of ranks in the topology instance where the current rank is located at a specified topology layer in a specified communicator.

Take the preceding topology model as an example:
  • Layer 0 contains two topology instances. For easy understanding, the topology instance IDs are defined as 0 and 1.
  • Layer 1 contains one topology instance.

Assume that this API is called on rank 0. If the specified layer is 0, the rank ID list returned by this API is [0,1,2] and the number of ranks is 3. If the specified layer is 1, the rank ID list returned by this API is [0,1,2,3,4,5] and the number of ranks is 6.

Prototype

1
HcclResult HcclRankGraphGetRanksByLayer(HcclComm comm, uint32_t netLayer, uint32_t **ranks, uint32_t *rankNum)

Parameters

Parameter

Input/Output

Description

comm

Input

Communicator.

The HcclComm type is defined as follows:

1
typedef void *HcclComm;

netLayer

Input

Topology layer ID.

ranks

Output

List of rank IDs.

rankNum

Output

Number of ranks.

Returns

HcclResult: HCCL_SUCCESS on success, or else failure.

Restrictions

None

Example

The following uses the topology model in Function as an example:

For rank 0:

1
2
3
4
5
6
7
HcclComm commTp;
vector<uint32_t> ranks;
uint32_t rankNum;
HcclRankGraphGetRanksByLayer(commTp, netLayer=0, &ranks, &rankNum);
// For a level-0 topology, ranks = [0,1,2] and rankNum = 3.
HcclRankGraphGetRanksByLayer(commTp, netLayer=1, &ranks, &rankNum);
// For a level-1 topology, ranks = [0,1,2,3,4,5] and rankNum = 6.

For rank 3:

1
2
3
4
5
6
7
HcclComm commTp;
vector<uint32_t> ranks;
uint32_t rankNum;
HcclRankGraphGetRanksByLayer(commTp, netLayer=0, &ranks, &rankNum);
// For a level-0 topology, ranks = [3,4,5] and rankNum = 3.
HcclRankGraphGetRanksByLayer(commTp, netLayer=1, &ranks, &rankNum);
// For a level-1 topology, ranks = [0,1,2,3,4,5] and rankNum = 6.