LCOV - code coverage report
Current view: top level - aicpu_schedule/common - aicpusd_hccl_api.cpp (source / functions) Coverage Total Hit
Test: coverage.info Lines: 84.3 % 287 242
Test Date: 2026-08-12 11:05:02 Functions: 97.6 % 41 40

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2025 Huawei Technologies Co., Ltd.
       3              :  * This program is free software, you can redistribute it and/or modify it under the terms and conditions of
       4              :  * CANN Open Software License Agreement Version 2.0 (the "License").
       5              :  * Please refer to the License for details. You may not use this file except in compliance with the License.
       6              :  * THIS SOFTWARE IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND, EITHER EXPRESS OR IMPLIED,
       7              :  * INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT, MERCHANTABILITY, OR FITNESS FOR A PARTICULAR PURPOSE.
       8              :  * See LICENSE in the root of the software repository for the full text of the License.
       9              :  */
      10              : 
      11              : #include "aicpusd_hccl_api.h"
      12              : 
      13              : #include <algorithm>
      14              : #include <dlfcn.h>
      15              : 
      16              : #include "aicpusd_status.h"
      17              : 
      18              : namespace AicpuSchedule {
      19              : constexpr int32_t BUFF_POOL_DEVICE_ID = 0;
      20              : constexpr uint32_t BUFF_POOL_ALIGN = 4096U; // 4kb
      21              : constexpr int32_t COUNT_ONE = 1;
      22              : constexpr uint32_t INDEX_ZERO = 0U;
      23              : 
      24              : using HcclInitCsCommFunc = HcclResult (*)(const char_t*, int32_t, const char_t*, const CalcParams*, HcclComm*);
      25              : using HcclFinalizeCommFunc = HcclResult (*)(HcclComm);
      26              : using HcclGetLookupRequestFunc =
      27              :     HcclResult (*)(void*, int32_t, HcclDataType, int32_t, ServiceHandle*, HcclComm, ReqStatus*);
      28              : using HcclIsetLookupResponseFunc = HcclResult (*)(void*, int32_t, HcclDataType, ServiceHandle, HcclComm, HcclRequest*);
      29              : using HcclWaitSomeFunc = HcclResult (*)(int32_t, HcclRequest[], int32_t*, int32_t[], HcclStatus[]);
      30              : using HcclAbortSelfFunc = HcclResult (*)(HcclComm, int32_t);
      31              : using HddsServiceCancelFunc = HcclResult (*)(ServiceHandle);
      32              : using HddsCollRecvUpdateRequestFunc = HcclResult (*)(
      33              :     void*, int32_t, HcclDataType, void*, int32_t, HcclDataType, int32_t, ServiceHandle*, HcclComm, UpdateReqStatus*);
      34              : using HddsIsendUpdateResponseFunc = HcclResult (*)(ServiceHandle, HcclComm, HcclRequest*);
      35              : using HddsCollRecvLookupRequestFunc =
      36              :     HcclResult (*)(void*, int32_t, HcclDataType, int32_t, ServiceHandle*, HcclComm, LookupReqStatus*);
      37              : using HddsIsendLookupResponseFunc = HcclResult (*)(void*, int32_t, HcclDataType, ServiceHandle, HcclComm, HcclRequest*);
      38              : using HcomPrepareStartFunc = HcclResult (*)(const HcomOpDesc*, HcomRequest*);
      39              : using HcomPrepareQueryFunc = HcclResult (*)(HcomRequest, HcomStatus*);
      40              : using HcomSendByOSFunc = HcclResult (*)(void*, uint64_t, HcclDataType, uint32_t, uint32_t, const char_t*, uint64_t);
      41              : using HcomReceiveByOSFunc = HcclResult (*)(void*, uint64_t, HcclDataType, uint32_t, uint32_t, const char_t*, uint64_t);
      42              : using HcomInitByRankTableFunc = HcclResult (*)(const char_t*, uint32_t);
      43              : using HcomDestroyFunc = HcclResult (*)();
      44              : using HcomCreateGroupFunc = HcclResult (*)(const char_t*, uint32_t, uint32_t*);
      45              : using HcomDestroyGroupFunc = HcclResult (*)(const char_t*);
      46              : using HcomBroadcastByOSFunc = HcclResult (*)(void*, uint64_t, HcclDataType, uint32_t, const char*, uint64_t);
      47              : using HcomGatherByOSFunc =
      48              :     HcclResult (*)(void*, uint64_t, HcclDataType, void*, uint64_t, HcclDataType, uint32_t, const char*, uint64_t);
      49              : using HcclDestroyResouceFunc = HcclResult (*)(HcclComm, int32_t);
      50              : using HcclRegisterGlobalMemoryFunc = HcclResult (*)(void*, uint64_t);
      51              : using HcclUnregisterGlobalMemoryFunc = HcclResult (*)(void*);
      52              : using HcclPsAssociateWorkersFunc = HcclResult (*)(HcclComm, int32_t, uint32_t[], uint64_t);
      53              : using HcclCpuCommInitClusterInfoMemConfigFunc = HcclResult (*)(const char_t*, uint32_t, HcclCommConfig*);
      54              : 
      55           62 : HcclSoManager* HcclSoManager::GetInstance()
      56              : {
      57           62 :     static HcclSoManager hcclSoIns;
      58           62 :     return &hcclSoIns;
      59              : }
      60              : 
      61            1 : void HcclSoManager::LoadHccdSo()
      62              : {
      63            1 :     if (hccdSoHandle_ != nullptr) {
      64            0 :         aicpusd_info("Already loaded libhccd.so");
      65            0 :         return;
      66              :     }
      67            1 :     hccdSoHandle_ = dlopen("libhccd.so", RTLD_LAZY);
      68            1 :     if (hccdSoHandle_ == nullptr) {
      69            0 :         aicpusd_err("Failed to dlopen libhccd.so!");
      70            0 :         return;
      71              :     }
      72              :     const std::string funcName[] = {
      73              :         "HcclInitCsComm",
      74              :         "HcclFinalizeCsComm",
      75              :         "HcclGetLookupRequest",
      76              :         "HcclIsetLookupResponse",
      77              :         "HcclWaitSome",
      78              :         "HcclAbortSelf",
      79              :         "HddsServiceCancel",
      80              :         "HddsCollRecvUpdateRequest",
      81              :         "HddsIsendUpdateResponse",
      82              :         "HddsCollRecvLookupRequest",
      83              :         "HddsIsendLookupResponse",
      84              :         "HcclDestroyResouce",
      85              :         "HcclRpcRegisterGlobalMemory",
      86              :         "HcclRpcUnregisterGlobalMemory",
      87           18 :         "HcclPsAssociateWorkers"};
      88           16 :     for (auto& name : funcName) {
      89           15 :         void* func = dlsym(hccdSoHandle_, name.c_str());
      90           15 :         if (func != nullptr) {
      91           15 :             funcMap_[name] = func;
      92              :         } else {
      93            0 :             aicpusd_err("Failed to get function [%s]", name.c_str());
      94              :         }
      95              :     }
      96            1 :     aicpusd_info("Loaded libhccd.so successfully");
      97           16 : }
      98              : 
      99            1 : void HcclSoManager::LoadHcclSo()
     100              : {
     101            1 :     if (hcclSoHandle_ != nullptr) {
     102            0 :         aicpusd_info("Already loaded libhccl_heterog.so");
     103            0 :         return;
     104              :     }
     105            1 :     hcclSoHandle_ = dlopen("libhccl_heterog.so", RTLD_LAZY);
     106            1 :     if (hcclSoHandle_ == nullptr) {
     107            0 :         aicpusd_err("Failed to dlopen libhccl_heterog.so!");
     108            0 :         return;
     109              :     }
     110              :     const std::string funcName[] = {
     111              :         "HcomPrepareStart",
     112              :         "HcomPrepareQuery",
     113              :         "HcomSendByOS",
     114              :         "HcomReceiveByOS",
     115              :         "HcomInitByRankTable",
     116              :         "HcomDestroy",
     117              :         "HcomCreateGroup",
     118              :         "HcomDestroyGroup",
     119              :         "HcomGatherByOs",
     120              :         "HcomBcastByOS",
     121           14 :         "HcclCpuCommInitClusterInfoMemConfig"};
     122           12 :     for (auto& name : funcName) {
     123           11 :         void* func = dlsym(hcclSoHandle_, name.c_str());
     124           11 :         if (func != nullptr) {
     125           11 :             funcMap_[name] = func;
     126              :         } else {
     127            0 :             aicpusd_err("Failed to get function [%s]", name.c_str());
     128              :         }
     129              :     }
     130            1 :     aicpusd_info("Load libhccl_heterog.so successfully");
     131           12 : }
     132              : 
     133            1 : void HcclSoManager::LoadSo()
     134              : {
     135            1 :     LoadHccdSo();
     136            1 :     LoadHcclSo();
     137            1 : }
     138              : 
     139            5 : void HcclSoManager::UnLoadHccdSo()
     140              : {
     141            5 :     if (hccdSoHandle_ != nullptr) {
     142            1 :         (void)dlclose(hccdSoHandle_);
     143            1 :         hccdSoHandle_ = nullptr;
     144              :     }
     145            5 :     aicpusd_info("Unload libhccd.so successfully");
     146            5 : }
     147              : 
     148            5 : void HcclSoManager::UnLoadHcclSo()
     149              : {
     150            5 :     if (hcclSoHandle_ != nullptr) {
     151            1 :         (void)dlclose(hcclSoHandle_);
     152            1 :         hcclSoHandle_ = nullptr;
     153              :     }
     154            5 :     aicpusd_info("Unload libhccl.so successfully");
     155            5 : }
     156            5 : void HcclSoManager::UnloadSo()
     157              : {
     158            5 :     funcMap_.clear();
     159            5 :     UnLoadHccdSo();
     160            5 :     UnLoadHcclSo();
     161            5 : }
     162              : 
     163           57 : void* HcclSoManager::GetFunc(const std::string& name) const
     164              : {
     165           57 :     const auto it = funcMap_.find(name);
     166           57 :     if (it != funcMap_.end()) {
     167           29 :         return it->second;
     168              :     }
     169           28 :     aicpusd_err("Can't get function [%s] from hccl so", name.c_str());
     170           28 :     return nullptr;
     171              : }
     172              : 
     173            1 : HcclSoManager::~HcclSoManager() { UnloadSo(); }
     174              : 
     175            2 : int32_t MBufferPool::Init(const uint32_t blockNum, const uint32_t blockSize, const bool registerMem)
     176              : {
     177            2 :     mpAttr attr = {};
     178            2 :     attr.devid = BUFF_POOL_DEVICE_ID;
     179            2 :     attr.blkSize = blockSize;
     180            2 :     attr.blkNum = blockNum;
     181            2 :     attr.align = BUFF_POOL_ALIGN;
     182            2 :     const auto ret = halBuffCreatePool(&attr, &mp_);
     183            2 :     if (ret != RET_SUCCESS) {
     184            0 :         aicpusd_err("Fail to create pool, ret is %d", ret);
     185            0 :         return ret;
     186              :     }
     187              : 
     188            2 :     if (!registerMem) {
     189            1 :         aicpusd_info(
     190              :             "Create pool successfully without registering memory, blockSize: %u, blockNum: %u", blockSize, blockNum);
     191            1 :         return RET_SUCCESS;
     192              :     }
     193              : 
     194            1 :     MemPoolInfo poolInfo = {};
     195            1 :     uint32_t outLen = static_cast<uint32_t>(sizeof(poolInfo));
     196              :     const auto poolInfoRet =
     197            1 :         halBuffGetInfo(BUFF_GET_MEMPOOL_INFO, &mp_, static_cast<uint32_t>(sizeof(mp_)), &poolInfo, &outLen);
     198            1 :     if (poolInfoRet == static_cast<int32_t>(DRV_ERROR_NONE)) {
     199            1 :         poolAddr_ = poolInfo.blk_start;
     200            1 :         poolSize_ = poolInfo.blk_total_len;
     201            1 :         const auto res = StubHcclRegisterGlobalMemory(poolAddr_, poolSize_);
     202            1 :         if (res != HCCL_SUCCESS) {
     203            0 :             aicpusd_err("Fail to register memory, res is %d.", static_cast<int32_t>(res));
     204              :         } else {
     205            1 :             isRegister_ = true;
     206            1 :             aicpusd_info("Successfully registered memory[%lu]", poolSize_);
     207              :         }
     208              :     } else {
     209            0 :         aicpusd_err("halBuffGetInfo fail, ret is %d", poolInfoRet);
     210              :     }
     211            1 :     aicpusd_info("create pool success, blockSize: %u, blockNum: %u", blockSize, blockNum);
     212            1 :     return RET_SUCCESS;
     213              : }
     214              : 
     215            1 : void MBufferPool::UnInit()
     216              : {
     217            1 :     if (mp_ == nullptr) {
     218            1 :         aicpusd_warn("mbufferPool has not been initialized yet!");
     219            1 :         return;
     220              :     }
     221              : 
     222            0 :     if (isRegister_) {
     223            0 :         const auto res = StubHcclUnregisterGlobalMemory(poolAddr_);
     224            0 :         if (res != HCCL_SUCCESS) {
     225            0 :             aicpusd_err("Fail to unregister memory, res is %d.", static_cast<int32_t>(res));
     226              :         } else {
     227            0 :             isRegister_ = false;
     228              :         }
     229              :     }
     230              : 
     231            0 :     const auto ret = halBuffDeletePool(mp_);
     232            0 :     if (ret != RET_SUCCESS) {
     233            0 :         aicpusd_err("Fail to delete pool, ret is %d", ret);
     234            0 :         return;
     235              :     }
     236            0 :     mp_ = nullptr;
     237            0 :     aicpusd_info("delete bufferpool");
     238              : }
     239              : 
     240            1 : int32_t MBufferPool::Allocate(Mbuf** mbufPtr)
     241              : {
     242            1 :     if (mp_ == nullptr) {
     243            1 :         aicpusd_err("mbufferPool has not been initialized yet!");
     244            1 :         return RET_FAILED;
     245              :     }
     246            0 :     const auto ret = halMbufAllocByPool(mp_, mbufPtr);
     247            0 :     if (ret != RET_SUCCESS) {
     248            0 :         aicpusd_warn("unable allocate by pool, ret is %d", ret);
     249              :     } else {
     250            0 :         std::lock_guard<std::mutex> lockForMbufSet(mutexForMbufSet_);
     251            0 :         mbufsAllocated_.emplace(*mbufPtr);
     252            0 :     }
     253            0 :     return ret;
     254              : }
     255              : 
     256            0 : int32_t MBufferPool::Free(Mbuf* mbuf)
     257              : {
     258            0 :     const auto ret = halMbufFree(mbuf);
     259            0 :     if (ret != RET_SUCCESS) {
     260            0 :         aicpusd_err("Fail to free, ret is %d", ret);
     261              :     } else {
     262            0 :         std::lock_guard<std::mutex> lockForMbufSet(mutexForMbufSet_);
     263            0 :         mbufsAllocated_.erase(mbuf);
     264            0 :     }
     265            0 :     return ret;
     266              : }
     267              : 
     268            1 : int32_t MBufferPool::FreeAll()
     269              : {
     270            1 :     std::set<Mbuf*> mbufsBack = mbufsAllocated_;
     271            1 :     for (auto mbuf : mbufsBack) {
     272            0 :         auto ret = Free(mbuf);
     273            0 :         if (ret != RET_SUCCESS) {
     274            0 :             return ret;
     275              :         }
     276              :     }
     277            1 :     return RET_SUCCESS;
     278            1 : }
     279              : 
     280              : // PS侧控制面接口:类似Helper1.0的通信域创建接口。内部根据rank_table和clusterConfig中描述的PS/worker信息直接建链,
     281              : // 只建立一组通信连接,使用者需要防重入
     282            2 : HcclResult StubHcclInitCsComm(
     283              :     const char_t* rankTableM, int32_t rankId, const char_t* roleTable, const CalcParams* calcParams, HcclComm* comm)
     284              : {
     285            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcclInitCsComm");
     286            2 :     if (func == nullptr) {
     287            1 :         return HCCL_E_RESERVED;
     288              :     }
     289            1 :     return (reinterpret_cast<AicpuSchedule::HcclInitCsCommFunc>(func))(rankTableM, rankId, roleTable, calcParams, comm);
     290              : }
     291              : 
     292            2 : HcclResult StubHcclFinalizeComm(HcclComm comm)
     293              : {
     294            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcclFinalizeCsComm");
     295            2 :     if (func == nullptr) {
     296            1 :         return HCCL_E_RESERVED;
     297              :     }
     298            1 :     return (reinterpret_cast<AicpuSchedule::HcclFinalizeCommFunc>(func))(comm);
     299              : }
     300              : 
     301            2 : HcclResult StubHcclGetLookupRequest(
     302              :     void* keys, int32_t count, HcclDataType type, int32_t tag, ServiceHandle* handle, HcclComm comm, ReqStatus* status)
     303              : {
     304            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcclGetLookupRequest");
     305            2 :     if (func == nullptr) {
     306            1 :         return HCCL_E_RESERVED;
     307              :     }
     308            1 :     return (reinterpret_cast<AicpuSchedule::HcclGetLookupRequestFunc>(func))(
     309            1 :         keys, count, type, tag, handle, comm, status);
     310              : }
     311              : 
     312            2 : HcclResult StubHcclIsetLookupResponse(
     313              :     void* values, int32_t count, HcclDataType type, ServiceHandle handle, HcclComm comm, HcclRequest* request)
     314              : {
     315            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcclIsetLookupResponse");
     316            2 :     if (func == nullptr) {
     317            1 :         return HCCL_E_RESERVED;
     318              :     }
     319            1 :     return (reinterpret_cast<AicpuSchedule::HcclIsetLookupResponseFunc>(func))(
     320            1 :         values, count, type, handle, comm, request);
     321              : }
     322              : 
     323            5 : HcclResult StubHcclWaitSome(
     324              :     int32_t count, HcclRequest requestArray[], int32_t* compCount, int32_t compIndices[], HcclStatus compStatus[])
     325              : {
     326           10 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcclWaitSome");
     327            5 :     if (func == nullptr) {
     328            2 :         return HCCL_E_RESERVED;
     329              :     }
     330            3 :     return (reinterpret_cast<AicpuSchedule::HcclWaitSomeFunc>(func))(
     331            3 :         count, requestArray, compCount, compIndices, compStatus);
     332              : }
     333              : 
     334            2 : HcclResult StubHcclAbortSelf(HcclComm comm, int32_t tag)
     335              : {
     336            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcclAbortSelf");
     337            2 :     if (func == nullptr) {
     338            1 :         return HCCL_E_RESERVED;
     339              :     }
     340            1 :     return (reinterpret_cast<AicpuSchedule::HcclAbortSelfFunc>(func))(comm, tag);
     341              : }
     342              : 
     343            2 : HcclResult StubHddsServiceCancel(ServiceHandle handle)
     344              : {
     345            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HddsServiceCancel");
     346            2 :     if (func == nullptr) {
     347            1 :         return HCCL_E_RESERVED;
     348              :     }
     349            1 :     return (reinterpret_cast<AicpuSchedule::HddsServiceCancelFunc>(func))(handle);
     350              : }
     351              : 
     352            3 : int32_t SingleHcclWait(HcclRequest request)
     353              : {
     354            3 :     constexpr int32_t count = 1;
     355            3 :     HcclRequest requestArray[] = {request};
     356            3 :     int32_t compCount = 0;
     357            3 :     int32_t compIndices[] = {-1};
     358            3 :     HcclStatus status = {};
     359            3 :     HcclStatus compStatus[] = {status};
     360              : 
     361            3 :     const auto testRet = StubHcclWaitSome(count, requestArray, &compCount, compIndices, compStatus);
     362            3 :     if (testRet == HCCL_E_AGAIN) {
     363            1 :         return RET_SUCCESS;
     364              :     }
     365              : 
     366            2 :     if (testRet != HCCL_SUCCESS) {
     367            1 :         aicpusd_err("Fail to call HcclWaitSome, ret is %d", static_cast<int32_t>(testRet));
     368            1 :         return RET_FAILED;
     369              :     }
     370              : 
     371            1 :     if ((compCount != COUNT_ONE) || (compIndices[0U] != INDEX_ZERO) || (compStatus[0U].error != RET_SUCCESS)) {
     372            0 :         aicpusd_err(
     373              :             "Something returned by HcclWaitSome is illegal, compCount[%d], compIndices[%d], status_error[%d]",
     374              :             compCount, compIndices[0U], compStatus[0U].error);
     375            0 :         return RET_FAILED;
     376              :     }
     377              : 
     378            1 :     return RET_SUCCESS;
     379              : }
     380              : 
     381            2 : HcclResult StubHddsCollRecvUpdateRequest(
     382              :     void* keys, int32_t keyCount, HcclDataType keyType, void* values, int32_t valueCount, HcclDataType valueType,
     383              :     int32_t tag, ServiceHandle* handle, HcclComm comm, UpdateReqStatus* status)
     384              : {
     385            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HddsCollRecvUpdateRequest");
     386            2 :     if (func == nullptr) {
     387            1 :         return HCCL_E_RESERVED;
     388              :     }
     389            1 :     return (reinterpret_cast<AicpuSchedule::HddsCollRecvUpdateRequestFunc>(func))(
     390            1 :         keys, keyCount, keyType, values, valueCount, valueType, tag, handle, comm, status);
     391              : }
     392              : 
     393            2 : HcclResult StubHddsIsendUpdateResponse(ServiceHandle handle, HcclComm comm, HcclRequest* request)
     394              : {
     395            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HddsIsendUpdateResponse");
     396            2 :     if (func == nullptr) {
     397            1 :         return HCCL_E_RESERVED;
     398              :     }
     399            1 :     return (reinterpret_cast<AicpuSchedule::HddsIsendUpdateResponseFunc>(func))(handle, comm, request);
     400              : }
     401              : 
     402            2 : HcclResult StubHddsCollRecvLookupRequest(
     403              :     void* keys, int32_t count, HcclDataType type, int32_t tag, ServiceHandle* handle, HcclComm comm,
     404              :     LookupReqStatus* status)
     405              : {
     406            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HddsCollRecvLookupRequest");
     407            2 :     if (func == nullptr) {
     408            1 :         return HCCL_E_RESERVED;
     409              :     }
     410            1 :     return (reinterpret_cast<AicpuSchedule::HddsCollRecvLookupRequestFunc>(func))(
     411            1 :         keys, count, type, tag, handle, comm, status);
     412              : }
     413              : 
     414            2 : HcclResult StubHddsIsendLookupResponse(
     415              :     void* values, int32_t count, HcclDataType type, ServiceHandle handle, HcclComm comm, HcclRequest* request)
     416              : {
     417            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HddsIsendLookupResponse");
     418            2 :     if (func == nullptr) {
     419            1 :         return HCCL_E_RESERVED;
     420              :     }
     421            1 :     return (reinterpret_cast<AicpuSchedule::HddsIsendLookupResponseFunc>(func))(
     422            1 :         values, count, type, handle, comm, request);
     423              : }
     424              : 
     425            2 : HcclResult StubHcomPrepareStart(const HcomOpDesc* op, HcomRequest* request)
     426              : {
     427            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcomPrepareStart");
     428            2 :     if (func == nullptr) {
     429            1 :         return HCCL_E_RESERVED;
     430              :     }
     431            1 :     return (reinterpret_cast<AicpuSchedule::HcomPrepareStartFunc>(func))(op, request);
     432              : }
     433              : 
     434            2 : HcclResult StubHcomPrepareQuery(HcomRequest request, HcomStatus* status)
     435              : {
     436            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcomPrepareQuery");
     437            2 :     if (func == nullptr) {
     438            1 :         return HCCL_E_RESERVED;
     439              :     }
     440            1 :     return (reinterpret_cast<AicpuSchedule::HcomPrepareQueryFunc>(func))(request, status);
     441              : }
     442              : 
     443            2 : HcclResult StubHcomSendByOS(
     444              :     void* buf, uint64_t count, HcclDataType dataType, uint32_t peerRank, uint32_t tag, const char_t* group,
     445              :     uint64_t flag)
     446              : {
     447            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcomSendByOS");
     448            2 :     if (func == nullptr) {
     449            1 :         return HCCL_E_RESERVED;
     450              :     }
     451            1 :     return (reinterpret_cast<AicpuSchedule::HcomSendByOSFunc>(func))(buf, count, dataType, peerRank, tag, group, flag);
     452              : }
     453              : 
     454            2 : HcclResult StubHcomReceiveByOS(
     455              :     void* buf, uint64_t count, HcclDataType dataType, uint32_t peerRank, uint32_t tag, const char_t* group,
     456              :     uint64_t flag)
     457              : {
     458            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcomReceiveByOS");
     459            2 :     if (func == nullptr) {
     460            1 :         return HCCL_E_RESERVED;
     461              :     }
     462            1 :     return (reinterpret_cast<AicpuSchedule::HcomReceiveByOSFunc>(func))(
     463            1 :         buf, count, dataType, peerRank, tag, group, flag);
     464              : }
     465              : 
     466            2 : HcclResult StubHcomInitByRankTable(const char_t* rankTable, uint32_t rankId)
     467              : {
     468            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcomInitByRankTable");
     469            2 :     if (func == nullptr) {
     470            1 :         return HCCL_E_RESERVED;
     471              :     }
     472            1 :     return (reinterpret_cast<AicpuSchedule::HcomInitByRankTableFunc>(func))(rankTable, rankId);
     473              : }
     474              : 
     475            2 : HcclResult StubHcomDestroy()
     476              : {
     477            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcomDestroy");
     478            2 :     if (func == nullptr) {
     479            1 :         return HCCL_E_RESERVED;
     480              :     }
     481            1 :     return (reinterpret_cast<AicpuSchedule::HcomDestroyFunc>(func))();
     482              : }
     483              : 
     484            2 : HcclResult StubHcomCreateGroup(const char_t* group, uint32_t rankNum, uint32_t* rankIds)
     485              : {
     486            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcomCreateGroup");
     487            2 :     if (func == nullptr) {
     488            1 :         return HCCL_E_RESERVED;
     489              :     }
     490            1 :     return (reinterpret_cast<AicpuSchedule::HcomCreateGroupFunc>(func))(group, rankNum, rankIds);
     491              : }
     492              : 
     493            2 : HcclResult StubHcomDestroyGroup(const char_t* group)
     494              : {
     495            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcomDestroyGroup");
     496            2 :     if (func == nullptr) {
     497            1 :         return HCCL_E_RESERVED;
     498              :     }
     499            1 :     return (reinterpret_cast<AicpuSchedule::HcomDestroyGroupFunc>(func))(group);
     500              : }
     501              : 
     502            2 : HcclResult StubHcomBroadcastByOS(
     503              :     void* buf, uint64_t count, HcclDataType dataType, uint32_t root, const char* group, uint64_t flag)
     504              : {
     505            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcomBcastByOS");
     506            2 :     if (func == nullptr) {
     507            1 :         return HCCL_E_RESERVED;
     508              :     }
     509            1 :     return (reinterpret_cast<AicpuSchedule::HcomBroadcastByOSFunc>(func))(buf, count, dataType, root, group, flag);
     510              : }
     511              : 
     512            2 : HcclResult StubHcomGatherByOS(
     513              :     void* inputBuf, uint64_t inputCount, HcclDataType inputType, void* outputBuf, uint64_t outputCount,
     514              :     HcclDataType outputType, uint32_t root, const char* group, uint64_t flag)
     515              : {
     516            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcomGatherByOs");
     517            2 :     if (func == nullptr) {
     518            1 :         return HCCL_E_RESERVED;
     519              :     }
     520            1 :     return (reinterpret_cast<AicpuSchedule::HcomGatherByOSFunc>(func))(
     521            1 :         inputBuf, inputCount, inputType, outputBuf, outputCount, outputType, root, group, flag);
     522              : }
     523              : 
     524            2 : HcclResult StubHcclDestroyResouce(HcclComm comm, int32_t tag)
     525              : {
     526            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcclDestroyResouce");
     527            2 :     if (func == nullptr) {
     528            1 :         return HCCL_E_RESERVED;
     529              :     }
     530            1 :     return (reinterpret_cast<AicpuSchedule::HcclDestroyResouceFunc>(func))(comm, tag);
     531              : }
     532              : 
     533            3 : HcclResult StubHcclRegisterGlobalMemory(void* addr, uint64_t size)
     534              : {
     535            6 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcclRpcRegisterGlobalMemory");
     536            3 :     if (func == nullptr) {
     537            1 :         return HCCL_E_RESERVED;
     538              :     }
     539            2 :     return (reinterpret_cast<AicpuSchedule::HcclRegisterGlobalMemoryFunc>(func))(addr, size);
     540              : }
     541              : 
     542            2 : HcclResult StubHcclUnregisterGlobalMemory(void* addr)
     543              : {
     544            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcclRpcUnregisterGlobalMemory");
     545            2 :     if (func == nullptr) {
     546            1 :         return HCCL_E_RESERVED;
     547              :     }
     548            1 :     return (reinterpret_cast<AicpuSchedule::HcclUnregisterGlobalMemoryFunc>(func))(addr);
     549              : }
     550              : 
     551            2 : HcclResult StubHcclPsAssociateWorkers(HcclComm comm, int32_t tag, uint32_t workerRanks[], uint64_t workerNum)
     552              : {
     553            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcclPsAssociateWorkers");
     554            2 :     if (func == nullptr) {
     555            1 :         return HCCL_E_RESERVED;
     556              :     }
     557            1 :     return (reinterpret_cast<AicpuSchedule::HcclPsAssociateWorkersFunc>(func))(comm, tag, workerRanks, workerNum);
     558              : }
     559              : 
     560            2 : HcclResult StubHcclCpuCommInit(const char_t* rankTable, uint32_t rank, HcclCommConfig* config)
     561              : {
     562            4 :     auto func = AicpuSchedule::HcclSoManager::GetInstance()->GetFunc("HcclCpuCommInitClusterInfoMemConfig");
     563            2 :     if (func == nullptr) {
     564            1 :         return HCCL_E_RESERVED;
     565              :     }
     566            1 :     return (reinterpret_cast<AicpuSchedule::HcclCpuCommInitClusterInfoMemConfigFunc>(func))(rankTable, rank, config);
     567              : }
     568              : } // namespace AicpuSchedule
        

Generated by: LCOV version 2.0-1