LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/communicator - hccl_communicator.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 74.3 % 284 211
Test Date: 2026-07-28 12:11:00 Functions: 77.0 % 87 67

            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              : #include "hccl_communicator.h"
      11              : 
      12              : #include <memory>
      13              : #include <utility>
      14              : #include "communicator_impl.h"
      15              : #include "snap_shot_parse.h"
      16              : #include "task_abort_handler.h"
      17              : #include "ccu_dev_mgr.h"
      18              : #include "communicator_callback.h"
      19              : #include "comm_manager.h"
      20              : #include "orion_adapter_rts.h"
      21              : 
      22              : namespace Hccl {
      23              : 
      24          250 : HcclCommunicator::HcclCommunicator(const CommParams &commParams) : commParams(std::move(commParams))
      25              : {
      26          250 :     pimpl                    = std::make_unique<CommunicatorImpl>();
      27          250 :     config.hcclBufferSize    = 0;
      28          250 :     config.hcclDeterministic = 0;
      29          250 :     RegistTaskAbortHandler();
      30          250 : }
      31              : 
      32           20 : HcclCommunicator::HcclCommunicator(const CommParams &commParams, const HcclCommConfig *config)
      33           20 :     : commParams(std::move(commParams)), config(*config)
      34              : {
      35           20 :     pimpl = std::make_unique<CommunicatorImpl>();
      36           20 :     RegistTaskAbortHandler();
      37           20 : }
      38              : 
      39          270 : HcclCommunicator::~HcclCommunicator()
      40              : {
      41          270 :     DECTOR_TRY_CATCH("HcclCommunicator", {
      42              :         UnRegistTaskAbortHandler();
      43              :         u32 devLogicId = GetDeviceLogicId();
      44              :         pimpl = nullptr;
      45              :         CommManager::GetInstance(static_cast<s32>(devLogicId)).DeinitCcuDriver();
      46              :     });
      47          270 : }
      48              : 
      49           10 : HcclResult HcclCommunicator::Init(const std::string &ranktableM)
      50              : {
      51           10 :     return pimpl->Init(commParams, ranktableM, config);
      52              : }
      53              : 
      54            0 : HcclResult HcclCommunicator::Init(const RankTableInfo &ranktable)
      55              : {
      56            0 :     return pimpl->Init(commParams, ranktable, config);
      57              : }
      58              : 
      59            3 : HcclResult HcclCommunicator::CreateSubComm(const CommParams &subCommParams, const std::vector<u32> &rankIds,
      60              :                                            std::shared_ptr<HcclCommunicator> &subHcclComm)
      61              : {
      62            3 :     subHcclComm = std::make_shared<Hccl::HcclCommunicator>(subCommParams);
      63            3 :     return pimpl->CreateSubComm(subCommParams, rankIds, subHcclComm->GetCommImpl());
      64              : }
      65              : 
      66            3 : HcclResult HcclCommunicator::CreateSubComm(const CommParams &subCommParams, const std::vector<u32> &rankIds,
      67              :                                            std::shared_ptr<HcclCommunicator> &subHcclComm, HcclCommConfig &subConfig)
      68              : {
      69            3 :     subHcclComm = std::make_shared<Hccl::HcclCommunicator>(subCommParams);
      70            3 :     config.hcclBufferSize    = 0;
      71            3 :     config.hcclDeterministic = 0;
      72            3 :     return pimpl->CreateSubComm(subCommParams, rankIds, subHcclComm->GetCommImpl(), subConfig);
      73              : }
      74              : 
      75           14 : CommunicatorImpl *HcclCommunicator::GetCommImpl()
      76              : {
      77           14 :     return pimpl.get();
      78              : }
      79              : 
      80            0 : void HcclCommunicator::DeInit() const
      81              : {
      82            0 : }
      83              : 
      84            5 : HcclResult HcclCommunicator::LoadOpbasedCollOp(const CollOpParams &opParams, void *stream)
      85              : {
      86            5 :     return pimpl->LoadOpbasedCollOp(opParams, stream);
      87              : }
      88              : 
      89            0 : HcclResult HcclCommunicator::AllocCollOpResource(const CollOpParams &opParams, void **addr)
      90              : {
      91            0 :     return pimpl->AllocCollOpResource(opParams, addr);
      92              : }
      93              : 
      94            2 : HcclResult HcclCommunicator::CalcCollOffloadOpRes(const OpType opType, u64 dataSize, HcclDataType dataType, CollOffloadOpResReq &resReq)
      95              : {
      96            2 :     std::lock_guard<std::mutex> lock(serialMutex);
      97            2 :     auto                        ret = pimpl->CalcCollOffloadOpRes(opType, dataSize, dataType, resReq);
      98            2 :     return ret;
      99            2 : }
     100              : 
     101            3 : HcclResult HcclCommunicator::SetCollOffloadSlaveStreams(const std::string &opTag, std::vector<void *> slaveStreams)
     102              : {
     103            3 :     std::lock_guard<std::mutex> lock(serialMutex);
     104            3 :     auto                        ret = pimpl->SetCollOffloadSlaveStreams(opTag, slaveStreams);
     105            3 :     return ret;
     106            3 : }
     107              : 
     108            3 : HcclResult HcclCommunicator::SetCollOffloadScratchBuf(const std::string &opTag, void *scratchMemPtr,
     109              :                                                       u64 requiredScratchMemSize)
     110              : {
     111            3 :     std::lock_guard<std::mutex> lock(serialMutex);
     112            3 :     auto                        ret = pimpl->SetCollOffloadScratchBuf(opTag, scratchMemPtr, requiredScratchMemSize);
     113            3 :     return ret;
     114            3 : }
     115              : 
     116            1 : HcclResult HcclCommunicator::LoadOffloadCollOp(std::string &opTag, const CollOpParams &opParams, void *stream)
     117              : {
     118            1 :     std::lock_guard<std::mutex> lock(serialMutex);
     119            1 :     auto                        ret = pimpl->LoadOffloadCollOp(opTag, opParams, stream);
     120            1 :     return ret;
     121            1 : }
     122              : 
     123           78 : HcclResult HcclCommunicator::GetRankSize(uint32_t *rankSize)
     124              : {
     125           78 :     if (rankSize == nullptr) {
     126            0 :         HCCL_ERROR("Parameter rank size is nullptr.");
     127            0 :         return HcclResult::HCCL_E_PARA;
     128              :     }
     129              : 
     130           78 :     *rankSize = pimpl->GetRankSize();
     131              : 
     132           78 :     return HcclResult::HCCL_SUCCESS;
     133              : }
     134              : 
     135            0 : HcclResult HcclCommunicator::HcclGetCclBuffer(uintptr_t &cclBufferAddr, size_t &cclBufferSize, HcclMemType &cclBufferMemType)
     136              : {
     137            0 :     auto commImpl = GetCommImpl();
     138            0 :     if (UNLIKELY(commImpl == nullptr)) {
     139            0 :         HCCL_ERROR("[HcclCommunicator][%s] commImpl is null.", __func__);
     140            0 :         return HcclResult::HCCL_E_PTR;
     141              :     }
     142              : 
     143              :     // GetCclBuffer接口不合理,应返回裸指针
     144              :     // 本次性能整改暂时最小化修改,避免重复分配内存和拷贝
     145            0 :     const auto &hcclBuffer = commImpl->GetCclBuffer();
     146            0 :     if (UNLIKELY(hcclBuffer == nullptr)) {
     147            0 :         cclBufferSize = 0;
     148            0 :         cclBufferAddr = 0;
     149            0 :         cclBufferMemType = HcclMemType::HCCL_MEM_TYPE_DEVICE;
     150            0 :         return HcclResult::HCCL_SUCCESS;
     151              :     }
     152              : 
     153            0 :     cclBufferSize = commImpl->GetBufferSize();
     154            0 :     cclBufferAddr = hcclBuffer->GetAddr();
     155            0 :     cclBufferMemType = hcclBuffer->GetMemType();
     156            0 :     return HCCL_SUCCESS;
     157              : }
     158              : 
     159              : // 后续会整改把cclbuffer等资源的申请放到collcomm中
     160            3 : HcclResult HcclCommunicator::GetCclBufferSharedPtr(std::shared_ptr<DevBuffer> &cclBuffer)
     161              : {
     162            3 :     auto commImpl = GetCommImpl();
     163            3 :     if (commImpl == nullptr) {
     164            3 :         HCCL_ERROR("[HcclCommunicator][%s] commImpl is null.", __func__);
     165            1 :         return HcclResult::HCCL_E_PTR;
     166              :     }
     167            2 :     cclBuffer = commImpl->GetCclBuffer();
     168            2 :     if (cclBuffer == nullptr) {
     169            3 :         HCCL_WARNING(
     170              :             "[HcclCommunicator][%s] cclBuffer is nullptr, ranksize is %u.", __func__, commImpl->GetRankSize());
     171              :     }
     172            2 :     return HcclResult::HCCL_SUCCESS;
     173              : }
     174              : 
     175           65 : HcclResult HcclCommunicator::GetRankId(uint32_t &rankId)
     176              : {
     177           65 :     rankId = pimpl->GetMyRank();
     178           65 :     return HcclResult::HCCL_SUCCESS;
     179              : }
     180              : 
     181            1 : HcclResult HcclCommunicator::AllocCommResource(void *mc2Tiling, void **commContext)
     182              : {
     183            1 :     std::lock_guard<std::mutex> lock(serialMutex);
     184            1 :     auto                        ret = pimpl->AllocCommResource(mc2Tiling, commContext);
     185            1 :     return ret;
     186            1 : }
     187              : 
     188            0 : HcclResult HcclCommunicator::GetCcuTaskInfo(void *tilingData, void *ccuTaskGroup)
     189              : {
     190            0 :     return pimpl->GetCcuTaskInfo(tilingData, ccuTaskGroup);
     191              : }
     192              : 
     193            0 : u32 HcclCommunicator::GetCcuMc2ServerNum()
     194              : {
     195            0 :     return pimpl->GetCcuMc2ServerNum();
     196              : }
     197              : 
     198          162 : const std::string &HcclCommunicator::GetId() const
     199              : {
     200          162 :     return pimpl->GetId();
     201              : }
     202              : 
     203            2 : HcclResult HcclCommunicator::Suspend()
     204              : {
     205            2 :     std::lock_guard<std::mutex> lock(serialMutex);
     206            2 :     auto                        ret = pimpl->Suspend();
     207            2 :     return ret;
     208            2 : }
     209              : 
     210            1 : HcclResult HcclCommunicator::Clean()
     211              : {
     212            1 :     std::lock_guard<std::mutex> lock(serialMutex);
     213            1 :     auto                        ret = pimpl->Clean();
     214            1 :     return ret;
     215            1 : }
     216              : 
     217            4 : HcclResult HcclCommunicator::Resume()
     218              : {
     219            4 :     std::lock_guard<std::mutex> lock(serialMutex);
     220            4 :     auto                        ret = pimpl->Resume();
     221            4 :     return ret;
     222            4 : }
     223              : 
     224            6 : bool HcclCommunicator::IsWorldGroup() const
     225              : {
     226            6 :     return pimpl->IsWorldGroup();
     227              : }
     228              : 
     229            0 : HcclResult HcclCcuTaskKillPreProcess(u32 deviceLogicId)
     230              : {
     231              :     // 有没有使能ccu都尝试执行
     232            0 :     return CcuSetTaskKill(deviceLogicId);
     233              : }
     234              : 
     235            0 : HcclResult HcclCcuTaskKillPostProcess(u32 deviceLogicId)
     236              : {
     237            0 :     return CcuSetTaskKillDone(deviceLogicId);
     238              : }
     239              : 
     240            2 : HcclResult HcclCcuResumePfeTableProcess(u32 deviceLogicId)
     241              : {
     242              :     // 待修改
     243            2 :     return HcclResult::HCCL_SUCCESS;
     244              : }
     245              : 
     246            5 : HcclResult HcclCommunicator::GetSnapShotDynamicBuf(void *buf)
     247              : {
     248            5 :     std::lock_guard<std::mutex> lock(serialMutex);
     249            5 :     CHK_RET(pimpl->GetSnapShotDynamicBuf(*(static_cast<BinaryStream *>(buf))));
     250            5 :     return HcclResult::HCCL_SUCCESS;
     251            5 : }
     252              : 
     253            1 : HcclResult HcclCommunicator::RecoverComm(void *snapShotComm, u32 step, const char *changeInfo)
     254              : {
     255            1 :     std::lock_guard<std::mutex> lock(serialMutex);
     256            2 :     return pimpl->RecoverComm(*(static_cast<SnapShotComm *>(snapShotComm)), step, changeInfo);
     257            1 : }
     258              : 
     259            1 : HcclResult HcclCommunicator::RecoverSubComm(const void *snapShotSubComm, std::shared_ptr<HcclCommunicator> &subComm,
     260              :                                             u32 step)
     261              : {
     262            1 :     const SnapShotSubComm      *snapShotSubCommTemp = static_cast<const SnapShotSubComm *>(snapShotSubComm);
     263            1 :     std::lock_guard<std::mutex> lock(serialMutex);
     264            1 :     subComm = std::make_shared<Hccl::HcclCommunicator>(snapShotSubCommTemp->commParams);
     265            1 :     subComm->RegisterAcceStateCallBack(CommunicatorCallback());
     266            2 :     return pimpl->RecoverSubComm(*snapShotSubCommTemp, subComm->GetCommImpl(), step);
     267            1 : }
     268              : 
     269            5 : void *HcclCommunicator::GetStaticBinaryInfo()
     270              : {
     271            5 :     std::lock_guard<std::mutex> lock(serialMutex);
     272           10 :     return static_cast<void *>(&pimpl->GetStaticBinaryInfo());
     273            5 : }
     274              : 
     275            1 : bool HcclCommunicator::IsCommReady()
     276              : {
     277            1 :     return pimpl->IsCommReady();
     278              : }
     279              : 
     280          269 : void HcclCommunicator::RegistTaskAbortHandler()
     281              : {
     282          269 :     TaskAbortHandler::GetInstance().Register(this);
     283          269 : }
     284              : 
     285          269 : void HcclCommunicator::UnRegistTaskAbortHandler()
     286              : {
     287          269 :     TaskAbortHandler::GetInstance().UnRegister(this);
     288          269 : }
     289              : 
     290            7 : HcclResult HcclCommunicator::GetOneSidedService(HcclOneSidedService **oneSidedService)
     291              : {
     292           21 :     HCCL_INFO("HcclCommunicator::GetOneSidedService begin");
     293            7 :     CHK_RET(pimpl->GetOneSidedService(oneSidedService));
     294           21 :     HCCL_INFO("HcclCommunicator::GetOneSidedService end");
     295            7 :     return HCCL_SUCCESS;
     296              : }
     297              : 
     298            0 : u32 HcclCommunicator::GetUsedChannelCount(u32 dieId)
     299              : {
     300            0 :     return pimpl->GetUsedChannelCount(dieId);
     301              : }
     302              : 
     303           13 : void HcclCommunicator::RegisterPrintChannelInfoCallback(std::function<void()> callback)
     304              : {
     305           13 :     pimpl->RegisterPrintChannelInfoCallback(callback);
     306           13 : }
     307              : 
     308            5 : CommStatus HcclCommunicator::GetCommStatus() const
     309              : {
     310            5 :     return pimpl->GetCommStatus();
     311              : }
     312              : 
     313            5 : HcclResult HcclCommunicator::CreateCommCclBuf()
     314              : {
     315           15 :     HCCL_INFO("HcclCommunicator::CreateCommCclBuf start");
     316            5 :     return pimpl->CreateCommCclBuf();
     317              : }
     318              :  
     319            1 : HcclResult HcclCommunicator::GetInCclBuf(void* &commInputPtr, u64 &commInputSize)
     320              : {
     321            1 :     return pimpl->GetInCclBuf(commInputPtr, commInputSize);
     322              : }
     323              :  
     324            1 : HcclResult HcclCommunicator::GetOutCclBuf(void* &commOutputPtr, u64 &commOutputSize)
     325              : {
     326            1 :     return pimpl->GetOutCclBuf(commOutputPtr, commOutputSize);
     327              : }
     328              : 
     329            1 : HcclResult HcclCommunicator::GetLocalCclBuffer(void **addr, uint64_t *size)
     330              : {
     331            1 :     return pimpl->GetLocalCclBuffer(addr, size);
     332              : }
     333              :  
     334            5 : HcclResult HcclCommunicator::GetDevMemWorkSpace(const std::string &memTag, uint64_t *size, void **addr, bool *newCreated)
     335              : {
     336            5 :     return pimpl->GetDevMemWorkSpace(memTag, size, addr, newCreated);
     337              : }
     338              :  
     339            0 : HcclResult HcclCommunicator::GetAicpuOpStreamNotify(rtStream_t *opStream, u8 aicpuNotifyNum, void** aicpuNotify) 
     340              : {
     341            0 :     return pimpl->GetAicpuOpStreamNotify(opStream, aicpuNotifyNum, aicpuNotify);
     342              : }
     343              :  
     344            1 : HcclResult HcclCommunicator::GetIndirectInputCclBuf(void* &commIndirectInputPtr, u64 &commIndirectInputSize)
     345              : {
     346            1 :     return pimpl->GetIndirectInCclBuf(commIndirectInputPtr, commIndirectInputSize);
     347              : }
     348              : 
     349            1 : HcclResult HcclCommunicator::GetIndirectOutputCclBuf(void* &commIndirectOutputPtr, u64 &commIndirectOutputSize)
     350              : {
     351            1 :     return pimpl->GetIndirectOutCclBuf(commIndirectOutputPtr, commIndirectOutputSize);
     352              : }
     353              : 
     354           14 : HcclResult HcclCommunicator::SetAccelerator(HcclAccelerator hcclAccelerator, bool isCcuMsAvailable)
     355              : {
     356           14 :     CHK_RET(pimpl->SetAccelerator(hcclAccelerator, isCcuMsAvailable));
     357           14 :     return HcclResult::HCCL_SUCCESS;
     358              : }
     359              : 
     360            0 : HcclResult HcclCommunicator::SetAccelerator(int32_t accelerator, bool isCcuMsAvailable)
     361              : {
     362            0 :     if (accelerator < static_cast<int32_t>(HcclAccelerator::DEFAULT) || accelerator > static_cast<int32_t>(HcclAccelerator::AICPU)) {
     363            0 :         HCCL_ERROR("[HcclCommunicator][SetAccelerator] Invalid accelerator value [%d], valid range is [0,7]", accelerator);
     364            0 :         return HCCL_E_NOT_SUPPORT;
     365              :     }
     366            0 :     HcclAccelerator hcclAccelerator = static_cast<HcclAccelerator::Value>(accelerator);
     367            0 :     CHK_RET(SetAccelerator(hcclAccelerator, isCcuMsAvailable));
     368            0 :     return HcclResult::HCCL_SUCCESS;
     369              : }
     370              : 
     371            0 : HcclResult HcclCommunicator::GetAccelerator(int32_t* accelerator) const
     372              : {
     373            0 :     CHK_RET(pimpl->GetAccelerator(accelerator));
     374            0 :     return HcclResult::HCCL_SUCCESS;
     375              : }
     376              : 
     377            1 : bool HcclCommunicator::IsUsingCcuMs() const
     378              : {
     379            1 :     return pimpl->IsCommUsingCcuMs(); // 通信域粒度
     380              : }
     381              : 
     382            1 : bool HcclCommunicator::IsUsingCcuSched() const
     383              : {
     384            1 :     return pimpl->IsCommUsingCcuSched(); // 通信域粒度
     385              : }
     386              : 
     387           17 : void HcclCommunicator::RegisterAcceStateCallBack(std::function<HcclResult(const std::string &commId, bool isUsingCcuMs, bool isUsingCcuSched)> callback)
     388              : {
     389           17 :     pimpl->RegisterAcceStateCallBack(callback);
     390           17 : }
     391              : 
     392            1 : HcclResult HcclCommunicator::CalcTaskNum(OpType opType, DataType dataType, u64 count, u32 &taskNum)
     393              : {
     394            3 :     HCCL_INFO("HcclCommunicator::CalcTaskNum begin");
     395            1 :     return pimpl->CalcTaskNum(opType, dataType, count, taskNum);
     396              : }
     397              : 
     398            2 : HcclResult HcclCommunicator::GetTopoDesc(HcclTopoDescs *topoDescs, uint32_t topoSize)
     399              : {
     400            2 :     return pimpl->GetTopoDesc(topoDescs, topoSize);
     401              : }
     402              : 
     403            0 : HcclResult HcclCommunicator::GetDevType(DevType &devType)
     404              : {
     405            0 :     devType = pimpl->GetDevType();
     406            0 :     HCCL_INFO("HcclCommunicator::GetDevTyp, devtype is %s", devType.Describe().c_str());
     407            0 :     return HcclResult::HCCL_SUCCESS;
     408              : }
     409              : 
     410            1 : HcclResult HcclCommunicator::SetGlobalWorkSpace() const
     411              : {
     412            3 :     HCCL_WARNING("set global work space not support at A5");
     413            1 :     return HCCL_SUCCESS;
     414              : }
     415              : 
     416           57 : HcclResult HcclCommunicator::ExecAlgSelect(const CollOpParams &opParams, int32_t aivCoreLimit, bool &ifAiv, std::string &algName)
     417              : {
     418           57 :     return pimpl->HcomSelectAlg(opParams, aivCoreLimit, ifAiv, algName);
     419              : }
     420              : 
     421            1 : HcclResult HcclCommunicator::GetRankGraphV2(void *&rankGraph)
     422              : {
     423            1 :     CHK_SMART_PTR_NULL(pimpl);
     424            1 :     shared_ptr<RankGraph> rankGraphShPtr = pimpl->GetRankGraph();
     425            1 :     CHK_SMART_PTR_NULL(rankGraphShPtr);
     426            1 :     rankGraph = static_cast<void *>(rankGraphShPtr.get());
     427            1 :     return HCCL_SUCCESS;
     428            1 : }
     429              : 
     430            2 : HcclResult HcclCommunicator::CreateBarrierMemory(void *&sendBuf, void *&recvBuf, uint64_t count)
     431              : {
     432            2 :     return pimpl->CreateBarrierMemory(sendBuf, recvBuf, count);
     433              : }
     434              : 
     435            1 : HcclResult HcclCommunicator::SetAivClearEnable(bool aivClearEnable)
     436              : {
     437            1 :     pimpl->SetAivClearEnable(aivClearEnable);
     438            1 :     return HCCL_SUCCESS;
     439              : }
     440              : 
     441            1 : HcclResult HcclCommunicator::SetAivCoreLimit(u32 newAivCoreLimit)
     442              : {
     443            1 :     pimpl->SetAivCoreLimit(newAivCoreLimit);
     444            1 :     return HCCL_SUCCESS;
     445              : }
     446              : 
     447            0 : HcclResult HcclCommunicator::GetNetLayers(uint32_t **netLayers, uint32_t *netLayerNum)
     448              : {
     449            0 :     return pimpl->GetNetLayers(netLayers, netLayerNum);
     450              : }
     451              :  
     452            0 : HcclResult HcclCommunicator::GetInstSizeByNetLayer(uint32_t netLayer, uint32_t *rankNum)
     453              : {
     454            0 :     return pimpl->GetInstSizeByNetLayer(netLayer, rankNum);
     455              : }
     456              : 
     457            0 : HcclResult HcclCommunicator::GetConfigInCCLbufferSize(uint64_t *cclBufSize)
     458              : {
     459            0 :     *cclBufSize = static_cast<uint64_t>(pimpl->GetBufferSize());
     460            0 :     return HCCL_SUCCESS;
     461              : }
     462            0 : HcclResult HcclCommunicator::GetKFCWorkSpace(const char *memTag, uint64_t *size, void **addr, bool *newCreated)
     463              : {
     464            0 :     HCCL_INFO("HcclCommunicator::GetKFCWorkSpace start");
     465            0 :     CHK_RET(pimpl->CreateWorkspaceBuf(memTag, size, newCreated));
     466            0 :     shared_ptr<DevBuffer> buff = pimpl->GetKFCWorkSpace(memTag);
     467            0 :     *addr = reinterpret_cast<void*>(buff.get()->GetAddr());
     468            0 :     if (*size != static_cast<uint64_t>(buff.get()->GetSize())) {
     469            0 :         HCCL_ERROR("HcclCommunicator::GetKFCWorkSpace, The size of mem is non-consistent. [%u->%u]", *size, buff.get()->GetSize());
     470            0 :         return HCCL_E_PARA;
     471              :     }
     472            0 :     return HcclResult::HCCL_SUCCESS;
     473            0 : }
     474              : 
     475            2 : HcclResult HcclCommunicator::GetInstRanksByNetLayer(uint32_t netLayer, uint32_t **ranks, uint32_t *rankNum)
     476              : {
     477            2 :     return pimpl->GetInstRanksByNetLayer(netLayer, ranks, rankNum);
     478              : }
     479              : 
     480            2 : HcclResult HcclCommunicator::GetInstTopoTypeByNetLayer(uint32_t netLayer, uint32_t *topoType)
     481              : {
     482            2 :     return pimpl->GetInstTopoTypeByNetLayer(netLayer, topoType);
     483              : }
     484              : 
     485            4 : HcclResult HcclCommunicator::GetInstSizeListByNetLayer(uint32_t netLayer, uint32_t **instSizeList, uint32_t *listSize)
     486              : {
     487            4 :     return pimpl->GetInstSizeListByNetLayer(netLayer, instSizeList, listSize);
     488              : }
     489              : 
     490            2 : HcclResult HcclCommunicator::GetLinks(uint32_t netLayer, uint32_t srcRank, uint32_t dstRank, CommLink **linkList,
     491              :                                       uint32_t *listSize)
     492              : {
     493            2 :     return pimpl->GetLinks(netLayer, srcRank, dstRank, linkList, listSize);
     494              : }
     495              : 
     496            2 : HcclResult HcclCommunicator::GetTopoInstsByLayer(uint32_t netLayer, uint32_t **topoInsts, uint32_t *topoInstNum)
     497              : {
     498            2 :     return pimpl->GetTopoInstsByLayer(netLayer, topoInsts, topoInstNum);
     499              : }
     500              : 
     501            2 : HcclResult HcclCommunicator::GetTopoType(uint32_t netLayer, uint32_t topoInstId, CommTopo *topoType)
     502              : {
     503            2 :     return pimpl->GetTopoType(netLayer, topoInstId, topoType);
     504              : }
     505              : 
     506            2 : HcclResult HcclCommunicator::GetRanksByTopoInst(uint32_t netLayer, uint32_t topoInstId, uint32_t **ranks,
     507              :                                                 uint32_t *rankNum)
     508              : {
     509            2 :     return pimpl->GetRanksByTopoInst(netLayer, topoInstId, ranks, rankNum);
     510              : }
     511              : 
     512            1 : HcclResult HcclCommunicator::CalcNumBlocks(const CollOpParams &opParams, int32_t aivCoreLimit,
     513              :         std::string &algName, u32 &numBlocks)
     514              : {
     515            1 :     return pimpl->CalcNumBlocks(opParams, aivCoreLimit, algName, numBlocks);
     516              : }
     517              : 
     518            1 : HcclResult HcclCommunicator::GetAlgExecParam(const CollOpParams &opParams, bool clearEnable, void *&commContext, u64 &len,
     519              :                                u32 aivCoreLimit)
     520              : {
     521            1 :     return pimpl->GetAlgExecParam(opParams, clearEnable, commContext, len, aivCoreLimit);
     522              : }
     523              : 
     524            1 : HcclResult HcclCommunicator::ClearOpResource(const std::string &opTag)
     525              : {
     526            1 :     return pimpl->ClearOpResource(opTag);
     527              : }
     528              : 
     529          277 : u32 HcclCommunicator::GetDeviceLogicId() const
     530              : {
     531          277 :     return pimpl->GetDeviceLogicId();
     532              : }
     533              : 
     534            2 : HcclResult HcclCommunicator::GetEndpointNum(uint32_t layer, uint32_t topoInstId, uint32_t* num)
     535              : {
     536            2 :     return pimpl->GetEndpointNum(layer, topoInstId, num);
     537              : }
     538              : 
     539            3 : HcclResult HcclCommunicator::GetEndpointDesc(uint32_t layer, uint32_t topoInstId, uint32_t *descNum, EndpointDesc *endpointDesc)
     540              : {
     541            3 :     return pimpl->GetEndpointDesc(layer, topoInstId, descNum, endpointDesc);
     542              : }
     543              : 
     544            1 : HcclResult HcclCommunicator::GetEndpointInfo(uint32_t rankId, const EndpointDesc* endpointDesc, EndpointAttr endpointAttr,
     545              :                                      uint32_t infoLen, void* info)
     546              : {
     547            1 :     return pimpl->GetEndpointInfo(rankId, endpointDesc, endpointAttr, infoLen, info);
     548              : }
     549              : 
     550           28 : Trace& HcclCommunicator::GetTrace() const
     551              : {
     552           28 :     return pimpl->GetTrace();
     553              : }
     554              : 
     555            0 : u32 HcclCommunicator::GetRankInParentComm() {
     556            0 :     return pimpl->GetRankInParentComm();
     557              : }
     558              : 
     559            0 : HcclResult HcclCommunicator::Mc2AiCpuStreamAllocAndGetV2(rtStream_t *aiCpuStream)
     560              : {
     561            0 :     return pimpl->Mc2AiCpuStreamAllocAndGetV2(aiCpuStream);
     562              : }
     563              : 
     564            4 : HcclResult HcclCommunicator::GetStreamId(u32 &streamId)
     565              : {
     566            4 :     streamId = pimpl->GetDpuStreamId();
     567            4 :     return HCCL_SUCCESS;
     568              : }
     569              : 
     570            0 : HcclResult HcclCommunicator::GetRankIpPortMap(RankIpPortMapPtr& rankIpPortMap)
     571              : {
     572            0 :     CHK_RET(pimpl->GetRankIpPortMap(rankIpPortMap));
     573            0 :     return HCCL_SUCCESS;
     574              : }
     575              : 
     576              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1