华为通信库HCOMM线程配置获取

华为通信库HCOMM线程配置获取
HcclThreadAcquireWithConfig【免费下载链接】hcommHCOMMHuawei Communication是HCCL的通信基础库提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcomm产品支持情况Ascend 950PR/Ascend 950DT支持Atlas A3 训练系列产品/Atlas A3 推理系列产品支持Atlas A2 训练系列产品/Atlas A2 推理系列产品支持功能说明基于通信域和线程配置获取通信线程资源。与HcclThreadAcquire相比该接口支持通过ThreadConfig结构体逐线程配置同步资源数量适用于不同线程需要不同数量Notify的场景。函数原型HcclResult HcclThreadAcquireWithConfig(HcclComm comm, CommEngine engine, uint32_t threadNum, ThreadType type, const ThreadConfig *config, ThreadHandle *threads)参数说明参数名输入/输出描述comm输入通信域句柄。HcclComm类型的定义如下typedef void *HcclComm;engine输入通信引擎类型。CommEngine类型的定义可参见CommEngine。threadNum输入通信线程数量。一个通信域内最多申请40条流。type输入线程类型。当前支持THREAD_TYPE_TS。config输入每线程的配置信息数组长度须与threadNum一致。调用前须使用ThreadConfigInit初始化。ThreadConfig结构体定义如下c typedef struct { CommAbiHeader header; uint16_t notifyNumPerThread; uint8_t reserved[14]; } ThreadConfig;其中notifyNumPerThread表示每个通信线程中的同步资源Notify数量取值范围0~65535。一个通信域内所有线程的同步资源总量不超过65536个。threads输出返回的通信线程句柄。需传入threadNum大小的ThreadHandle类型数组。ThreadHandle类型的定义可参见ThreadHandle。返回值HcclResult接口返回值说明如下返回值描述HCCL_SUCCESS成功获取通信线程资源。HCCL_E_PTR传入的comm、threads或config为空指针。HCCL_E_PARA参数错误可能原因type无效、engine无效、threadNum为0、config未使用ThreadConfigInit初始化、engine不支持CPU_TS/AICPU_TS/AIV/CCU。HCCL_E_INTERNAL内部错误。约束说明config数组必须使用ThreadConfigInit函数进行初始化否则接口返回参数错误。返回的通信线程与同步资源由库内管理调用者严禁释放。当前各产品形态支持的CommEngine范围Ascend 950PR/Ascend 950DTCOMM_ENGINE_CPUCOMM_ENGINE_AICPUAtlas A3 训练系列产品/Atlas A3 推理系列产品COMM_ENGINE_CPUCOMM_ENGINE_AICPUAtlas A2 训练系列产品/Atlas A2 推理系列产品COMM_ENGINE_CPUCOMM_ENGINE_AICPU该接口不支持COMM_ENGINE_CPU_TS和COMM_ENGINE_AICPU_TS通信引擎如需TS类型线程请使用COMM_ENGINE_CPU或COMM_ENGINE_AICPU引擎配合THREAD_TYPE_TS线程类型。该接口不支持COMM_ENGINE_AIV和COMM_ENGINE_CCU两种通信引擎。调用示例创建线程资源示例如下HcclComm comm; CommEngine engine COMM_ENGINE_AICPU; uint32_t threadNum 5; ThreadConfig configs[5]; ThreadConfigInit(configs, threadNum); for (uint32_t i 0; i threadNum; i) { configs[i].notifyNumPerThread 2; } ThreadHandle threads[5]; HcclThreadAcquireWithConfig(comm, engine, threadNum, THREAD_TYPE_TS, configs, threads);不同线程配置不同Notify数量的示例如下HcclComm comm; CommEngine engine COMM_ENGINE_CPU; uint32_t threadNum 3; ThreadConfig configs[3]; ThreadConfigInit(configs, threadNum); configs[0].notifyNumPerThread 2; configs[1].notifyNumPerThread 4; configs[2].notifyNumPerThread 1; ThreadHandle threads[3]; HcclThreadAcquireWithConfig(comm, engine, threadNum, THREAD_TYPE_TS, configs, threads);【免费下载链接】hcommHCOMMHuawei Communication是HCCL的通信基础库提供通信域以及通信资源的管理能力。项目地址: https://gitcode.com/cann/hcomm创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考