HcclChannelAcquire
Applicability
Product |
Supported |
|---|---|
Atlas 350 Accelerator Card |
√ |
√ |
|
√ |
|
x |
|
x |
|
x |
8
For
Function
Obtains multiple communication channels based on the communicator. If the communicator does not have the corresponding communication channel, the communication channel is directly created.
Whether the channel is reused is determined based on the unique channel ID consisting of commId, engine, remoterank, and channelProtocol.
Prototype
1 | HcclResult HcclChannelAcquire(HcclComm comm, CommEngine engine, const HcclChannelDesc *channelDescs, uint32_t channelNum, ChannelHandle *channels) |
Parameters
Parameter |
Input/Output |
Description |
||
|---|---|---|---|---|
comm |
Input |
Communicator handle. The HcclComm type is defined as follows:
|
||
engine |
Input |
Communication engine type. For the definition of the CommEngine type, see CommEngine. |
||
channelDescs |
Input |
Communication channel description list. The list length is channelNum. For the definition of the HcclChannelDesc type, see HcclChannelDesc. You can obtain the value by calling HcclRankGraphGetLinks. |
||
channelNum |
Input |
Number of communication channels. The value range is (0, 1024 × 1024]. |
||
channels |
Output |
List of communication channel handles. The list length is channelNum. |
Returns
HcclResult: HCCL_SUCCESS on success, or else failure.
Restrictions
When CommEngine is set to CCU, NotifyNum cannot be configured externally. By default, eight CCU Notify resources are configured.
When CommEngine is set to CCU, additional custom memory cannot be exchanged. Only the HcclBuffer of the communicator can be exchanged.
Example
The following uses batch communication channels as an example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 | // 1. Call HcclRankGraphGetLinks to obtain link information. CommLink *linkList = nullptr; uint32_t listSize; CHK_RET(HcclRankGraphGetLinks(comm, netLayer, myRank, rank, &linkList, &listSize)); // 2. Traverse each CommLink and fill in HcclChannelDesc. uint32_t channelNum = listSize; std::vector<HcclChannelDesc> channelDescVec(channelNum); for (uint32_t idx = 0; idx < listSize; idx++) { HcclChannelDesc channelDesc; HcclChannelDescInit(&channelDesc, 1); channelDesc.remoteRank = rank; CommLink link = linkList[idx]; // Core mapping: Extract endpoints from CommLink. channelDesc.localEndpoint.protocol = link.srcEndpointDesc.protocol; channelDesc.localEndpoint.commAddr = link.srcEndpointDesc.commAddr; channelDesc.localEndpoint.loc = link.srcEndpointDesc.loc; channelDesc.remoteEndpoint.protocol = link.dstEndpointDesc.protocol; channelDesc.remoteEndpoint.commAddr = link.dstEndpointDesc.commAddr; channelDesc.remoteEndpoint.loc = link.dstEndpointDesc.loc; channelDesc.channelProtocol = link.linkAttr.linkProtocol; channelDesc.notifyNum = NORMAL_NOTIFY_NUM; channelDescVec[idx] = channelDesc; } // 3. Create channels in batches. HcclComm comm; CommEngine engine = CommEngine::COMM_ENGINE_CPU_TS; std::vector<ChannelHandle> channels(channelNum); HcclChannelAcquire(comm, engine, channelDescVec.data(), channelNum, channels.data()); |