HcommChannelCreate【免费下载链接】hcommHCOMMHuawei Communication是HCCL的通信基础库提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcomm产品支持情况Ascend 950PR/Ascend 950DT支持Atlas A3 训练系列产品/Atlas A3 推理系列产品不支持Atlas A2 训练系列产品/Atlas A2 推理系列产品不支持功能说明该接口为创建通信通道的资源管理接口基于已创建的网络端点Endpoint根据给定的通道描述信息批量创建通信通道为点对点通信或集合通信提供数据传输的基础设施。函数原型HcommResult HcommChannelCreate(EndpointHandle endpointHandle, CommEngine engine, HcommChannelDesc *channelDescs, uint32_t channelNum, ChannelHandle *channels);参数说明参数名输入/输出说明endpointHandle输入网络设备端点句柄标识一个已创建的本地网络设备端点。EndpointHandle类型的定义请参见EndpointHandle该句柄必须通过HcommEndpointCreate成功创建且未销毁。engine输入通信引擎类型指定通道的执行位置。CommEngine类型的定义请参见CommEngine。需要注意必须是有效的引擎类型。channelDescs输入通道描述符数组每个元素描述一个待创建通道的属性信息。HcommChannelDesc类型的定义请参见HcommChannelDesc。数组元素数量必须等于channelNum每个元素需正确填充必要字段。channelNum输入待创建的通道数量。单位个取值范围[1, 1048576]。该参数需要大于 0。channels输出通道句柄数组用于返回创建成功的通道句柄列表。ChannelHandle类型的定义请参见ChannelHandle。调用者分配的数组需要至少包含channelNum个元素的空间。返回值HcommResult接口成功返回0其他失败。约束说明channelDescs数组长度必须与channelNum参数一致。HcommChannelDesc中的remoteEndpoint必须正确填充远端端点信息。当HcommChannelDesc中exchangeAllMems为false时必须配置memHandles和memHandleNum。当前CommEngine配置为CCU时仅支持交换1份memHandle。当前CommEngine配置为CCU时不支持外部配置NotifyNum默认为8个CCU Notify。支持的通信协议包括RoCE、UBC_TP、UBC_CTP、UBoE。调用示例// 1. 调用 HcclRankGraphGetLinks 获取链路信息 CommLink *linkList nullptr; uint32_t listSize; CHK_RET(HcclRankGraphGetLinks(comm, netLayer, myRank, rank, linkList, listSize)); // 2. 遍历每个 CommLink填充 HcommChannelDesc uint32_t channelNum listSize; std::vectorHcommChannelDesc hcommDescVec(channelNum); HcommChannelDescInit(hcommDescVec.data(), hcommDescVec.size()); for (uint32_t idx 0; idx listSize; idx) { HcommChannelDesc channelDesc; CommLink link linkList[idx]; // 核心映射从 CommLink 提取 Endpoint 信息 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; hcommDescVec[idx] channelDesc; // socket配置为空 HcommSocket hcommSocket nullptr; hcommDescVec[idx].socket hcommSocket; } // 参考 MyRank 下 BatchCreateChannels 获取 EndpointHandle EndpointHandle epHandle nullptr; ... // 3. 批量创建 Channel CommEngine engine CommEngine::COMM_ENGINE_CPU_TS; std::vectorChannelHandle channels(channelNum); HcommChannelCreate(epHandle, engine, hcommDescVec.data(), channelNum, channels.data());【免费下载链接】hcommHCOMMHuawei Communication是HCCL的通信基础库提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcomm创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考