LCOV - code coverage report
Current view: top level - legacy/ascend910/framework/communicator - hccl_comm.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 54.7 % 742 406
Test Date: 2026-08-18 17:47:01 Functions: 57.5 % 134 77

            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 <atomic>
      12              : #include <algorithm>
      13              : #include <arpa/inet.h>
      14              : #include <fstream>
      15              : #include <fcntl.h>
      16              : #include <unistd.h>
      17              : #include <hccl/hccl_types.h>
      18              : #include "hccl_communicator.h"
      19              : #include "hccl_comm_pub.h"
      20              : #if !defined(CCL_KERNEL_AICPU) && !defined(HCCD)
      21              : #include "coll_comm_mgr.h"
      22              : #endif
      23              : #include "coll_alg_utils.h"
      24              : #include "env_config.h"
      25              : #include "comm_configer.h"
      26              : #include "hccl_group_utils.h"
      27              : #include "hccl_dispatcher_ctx.h"
      28              : 
      29              : namespace hccl {
      30              : RankTable_t g_hcclDefaultRankTable;
      31              : 
      32          653 : hcclComm::hcclComm(u64 inCCLbufferSize, u64 outCCLbufferSize, std::string identifier, std::string cclBuffName)
      33          653 :     : barrierSendBuf(nullptr),
      34          653 :       barrierRecvBuf(nullptr),
      35          653 :       inCCLbufferSize_(inCCLbufferSize),
      36          653 :       outCCLbufferSize_(outCCLbufferSize),
      37          653 :       deviceType_(DevType::DEV_TYPE_COUNT),
      38          652 :       isFirstBarrier_(true),
      39          652 :       identifier_(identifier),
      40          653 :       cclBuffName_(cclBuffName),
      41          653 :       isHeterogComm_(false),
      42          653 :       isResetDevice_(false),
      43          653 :       isSpecialType_(false),
      44         1306 :       communicator_(nullptr)
      45              : {
      46          653 :     indirectInCCLbuffer_ = DeviceMem();
      47          653 :     indirectOutCCLbuffer_ = DeviceMem();
      48          652 :     barrierInMemory_ = DeviceMem();
      49          652 :     barrierOutMemory_ = DeviceMem();
      50          652 :     planner = std::make_shared<hcclKernelPlanner>();
      51          653 : }
      52              : 
      53         1957 : hcclComm::~hcclComm()
      54              : {
      55              : #if !defined(CCL_KERNEL_AICPU) && !defined(HCCD)
      56              :     // collComm_ 为 fullMode 时由 owner(hcclComm) 负责注销,避免在 ~CollComm 中反向依赖 CollCommMgr;
      57              :     // 此时 collComm_ 尚未析构(成员析构发生在函数体之后),指针有效
      58          653 :     if (collComm_ != nullptr && collComm_->IsFullMode()) {
      59          159 :         CollCommMgr::GetInstance().UnRegisteCollComm(collComm_.get());
      60              :     }
      61              : #endif
      62          653 :     RealeaseBarrierMemory();
      63          653 :     (void)UnRegistTaskAbortHandler();
      64          653 :     BinaryUnLoad();
      65          653 :     communicator_ = nullptr;
      66          653 : }
      67              : 
      68            0 : HcclResult hcclComm::ReleaseSubComms() const
      69              : {
      70            0 :     CHK_SMART_PTR_NULL(communicator_);
      71              : 
      72            0 :     CHK_RET(communicator_->ReleaseCommInfos());
      73              : 
      74            0 :     return HCCL_SUCCESS;
      75              : }
      76              : 
      77            0 : void hcclComm::ReleaseCommCCLbuffer() const
      78              : {
      79            0 :     if (!communicator_) {
      80            0 :         return;
      81              :     }
      82            0 :     communicator_->ReleaseCommCCLbuffer();
      83              : }
      84              : 
      85          653 : void hcclComm::RealeaseBarrierMemory()
      86              : {
      87          653 :     barrierInMemory_.free();
      88          653 :     barrierOutMemory_.free();
      89          653 : }
      90              : 
      91          236 : HcclResult hcclComm::RealeaseShareCCLbuffer()
      92              : {
      93          236 :     CHK_RET(ShareCCLbufferMgr::GetInstance().FreeShareCCLbuffer(cclBuffName_));
      94          236 :     return HCCL_SUCCESS;
      95              : }
      96              : 
      97          410 : void hcclComm::UpdateIsHaveCpuRank(const RankTable_t& rankTable)
      98              : {
      99         1583 :     for (u32 i = 0; i < rankTable.rankList.size(); i++) {
     100              :         // 同一server的标识IP 是一样的,所以可以以此推算出平均dev个数
     101         1173 :         if (rankTable.rankList[i].deviceInfo.devicePhyId == HOST_DEVICE_ID) {
     102            0 :             isHaveCpuRank_ = true;
     103              :         }
     104              :     }
     105          410 : }
     106              : 
     107            2 : void hcclComm::UpdateIsHaveCpuRank(const std::vector<RankInfo>& rankList)
     108              : {
     109            2 :     for (u32 i = 0; i < rankList.size(); i++) {
     110              :         // 同一server的标识IP 是一样的,所以可以以此推算出平均dev个数
     111            0 :         if (rankList[i].devicePhyId == HOST_DEVICE_ID) {
     112            0 :             isHaveCpuRank_ = true;
     113              :         }
     114              :     }
     115            2 : }
     116              : 
     117          410 : HcclResult hcclComm::init(HcclCommParams& params, const CommConfig& commConfig, const RankTable_t& rankTable)
     118              : {
     119          410 :     UpdateIsHaveCpuRank(rankTable);
     120          410 :     isHeterogComm_ = params.isHeterogComm;
     121              : 
     122          410 :     HCCL_INFO("hcclComm init workmode [%d]", params.commWorkMode);
     123          410 :     if (params.commWorkMode == WorkMode::HCCL_MODE_AI_CPU) {
     124            0 :         isSpecialType_ = true;
     125              :     }
     126          410 :     CHK_RET(InitImpl(params.deviceType, commConfig));
     127              : 
     128              :     /* 强行将最后一个字符置0, 确保其可以做字符串操作 */
     129          410 :     params.id.internal[HCCL_ROOT_INFO_BYTES - 1] = '\0';
     130              : 
     131              :     /* 入参判断 */
     132          410 :     if (params.rank >= params.totalRanks) {
     133            2 :         HCCL_ERROR(
     134              :             "[HcclComm][Init]errNo[0x%016llx] rank[%u] out of range[0, %u]", HCCL_ERROR_CODE(HCCL_E_PARA), params.rank,
     135              :             params.totalRanks - 1);
     136            2 :         return HCCL_E_PARA;
     137              :     }
     138          408 :     params.identifier = identifier_;
     139          408 :     params.cclBuffName = cclBuffName_;
     140              : 
     141              :     /* 设置commConfig单例 */
     142          408 :     HcclResult ret = CommConfiger::GetInstance().SetCommConfig(commConfig, identifier_);
     143          408 :     CHK_PRT_RET(
     144              :         ret != HCCL_SUCCESS,
     145              :         HCCL_ERROR("[hcclComm][init]errNo[0x%016llx] set commConfiger failed.", HCCL_ERROR_CODE(ret)), HCCL_E_PARA);
     146              : 
     147          408 :     CHK_RET(communicator_->AtomicInitSet());      /* 初始化竞争, 只允许被初始化一次 */
     148          408 :     ret = communicator_->Init(params, rankTable); /* 初始化实例, 失败则重新开放初始化竞争 */
     149          408 :     if (ret != HCCL_SUCCESS) {
     150            4 :         HCCL_ERROR("[HcclComm][Init]errNo[0x%016llx] hccl initialize failed", HCCL_ERROR_CODE(ret));
     151            4 :         communicator_->AtomicInitClear();
     152            4 :         return ret;
     153              :     }
     154          404 :     CHK_RET(ShareCCLbufferMgr::GetInstance().RecordShareCCLbuffer(cclBuffName_));
     155          404 :     if (params.totalRanks != 1) {
     156          206 :         CHK_RET(communicator_->InitCCLbuffer(inCCLbufferSize_, outCCLbufferSize_));
     157              :     }
     158              : 
     159          404 :     HCCL_USER_CRITICAL_LOG(
     160              :         "hcclCommInitInfo:commId[%s], rank[%u], totalRanks[%u], serverId[%s], deviceType[%d],"
     161              :         "logicDevId[%d], identifier[%s]",
     162              :         params.id.internal, params.rank, params.totalRanks, params.serverId.c_str(), params.deviceType,
     163              :         params.logicDevId, params.identifier.c_str());
     164              : 
     165          404 :     InitIndependentOp();
     166              : 
     167          404 :     return HCCL_SUCCESS;
     168              : }
     169              : 
     170            2 : HcclResult hcclComm::init(
     171              :     HcclCommParams& params, const CommConfig& commConfig, const std::vector<RankInfo>& rankList,
     172              :     WorldGroupInfo& groupCommonData)
     173              : {
     174            2 :     UpdateIsHaveCpuRank(rankList);
     175              :     /* 强行将最后一个字符置0, 确保其可以做字符串操作 */
     176            2 :     params.id.internal[HCCL_ROOT_INFO_BYTES - 1] = '\0';
     177              : 
     178            2 :     HCCL_USER_CRITICAL_LOG(
     179              :         "rootInfo[%s], rank[%u], totalRanks[%u], chip[%d], logicDevId[%d]", params.id.internal, params.rank,
     180              :         params.totalRanks, params.deviceType, params.logicDevId);
     181              : 
     182            2 :     HCCL_INFO("rootInfo init group workmode[%d]", params.commWorkMode);
     183            2 :     if (params.commWorkMode == WorkMode::HCCL_MODE_AI_CPU) {
     184            0 :         isSpecialType_ = true;
     185              :     }
     186            2 :     CHK_RET(InitImpl(params.deviceType, commConfig));
     187              : 
     188              :     /* 入参判断 */
     189            2 :     if (params.rank >= params.totalRanks) {
     190            1 :         HCCL_ERROR(
     191              :             "[HcclComm][Init]errNo[0x%016llx] rank[%u] out of range[0, %u]", HCCL_ERROR_CODE(HCCL_E_PARA), params.rank,
     192              :             params.totalRanks - 1);
     193            1 :         return HCCL_E_PARA;
     194              :     }
     195              : 
     196            1 :     params.identifier = identifier_;
     197              : 
     198              :     /* 设置commConfig单例 */
     199            1 :     HcclResult ret = CommConfiger::GetInstance().SetCommConfig(commConfig, identifier_);
     200            1 :     CHK_PRT_RET(
     201              :         ret != HCCL_SUCCESS,
     202              :         HCCL_ERROR("[hcclComm][init]errNo[0x%016llx] set commConfiger failed.", HCCL_ERROR_CODE(ret)), HCCL_E_PARA);
     203              : 
     204            1 :     CHK_RET(communicator_->CheckDeviceType(params.deviceType)); /* 芯片类型检查 */
     205            0 :     CHK_RET(communicator_->AtomicInitSet());                    /* 初始化竞争, 只允许被初始化一次 */
     206            0 :     ret = communicator_->Init(params, rankList, groupCommonData); /* 初始化实例, 失败则重新开放初始化竞争 */
     207            0 :     if (ret != HCCL_SUCCESS) {
     208            0 :         communicator_->AtomicInitClear();
     209            0 :         HCCL_ERROR("[HcclComm][Init]errNo[0x%016llx] hccl initialize failed", HCCL_ERROR_CODE(ret));
     210            0 :         return ret;
     211              :     }
     212            0 :     return ret;
     213              : }
     214              : 
     215          235 : HcclResult hcclComm::SetQpQosAttr(u32 trafficClass, u32 serviceLevel)
     216              : {
     217              :     // 校验config中TC的合法性
     218          235 :     if (trafficClass == HCCL_COMM_TRAFFIC_CLASS_CONFIG_NOT_SET
     219          235 :         && serviceLevel == HCCL_COMM_SERVICE_LEVEL_CONFIG_NOT_SET) {
     220          235 :         HCCL_INFO(
     221              :             "[SetQpQosAttr]The TC and SL do not use the config configuration. "
     222              :             "It will use environment variables to configure. TC[%u], SL[%u]",
     223              :             EnvConfig::GetExternalInputRdmaTrafficClass(), EnvConfig::GetExternalInputRdmaServerLevel());
     224          235 :         return HCCL_SUCCESS;
     225            0 :     } else if (
     226              :         trafficClass != HCCL_COMM_TRAFFIC_CLASS_CONFIG_NOT_SET
     227            0 :         && serviceLevel == HCCL_COMM_SERVICE_LEVEL_CONFIG_NOT_SET) {
     228            0 :         serviceLevel = EnvConfig::GetExternalInputRdmaServerLevel();
     229            0 :         HCCL_INFO("[SetQpQosAttr]The SL is not configured. It will use the environment value[%u]", serviceLevel);
     230            0 :     } else if (
     231              :         trafficClass == HCCL_COMM_TRAFFIC_CLASS_CONFIG_NOT_SET
     232            0 :         && serviceLevel != HCCL_COMM_SERVICE_LEVEL_CONFIG_NOT_SET) {
     233            0 :         trafficClass = EnvConfig::GetExternalInputRdmaTrafficClass();
     234            0 :         HCCL_INFO("[SetQpQosAttr]The TC is not configured. It will use the environment value[%u]", trafficClass);
     235              :     }
     236              : 
     237              :     // 若转换出错或者设置的RDMATrafficClass不在有效范围内,则报错
     238            0 :     if (trafficClass > EnvConfig::HCCL_RDMA_TC_MAX) {
     239            0 :         HCCL_ERROR(
     240              :             "[SetQpQosAttr]rdmaTrafficClass is invalid. except:[%u, %u], actual:[%u]", EnvConfig::HCCL_RDMA_TC_MIN,
     241              :             EnvConfig::HCCL_RDMA_TC_MAX, trafficClass);
     242            0 :         return HCCL_E_PARA;
     243              :     }
     244              :     // 若设置的RDMATrafficClass不是4的整数倍,则报错
     245            0 :     if (trafficClass % EnvConfig::HCCL_RDMA_TC_BASE != 0) {
     246            0 :         HCCL_ERROR(
     247              :             "[SetQpQosAttr]rdmaTrafficClass[%u] is not a multiple of [%u]", trafficClass, EnvConfig::HCCL_RDMA_TC_BASE);
     248            0 :         return HCCL_E_PARA;
     249              :     }
     250              : 
     251              :     // 校验config中SL是否合法
     252            0 :     if (serviceLevel > EnvConfig::HCCL_RDMA_SL_MAX) {
     253            0 :         HCCL_ERROR(
     254              :             "[SetQpQosAttr]rdmaServiceLevel is invalid. except:[%u, %u], actual:[%u]", EnvConfig::HCCL_RDMA_SL_MIN,
     255              :             EnvConfig::HCCL_RDMA_SL_MAX, serviceLevel);
     256            0 :         return HCCL_E_PARA;
     257              :     }
     258              : 
     259            0 :     HCCL_INFO("[SetQpQosAttr] rdmaTrafficClass[%u], rdmaServiceLevel[%u]", trafficClass, serviceLevel);
     260            0 :     communicator_->SetQpQosAttr(trafficClass, serviceLevel);
     261              : 
     262            0 :     return HCCL_SUCCESS;
     263              : }
     264              : 
     265            0 : HcclResult hcclComm::CreateGroup(
     266              :     const std::string& group, const u32& groupRank, const u32& userRank, const std::vector<u32>& groupRanks,
     267              :     std::shared_ptr<hcclComm>& groupComm)
     268              : {
     269              :     // 增加输出日志关键字
     270            0 :     HCCL_INFO(
     271              :         "HCCL_KEY_INFO: group[%s], groupRank[%u], userRank[%u], groupComm[%p]", group.c_str(), groupRank, userRank,
     272              :         groupComm.get());
     273              : 
     274              :     // 入参有消息校验
     275            0 :     if (group.length() == 0) {
     276            0 :         HCCL_ERROR("[Create][Group]errNo[0x%016llx] group name length is 0", HCCL_ERROR_CODE(HCCL_E_PARA));
     277            0 :         return HCCL_E_PARA;
     278              :     }
     279              : 
     280            0 :     if (groupRank >= groupRanks.size()) {
     281            0 :         HCCL_ERROR(
     282              :             "[Create][Group]errNo[0x%016llx] group rank[%u] out of range [0,%llu])", HCCL_ERROR_CODE(HCCL_E_PARA),
     283              :             groupRank, groupRanks.size() - 1);
     284            0 :         return HCCL_E_PARA;
     285              :     }
     286              : 
     287              :     HcclRootInfo id;
     288            0 :     CHK_RET(GetUniqueId(&id));
     289              : 
     290            0 :     HcclCommParams params;
     291            0 :     params.rank = groupRank;
     292            0 :     params.userRank = userRank;
     293            0 :     params.totalRanks = groupRanks.size();
     294            0 :     params.isHeterogComm = isHeterogComm_;
     295            0 :     s32 iret = snprintf_s(
     296              :         params.id.internal, HCCL_ROOT_INFO_BYTES, HCCL_ROOT_INFO_BYTES - 1, "%s%s%s", id.internal, "-", group.c_str());
     297              : 
     298            0 :     CHK_PRT_RET(
     299              :         (iret == -1),
     300              :         HCCL_ERROR("[Create][Group]errNo[0x%016llx] get group unique id failed", HCCL_ERROR_CODE(HCCL_E_INTERNAL)),
     301              :         HCCL_E_INTERNAL);
     302              : 
     303            0 :     WorldGroupInfo groupCommonData;
     304              : 
     305            0 :     CHK_RET(communicator_->GetGroupCommonData(groupCommonData));
     306            0 :     params.logicDevId = groupCommonData.deviceLogicId;
     307            0 :     params.profilingInitiated = groupCommonData.profilingInitiated;
     308            0 :     params.deviceType = deviceType_;
     309            0 :     params.hcomGroupNicInit = communicator_->GetNicInitialized();
     310            0 :     std::vector<RankInfo> rankList;
     311              : 
     312            0 :     CHK_RET(communicator_->GetGroupRanksInfo(groupRanks, rankList));
     313              : 
     314            0 :     groupComm.reset(new (std::nothrow) hccl::hcclComm(0, 0, group));
     315            0 :     CHK_SMART_PTR_NULL(groupComm);
     316            0 :     CommConfig commConfig(group);
     317            0 :     CHK_RET(groupComm->init(params, commConfig, rankList, groupCommonData));
     318              : 
     319            0 :     return HCCL_SUCCESS;
     320            0 : }
     321              : 
     322            0 : HcclResult hcclComm::DestroyGroup(const std::string& group) const
     323              : {
     324              :     /* 增加输出日志关键字 */
     325            0 :     HCCL_DEBUG("start destroy group: group[%s]", group.c_str());
     326            0 :     return HCCL_SUCCESS;
     327              : }
     328              : 
     329           80 : HcclResult hcclComm::GetAlgType(AlgType& algType, HcclCMDType opType)
     330              : {
     331              :     /* 增加输出日志关键字 */
     332           80 :     HCCL_DEBUG("algType[%s]", AlgTypeToStr(algType).c_str());
     333           80 :     return communicator_->GetAlgType(algType, opType);
     334              : }
     335              : 
     336           29 : void hcclComm::PrintSubmittedOpCnt(const std::string& tag, HcclResult ret)
     337              : {
     338           29 :     u32 index = 0;
     339           29 :     ProfilerBase::GetSubmittedOpCnt(index);
     340           29 :     HCCL_ERROR("[HcclComm][%s]errNo[0x%016llx] index[%u]", tag.c_str(), ret, index);
     341           29 : }
     342              : 
     343            2 : HcclResult hcclComm::AllGather(
     344              :     const std::string& tag, void* inputPtr, void* outputPtr, u64 inputCount, HcclDataType dataType, HcclRtStream stream,
     345              :     HcomCollOpInfo* opInfo)
     346              : {
     347              :     /* 增加输出日志关键字 */
     348            2 :     HCCL_INFO(
     349              :         "HCCL_KEY_INFO: tag[%s], count[%llu], data_type[%s]", tag.c_str(), inputCount,
     350              :         GetDataTypeEnumStr(dataType).c_str());
     351              : 
     352              :     /* * 入参检查 */
     353            2 :     CHK_PTR_NULL(inputPtr);
     354            2 :     CHK_PTR_NULL(outputPtr);
     355            2 :     CHK_PTR_NULL(stream);
     356              : 
     357            2 :     CHK_PRT_RET(
     358              :         tag.empty(),
     359              :         HCCL_ERROR("[HcclComm][AllGather]errNo[0x%016llx] AllGather tag length is 0", HCCL_ERROR_CODE(HCCL_E_PARA)),
     360              :         HCCL_E_PARA);
     361              : 
     362            2 :     CHK_RET(communicator_->CheckCount(inputCount));
     363            2 :     CHK_RET(communicator_->CheckDataType(dataType, false));
     364            2 :     HcclResult ret = communicator_->AllGather(tag, inputPtr, outputPtr, inputCount, dataType, stream, opInfo);
     365            2 :     if (ret != HCCL_SUCCESS) {
     366            1 :         PrintSubmittedOpCnt(tag, ret);
     367            1 :         return ret;
     368              :     }
     369              : 
     370            1 :     return HCCL_SUCCESS;
     371              : }
     372              : 
     373            0 : HcclResult hcclComm::AllGatherV(
     374              :     const std::string& tag, const void* sendBuf, u64 sendCount, const void* recvBuf, const void* recvCounts,
     375              :     const void* rdispls, HcclDataType dataType, HcclRtStream stream)
     376              : {
     377              :     /* 增加输出日志关键字 */
     378            0 :     HCCL_INFO(
     379              :         "HCCL_KEY_INFO: tag[%s], count[%llu], data_type[%s]", tag.c_str(), sendCount,
     380              :         GetDataTypeEnumStr(dataType).c_str());
     381              : 
     382              :     /* * 入参检查 */
     383            0 :     CHK_PTR_NULL(stream);
     384            0 :     CHK_PTR_NULL(sendBuf);
     385            0 :     CHK_PTR_NULL(recvBuf);
     386            0 :     CHK_PTR_NULL(recvCounts);
     387            0 :     CHK_PTR_NULL(rdispls);
     388              : 
     389            0 :     CHK_PRT_RET(
     390              :         tag.empty(),
     391              :         HCCL_ERROR("[HcclComm][AllGatherV]errNo[0x%016llx] AllGather tag length is 0", HCCL_ERROR_CODE(HCCL_E_PARA)),
     392              :         HCCL_E_PARA);
     393              : 
     394            0 :     CHK_RET(communicator_->CheckDataType(dataType, false));
     395            0 :     HcclResult ret = communicator_->AllGatherV(tag, sendBuf, sendCount, recvBuf, recvCounts, rdispls, dataType, stream);
     396            0 :     if (ret != HCCL_SUCCESS) {
     397            0 :         PrintSubmittedOpCnt(tag, ret);
     398            0 :         return ret;
     399              :     }
     400              : 
     401            0 :     return HCCL_SUCCESS;
     402              : }
     403              : 
     404           23 : HcclResult hcclComm::AllGatherOutPlace(
     405              :     const std::string& tag, void* inputPtr, void* outputPtr, u64 inputCount, HcclDataType dataType, HcclRtStream stream)
     406              : {
     407              :     /* 增加输出日志关键字 */
     408           23 :     HCCL_INFO(
     409              :         "HCCL_KEY_INFO: tag[%s], input_ptr[%p], output_ptr[%p], count[%llu], data_type[%s]", tag.c_str(), inputPtr,
     410              :         outputPtr, inputCount, GetDataTypeEnumStr(dataType).c_str());
     411              : 
     412              :     /* * 入参检查 */
     413           23 :     CHK_RET(communicator_->CheckDataType(dataType, false));
     414           23 :     HcclResult ret = communicator_->AllGatherOutPlace(tag, inputPtr, outputPtr, inputCount, dataType, stream);
     415           23 :     if (ret != HCCL_SUCCESS) {
     416            0 :         PrintSubmittedOpCnt(tag, ret);
     417            0 :         return ret;
     418              :     }
     419              : 
     420           23 :     return HCCL_SUCCESS;
     421              : }
     422              : 
     423           23 : HcclResult hcclComm::AllGatherVOutPlace(
     424              :     const std::string& tag, void* inputPtr, void* outputPtr, u64 inputCount, const void* outputCounts,
     425              :     const void* outputDispls, HcclDataType dataType, HcclRtStream stream)
     426              : {
     427              :     /* 增加输出日志关键字 */
     428           23 :     HCCL_INFO(
     429              :         "HCCL_KEY_INFO: tag[%s], input_ptr[%p], output_ptr[%p], counts[%llu], data_type[%d]", tag.c_str(), inputPtr,
     430              :         outputPtr, outputCounts, dataType);
     431              : 
     432              :     /* * 入参检查 */
     433           23 :     CHK_RET(communicator_->CheckDataType(dataType, false));
     434           23 :     CHK_RET(communicator_->AllGatherVOutPlace(
     435              :         tag, inputPtr, outputPtr, inputCount, outputCounts, outputDispls, dataType, stream));
     436              : 
     437           23 :     return HCCL_SUCCESS;
     438              : }
     439              : 
     440           24 : HcclResult hcclComm::AlltoAllV(
     441              :     const void* sendBuf, const void* sendCounts, const void* sdispls, HcclDataType sendType, const void* recvBuf,
     442              :     const void* recvCounts, const void* rdispls, HcclDataType recvType, rtStream_t stream, const std::string& tag)
     443              : {
     444              :     /* * 入参检查 */
     445           24 :     CHK_PTR_NULL(stream);
     446           24 :     CHK_PTR_NULL(sendCounts);
     447           24 :     CHK_PTR_NULL(sdispls);
     448           24 :     CHK_PTR_NULL(recvCounts);
     449           24 :     CHK_PTR_NULL(rdispls);
     450              : 
     451           24 :     CHK_PRT_RET(
     452              :         tag.empty(),
     453              :         HCCL_ERROR("[HcclComm][AlltoAllV]errNo[0x%016llx] AllToAllV tag length is 0", HCCL_ERROR_CODE(HCCL_E_PARA)),
     454              :         HCCL_E_PARA);
     455              : 
     456           24 :     CHK_RET(communicator_->CheckDataType(sendType, false));
     457              : 
     458           24 :     CHK_RET(communicator_->CheckDataType(recvType, false));
     459              : 
     460           24 :     HcclResult ret = communicator_->AlltoAllV(
     461              :         sendBuf, sendCounts, sdispls, sendType, recvBuf, recvCounts, rdispls, recvType, stream, tag);
     462           24 :     if (ret != HCCL_SUCCESS) {
     463            0 :         PrintSubmittedOpCnt(tag, ret);
     464            0 :         return ret;
     465              :     }
     466              : 
     467           24 :     return HCCL_SUCCESS;
     468              : }
     469              : 
     470            1 : HcclResult hcclComm::AlltoAllVOutPlace(
     471              :     const void* sendBuf, const void* sendCounts, const void* sdispls, HcclDataType sendType, const void* recvBuf,
     472              :     const void* recvCounts, const void* rdispls, HcclDataType recvType, rtStream_t stream, const std::string& tag)
     473              : {
     474              :     /* * 入参检查 */
     475            1 :     CHK_RET(communicator_->CheckDataType(sendType, false));
     476            1 :     CHK_RET(communicator_->CheckDataType(recvType, false));
     477              : 
     478            1 :     HcclResult ret = communicator_->AlltoAllVOutPlace(
     479              :         sendBuf, sendCounts, sdispls, sendType, recvBuf, recvCounts, rdispls, recvType, stream, tag);
     480            1 :     if (ret != HCCL_SUCCESS) {
     481            0 :         PrintSubmittedOpCnt(tag, ret);
     482            0 :         return ret;
     483              :     }
     484              : 
     485            1 :     return HCCL_SUCCESS;
     486              : }
     487              : 
     488            0 : HcclResult hcclComm::AlltoAllVC(
     489              :     const void* sendBuf, const void* sendCountMatrix, HcclDataType sendType, const void* recvBuf, HcclDataType recvType,
     490              :     rtStream_t stream, const std::string& tag)
     491              : {
     492              :     /* * 入参检查 */
     493            0 :     CHK_PTR_NULL(stream);
     494            0 :     CHK_PTR_NULL(sendCountMatrix);
     495              : 
     496            0 :     CHK_PRT_RET(
     497              :         tag.empty(),
     498              :         HCCL_ERROR("[HcclComm][AlltoAllVC]errNo[0x%016llx] AllToAllVC tag length is 0", HCCL_ERROR_CODE(HCCL_E_PARA)),
     499              :         HCCL_E_PARA);
     500              : 
     501            0 :     CHK_RET(communicator_->CheckDataType(sendType, false));
     502              : 
     503            0 :     CHK_RET(communicator_->CheckDataType(recvType, false));
     504              : 
     505            0 :     HcclResult ret = communicator_->AlltoAllVC(sendBuf, sendCountMatrix, sendType, recvBuf, recvType, stream, tag);
     506            0 :     if (ret != HCCL_SUCCESS) {
     507            0 :         PrintSubmittedOpCnt(tag, ret);
     508            0 :         return ret;
     509              :     }
     510              : 
     511            0 :     return HCCL_SUCCESS;
     512              : }
     513              : 
     514            0 : HcclResult hcclComm::AlltoAllVCOutPlace(
     515              :     const void* sendBuf, const void* sendCountMatrix, HcclDataType sendType, const void* recvBuf, HcclDataType recvType,
     516              :     rtStream_t stream, const std::string& tag)
     517              : {
     518              :     /* * 入参检查 */
     519            0 :     CHK_RET(communicator_->CheckDataType(sendType, false));
     520            0 :     CHK_RET(communicator_->CheckDataType(recvType, false));
     521              : 
     522              :     HcclResult ret
     523            0 :         = communicator_->AlltoAllVCOutPlace(sendBuf, sendCountMatrix, sendType, recvBuf, recvType, stream, tag);
     524            0 :     if (ret != HCCL_SUCCESS) {
     525            0 :         PrintSubmittedOpCnt(tag, ret);
     526            0 :         return ret;
     527              :     }
     528              : 
     529            0 :     return HCCL_SUCCESS;
     530              : }
     531              : 
     532           23 : HcclResult hcclComm::AlltoAll(
     533              :     const void* sendBuf, u64 sendCount, HcclDataType sendType, const void* recvBuf, u64 recvCount,
     534              :     HcclDataType recvType, rtStream_t stream, const std::string& tag)
     535              : {
     536              :     /* * 入参检查 */
     537           23 :     CHK_PTR_NULL(communicator_);
     538              : 
     539           23 :     CHK_PRT_RET(
     540              :         tag.empty(),
     541              :         HCCL_ERROR("[HcclComm][AlltoAll]errNo[0x%016llx] AllToAll tag length is 0", HCCL_ERROR_CODE(HCCL_E_PARA)),
     542              :         HCCL_E_PARA);
     543              : 
     544           23 :     CHK_RET(communicator_->CheckDataType(sendType, false));
     545              : 
     546           23 :     HcclResult ret = communicator_->AlltoAll(sendBuf, sendCount, sendType, recvBuf, recvCount, recvType, stream, tag);
     547           23 :     if (ret != HCCL_SUCCESS) {
     548            0 :         PrintSubmittedOpCnt(tag, ret);
     549            0 :         return ret;
     550              :     }
     551              : 
     552           23 :     return HCCL_SUCCESS;
     553              : }
     554              : 
     555              : HcclResult
     556            3 : hcclComm::Broadcast(const std::string& tag, void* ptr, u64 count, HcclDataType dataType, u32 root, HcclRtStream stream)
     557              : {
     558              :     /* 增加输出日志关键字 */
     559            3 :     HCCL_INFO(
     560              :         "HCCL_KEY_INFO:tag[%s], ptr[%p], count[%llu], data_type[%s], root[%u]", tag.c_str(), ptr, count,
     561              :         GetDataTypeEnumStr(dataType).c_str(), root);
     562              : 
     563              :     /* * 入参检查 */
     564            3 :     CHK_PTR_NULL(stream);
     565            3 :     CHK_PTR_NULL(ptr);
     566              : 
     567            3 :     if (tag.empty()) {
     568            0 :         HCCL_ERROR("[HcclComm][Broadcast]errNo[0x%016llx] broadcast tag length is 0", HCCL_ERROR_CODE(HCCL_E_PARA));
     569            0 :         return HCCL_E_PARA;
     570              :     }
     571              : 
     572              :     /* * 初始化检查 */
     573            3 :     CHK_SMART_PTR_NULL(communicator_);
     574            3 :     CHK_RET(communicator_->CheckCount(count));
     575            3 :     CHK_RET(communicator_->CheckDataType(dataType, false));
     576            3 :     CHK_RET(communicator_->CheckUserRank(root));
     577            3 :     HcclResult ret = communicator_->Broadcast(tag, ptr, count, dataType, root, stream);
     578            3 :     if (ret != HCCL_SUCCESS) {
     579            1 :         PrintSubmittedOpCnt(tag, ret);
     580            1 :         return ret;
     581              :     }
     582              : 
     583            2 :     return HCCL_SUCCESS;
     584              : }
     585              : 
     586           23 : HcclResult hcclComm::BroadcastOutPlace(
     587              :     const std::string& tag, void* ptr, u64 count, HcclDataType dataType, u32 root, HcclRtStream stream)
     588              : {
     589              :     /* 增加输出日志关键字 */
     590           23 :     HCCL_INFO(
     591              :         "HCCL_KEY_INFO:tag[%s], ptr[%p], count[%llu], data_type[%s], root[%u]", tag.c_str(), ptr, count,
     592              :         GetDataTypeEnumStr(dataType).c_str(), root);
     593              : 
     594              :     /* * 入参检查 */
     595           23 :     CHK_RET(communicator_->CheckDataType(dataType, false));
     596           23 :     CHK_RET(communicator_->CheckUserRank(root));
     597           23 :     HcclResult ret = communicator_->BroadcastOutPlace(tag, ptr, count, dataType, root, stream);
     598           23 :     if (ret != HCCL_SUCCESS) {
     599            0 :         PrintSubmittedOpCnt(tag, ret);
     600            0 :         return ret;
     601              :     }
     602              : 
     603           23 :     return HCCL_SUCCESS;
     604              : }
     605              : 
     606           24 : HcclResult hcclComm::ScatterOutPlace(
     607              :     const std::string& tag, void* inputPtr, void* outputPtr, u64 recvCount, HcclDataType dataType, u32 root,
     608              :     HcclRtStream stream)
     609              : {
     610              :     /* 增加输出日志关键字 */
     611           24 :     HCCL_INFO(
     612              :         "HCCL_KEY_INFO: tag[%s], input_ptr[%p], output_ptr[%p], recvCount[%llu], data_type[%s], root[%u]", tag.c_str(),
     613              :         inputPtr, outputPtr, recvCount, GetDataTypeEnumStr(dataType).c_str(), root);
     614              : 
     615           24 :     if (tag.empty()) {
     616            0 :         HCCL_ERROR("[HcclComm][Scatter]errNo[0x%016llx] scatter tag length is 0", HCCL_ERROR_CODE(HCCL_E_PARA));
     617            0 :         return HCCL_E_PARA;
     618              :     }
     619              : 
     620           24 :     CHK_RET(communicator_->CheckCount(recvCount));
     621           24 :     CHK_RET(communicator_->CheckDataType(dataType, false));
     622           24 :     CHK_RET(communicator_->CheckUserRank(root));
     623           24 :     HcclResult ret = communicator_->ScatterOutPlace(tag, inputPtr, outputPtr, recvCount, dataType, root, stream);
     624           24 :     if (ret != HCCL_SUCCESS) {
     625            0 :         PrintSubmittedOpCnt(tag, ret);
     626            0 :         return ret;
     627              :     }
     628              : 
     629           24 :     return HCCL_SUCCESS;
     630              : }
     631              : 
     632           12 : HcclResult hcclComm::ReduceScatter(
     633              :     const std::string& tag, void* inputPtr, void* outputPtr, u64 count, HcclDataType dataType, HcclReduceOp op,
     634              :     HcclRtStream stream)
     635              : {
     636              :     /* 增加输出日志关键字 */
     637           12 :     HCCL_INFO(
     638              :         "HCCL_KEY_INFO: tag[%s], input_ptr[%p], output_ptr[%p], count[%llu], data_type[%s], "
     639              :         "op[%s]",
     640              :         tag.c_str(), inputPtr, outputPtr, count, GetDataTypeEnumStr(dataType).c_str(), GetReduceOpEnumStr(op).c_str());
     641              : 
     642              :     /* * 入参检查 */
     643           19 :     CHK_PTR_NULL(stream);
     644           19 :     CHK_PTR_NULL(inputPtr);
     645           19 :     CHK_PTR_NULL(outputPtr);
     646              : 
     647           19 :     if (tag.empty()) {
     648            0 :         HCCL_ERROR(
     649              :             "[HcclComm][ReduceScatter]errNo[0x%016llx] reduceScatter tag length is"
     650              :             "0",
     651              :             HCCL_ERROR_CODE(HCCL_E_PARA));
     652            0 :         return HCCL_E_PARA;
     653              :     }
     654              : 
     655           19 :     CHK_RET(communicator_->CheckCount(count));
     656           12 :     CHK_RET(communicator_->CheckDataType(dataType, true));
     657           16 :     CHK_RET(communicator_->CheckReduceDataType(dataType, op));
     658           13 :     CHK_RET(communicator_->CheckReductionOp(op));
     659           11 :     HcclResult ret = communicator_->ReduceScatter(tag, inputPtr, outputPtr, count, dataType, op, stream);
     660           15 :     if (ret != HCCL_SUCCESS) {
     661            9 :         PrintSubmittedOpCnt(tag, ret);
     662            9 :         return ret;
     663              :     }
     664              : 
     665            6 :     return HCCL_SUCCESS;
     666              : }
     667              : 
     668           30 : HcclResult hcclComm::ReduceScatterOutPlace(
     669              :     const std::string& tag, void* inputPtr, void* outputPtr, u64 count, HcclDataType dataType, HcclReduceOp op,
     670              :     HcclRtStream stream)
     671              : {
     672              :     /* 增加输出日志关键字 */
     673           30 :     HCCL_INFO(
     674              :         "HCCL_KEY_INFO: tag[%s], input_ptr[%p], output_ptr[%p], count[%llu], data_type[%s], op[%s]", tag.c_str(),
     675              :         inputPtr, outputPtr, count, GetDataTypeEnumStr(dataType).c_str(), GetReduceOpEnumStr(op).c_str());
     676              : 
     677              :     /* * 入参检查 */
     678           35 :     CHK_RET(communicator_->CheckDataType(dataType, true));
     679           34 :     CHK_RET(communicator_->CheckReduceDataType(dataType, op));
     680           33 :     HcclResult ret = communicator_->ReduceScatterOutPlace(tag, inputPtr, outputPtr, count, dataType, op, stream);
     681           35 :     if (ret != HCCL_SUCCESS) {
     682            8 :         PrintSubmittedOpCnt(tag, ret);
     683            8 :         return ret;
     684              :     }
     685              : 
     686           27 :     return HCCL_SUCCESS;
     687              : }
     688              : 
     689            0 : HcclResult hcclComm::ReduceScatterV(
     690              :     const std::string& tag, void* inputPtr, const void* inputCounts, const void* inputDispls, void* outputPtr,
     691              :     u64 outputCount, HcclDataType dataType, HcclReduceOp op, HcclRtStream stream)
     692              : {
     693              :     /* 增加输出日志关键字 */
     694            0 :     HCCL_INFO(
     695              :         "HCCL_KEY_INFO: tag[%s], input_ptr[%p], output_ptr[%p], "
     696              :         "input_counts[%p], input_displs[%p], output_count[%llu], data_type[%s], op[%s]",
     697              :         tag.c_str(), inputPtr, outputPtr, inputCounts, inputDispls, outputCount, GetDataTypeEnumStr(dataType).c_str(),
     698              :         GetReduceOpEnumStr(op).c_str());
     699              : 
     700              :     /* * 入参检查 */
     701            0 :     CHK_PTR_NULL(stream);
     702            0 :     CHK_PTR_NULL(inputPtr);
     703            0 :     CHK_PTR_NULL(outputPtr);
     704              : 
     705            0 :     if (tag.empty()) {
     706            0 :         HCCL_ERROR(
     707              :             "[HcclComm][ReduceScatterV]errNo[0x%016llx] reduceScatterV tag length is"
     708              :             "0",
     709              :             HCCL_ERROR_CODE(HCCL_E_PARA));
     710            0 :         return HCCL_E_PARA;
     711              :     }
     712              : 
     713              :     // ReduceScatterV只支持inlinereduce,因此不支持int64类型
     714            0 :     if (dataType == HCCL_DATA_TYPE_INT64) {
     715            0 :         HCCL_ERROR(
     716              :             "[Check][DataType]errNo[0x%016llx] data type[%s] not supported.", HCCL_ERROR_CODE(HCCL_E_NOT_SUPPORT),
     717              :             GetDataTypeEnumStr(dataType).c_str());
     718            0 :         return HCCL_E_NOT_SUPPORT;
     719              :     }
     720              : 
     721            0 :     CHK_RET(communicator_->CheckDataType(dataType, true));
     722            0 :     CHK_RET(communicator_->CheckReduceDataType(dataType, op));
     723            0 :     CHK_RET(communicator_->CheckReductionOp(op));
     724            0 :     HcclResult ret = communicator_->ReduceScatterV(
     725              :         tag, inputPtr, inputCounts, inputDispls, outputPtr, outputCount, dataType, op, stream);
     726            0 :     if (ret != HCCL_SUCCESS) {
     727            0 :         PrintSubmittedOpCnt(tag, ret);
     728            0 :         return ret;
     729              :     }
     730              : 
     731            0 :     return HCCL_SUCCESS;
     732              : }
     733              : 
     734           23 : HcclResult hcclComm::ReduceScatterVOutPlace(
     735              :     const std::string& tag, void* inputPtr, void* outputPtr, const void* inputCounts, const void* inputDispls,
     736              :     u64 outputCount, HcclDataType dataType, HcclReduceOp op, HcclRtStream stream)
     737              : {
     738              :     /* 增加输出日志关键字 */
     739           23 :     HCCL_INFO(
     740              :         "HCCL_KEY_INFO: tag[%s], input_ptr[%p], output_ptr[%p], "
     741              :         "input_counts[%llu], input_displs[%llu], output_count[%llu], data_type[%s], op[%s]",
     742              :         tag.c_str(), inputPtr, outputPtr, inputCounts, inputDispls, outputCount, GetDataTypeEnumStr(dataType).c_str(),
     743              :         GetReduceOpEnumStr(op).c_str());
     744              : 
     745              :     /* * 入参检查 */
     746           23 :     CHK_RET(communicator_->CheckDataType(dataType, true));
     747           23 :     CHK_RET(communicator_->CheckReduceDataType(dataType, op));
     748           23 :     HcclResult ret = communicator_->ReduceScatterVOutPlace(
     749              :         tag, inputPtr, outputPtr, inputCounts, inputDispls, outputCount, dataType, op, stream);
     750           23 :     if (ret != HCCL_SUCCESS) {
     751            0 :         PrintSubmittedOpCnt(tag, ret);
     752            0 :         return ret;
     753              :     }
     754              : 
     755           23 :     return HCCL_SUCCESS;
     756              : }
     757              : 
     758            5 : HcclResult hcclComm::Reduce(
     759              :     const std::string& tag, void* inputPtr, void* outputPtr, u64 count, HcclDataType dataType, HcclReduceOp op,
     760              :     u32 root, HcclRtStream stream)
     761              : {
     762              :     /* 增加输出日志关键字 */
     763            5 :     HCCL_INFO(
     764              :         "HCCL_KEY_INFO: tag[%s], input_ptr[%p], output_ptr[%p], count[%llu], data_type[%s], op[%s], root[%u]",
     765              :         tag.c_str(), inputPtr, outputPtr, count, GetDataTypeEnumStr(dataType).c_str(), GetReduceOpEnumStr(op).c_str(),
     766              :         root);
     767              : 
     768              :     /* * 入参检查 */
     769            5 :     CHK_PTR_NULL(stream);
     770            5 :     CHK_PTR_NULL(inputPtr);
     771            5 :     CHK_PTR_NULL(outputPtr);
     772              : 
     773            5 :     if (tag.empty()) {
     774            0 :         HCCL_ERROR("[HcclComm][Reduce]errNo[0x%016llx] reduce tag length is 0", HCCL_ERROR_CODE(HCCL_E_PARA));
     775            0 :         return HCCL_E_PARA;
     776              :     }
     777              : 
     778            5 :     CHK_RET(communicator_->CheckCount(count));
     779            5 :     CHK_RET(communicator_->CheckDataType(dataType, true));
     780            5 :     CHK_RET(communicator_->CheckReduceDataType(dataType, op));
     781            5 :     CHK_RET(communicator_->CheckReductionOp(op));
     782            5 :     CHK_RET(communicator_->CheckUserRank(root));
     783            5 :     HcclResult ret = communicator_->Reduce(tag, inputPtr, outputPtr, count, dataType, op, root, stream);
     784            5 :     if (ret != HCCL_SUCCESS) {
     785            0 :         PrintSubmittedOpCnt(tag, ret);
     786            0 :         return ret;
     787              :     }
     788              : 
     789            5 :     return HCCL_SUCCESS;
     790              : }
     791              : 
     792           27 : HcclResult hcclComm::ReduceOutPlace(
     793              :     const std::string& tag, void* inputPtr, void* outputPtr, u64 count, HcclDataType dataType, HcclReduceOp op,
     794              :     u32 root, HcclRtStream stream)
     795              : {
     796              :     /* 增加输出日志关键字 */
     797           27 :     HCCL_INFO(
     798              :         "HCCL_KEY_INFO: tag[%s], input_ptr[%p], output_ptr[%p], count[%llu], data_type[%s], op[%s], root[%u]",
     799              :         tag.c_str(), inputPtr, outputPtr, count, GetDataTypeEnumStr(dataType).c_str(), GetReduceOpEnumStr(op).c_str(),
     800              :         root);
     801              : 
     802              :     /* * 入参检查 */
     803           27 :     CHK_RET(communicator_->CheckDataType(dataType, true));
     804           24 :     CHK_RET(communicator_->CheckReduceDataType(dataType, op));
     805           24 :     CHK_RET(communicator_->CheckUserRank(root));
     806           27 :     HcclResult ret = communicator_->ReduceOutPlace(tag, inputPtr, outputPtr, count, dataType, op, root, stream);
     807           27 :     if (ret != HCCL_SUCCESS) {
     808            4 :         PrintSubmittedOpCnt(tag, ret);
     809            4 :         return ret;
     810              :     }
     811              : 
     812           23 :     return HCCL_SUCCESS;
     813              : }
     814              : 
     815           23 : HcclResult hcclComm::BatchSendRecv(
     816              :     const std::string& tag, struct HcclSendRecvItemDef* sendRecvItemsPtr, u32 itemNum, rtStream_t stream)
     817              : {
     818           23 :     HcclResult ret = communicator_->BatchSendRecv(tag, sendRecvItemsPtr, itemNum, stream);
     819           23 :     if (ret != HCCL_SUCCESS) {
     820            0 :         PrintSubmittedOpCnt(tag, ret);
     821            0 :         return ret;
     822              :     }
     823              : 
     824           23 :     return HCCL_SUCCESS;
     825              : }
     826              : 
     827            0 : HcclResult hcclComm::send(
     828              :     const std::string& tag, void* inputPtr, u64 count, HcclDataType dataType, u32 destRank, rtStream_t stream,
     829              :     u32 srTag, u32 localGroupRank)
     830              : {
     831              :     /* 增加输出日志关键字 */
     832            0 :     HCCL_INFO(
     833              :         "HCCL_KEY_INFO: tag[%s], input_ptr[%p], count[%llu], data_type[%s], destRank[%u]", tag.c_str(), inputPtr, count,
     834              :         GetDataTypeEnumStr(dataType).c_str(), destRank);
     835              : 
     836              :     /* 入参检查 */
     837            0 :     CHK_PTR_NULL(inputPtr);
     838              : 
     839            0 :     if (tag.empty()) {
     840            0 :         HCCL_ERROR("[HcclComm][Send]errNo[0x%016llx] send tag length is 0", HCCL_ERROR_CODE(HCCL_E_PARA));
     841            0 :         return HCCL_E_PARA;
     842              :     }
     843              : 
     844            0 :     CHK_RET(communicator_->CheckCount(count));
     845            0 :     CHK_RET(communicator_->CheckDataType(dataType, false));
     846            0 :     CHK_RET(communicator_->CheckUserRank(destRank));
     847            0 :     HcclResult ret = communicator_->Send(tag, inputPtr, count, dataType, destRank, stream, srTag, localGroupRank);
     848            0 :     if (ret != HCCL_SUCCESS) {
     849            0 :         PrintSubmittedOpCnt(tag, ret);
     850            0 :         return ret;
     851              :     }
     852              : 
     853            0 :     return HCCL_SUCCESS;
     854              : }
     855              : 
     856           25 : HcclResult hcclComm::SendOutPlace(
     857              :     const std::string& tag, void* inputPtr, u64 count, HcclDataType dataType, u32 destRank, rtStream_t stream)
     858              : {
     859              :     /* 增加输出日志关键字 */
     860           25 :     HCCL_INFO(
     861              :         "HCCL_KEY_INFO: tag[%s], input_ptr[%p], count[%llu], data_type[%s], destRank[%u],", tag.c_str(), inputPtr,
     862              :         count, GetDataTypeEnumStr(dataType).c_str(), destRank);
     863              : 
     864              :     /* 入参检查 */
     865           25 :     CHK_RET(communicator_->CheckDataType(dataType, false));
     866           25 :     CHK_RET(communicator_->CheckUserRank(destRank));
     867           24 :     HcclResult ret = communicator_->SendOutPlace(tag, inputPtr, count, dataType, destRank, stream);
     868           24 :     if (ret != HCCL_SUCCESS) {
     869            1 :         PrintSubmittedOpCnt(tag, ret);
     870            1 :         return ret;
     871              :     }
     872              : 
     873           23 :     return HCCL_SUCCESS;
     874              : }
     875              : 
     876           25 : HcclResult hcclComm::ReceiveOutPlace(
     877              :     const std::string& tag, void* outputPtr, u64 count, HcclDataType dataType, u32 srcRank, rtStream_t stream)
     878              : {
     879              :     /* 增加输出日志关键字 */
     880           25 :     HCCL_INFO(
     881              :         "HCCL_KEY_INFO: tag[%s], output_ptr[%p], count[%llu], data_type[%s], srcRank[%u]", tag.c_str(), outputPtr,
     882              :         count, GetDataTypeEnumStr(dataType).c_str(), srcRank);
     883              : 
     884              :     /* * 入参检查 */
     885           25 :     CHK_RET(communicator_->CheckDataType(dataType, false));
     886           25 :     CHK_RET(communicator_->CheckUserRank(srcRank));
     887           24 :     HcclResult ret = communicator_->ReceiveOutPlace(tag, outputPtr, count, dataType, srcRank, stream);
     888           24 :     if (ret != HCCL_SUCCESS) {
     889            1 :         PrintSubmittedOpCnt(tag, ret);
     890            1 :         return ret;
     891              :     }
     892              : 
     893           23 :     return HCCL_SUCCESS;
     894              : }
     895              : 
     896            0 : HcclResult hcclComm::receive(
     897              :     const std::string& tag, void* outputPtr, u64 count, HcclDataType dataType, u32 srcRank, rtStream_t stream,
     898              :     u32 srTag, u32 localGroupRank)
     899              : {
     900              :     /* 增加输出日志关键字 */
     901            0 :     HCCL_INFO(
     902              :         "HCCL_KEY_INFO: tag[%s], output_ptr[%p], count[%llu], data_type[%s], srcRank[%u]", tag.c_str(), outputPtr,
     903              :         count, GetDataTypeEnumStr(dataType).c_str(), srcRank);
     904              : 
     905              :     /* * 入参检查 */
     906            0 :     CHK_PTR_NULL(outputPtr);
     907              : 
     908            0 :     CHK_PRT_RET(
     909              :         tag.empty(),
     910              :         HCCL_ERROR("[HcclComm][Receive]errNo[0x%016llx] receive tag length is 0", HCCL_ERROR_CODE(HCCL_E_PARA)),
     911              :         HCCL_E_PARA);
     912              : 
     913            0 :     CHK_RET(communicator_->CheckCount(count));
     914            0 :     CHK_RET(communicator_->CheckDataType(dataType, false));
     915            0 :     CHK_RET(communicator_->CheckUserRank(srcRank));
     916            0 :     HcclResult ret = communicator_->Receive(tag, outputPtr, count, dataType, srcRank, stream, srTag, localGroupRank);
     917            0 :     if (ret != HCCL_SUCCESS) {
     918            0 :         PrintSubmittedOpCnt(tag, ret);
     919            0 :         return ret;
     920              :     }
     921              : 
     922            0 :     return HCCL_SUCCESS;
     923              : }
     924              : 
     925              : // 目前支持按tag对资源释放、解绑定
     926           16 : HcclResult hcclComm::ClearOpResource(const std::string& tag)
     927              : {
     928           16 :     CHK_RET(communicator_->ClearOpResource(tag));
     929              : 
     930           16 :     return HCCL_SUCCESS;
     931              : }
     932              : 
     933            0 : HcclResult hcclComm::SetClearAivSyncBuf(bool aivClearEnable)
     934              : {
     935            0 :     CHK_RET(communicator_->SetClearAivSyncBuf(aivClearEnable));
     936              : 
     937            0 :     return HCCL_SUCCESS;
     938              : }
     939              : 
     940          292 : HcclResult hcclComm::GetUniqueId(HcclRootInfo* uniqueId)
     941              : {
     942          292 :     CHK_PTR_NULL(uniqueId);
     943              : 
     944          292 :     std::string uniqueIdGot = HcclCommunicator::GetUniqueId();
     945          292 :     s32 ret = snprintf_s(
     946          292 :         uniqueId->internal, HCCL_ROOT_INFO_BYTES, HCCL_ROOT_INFO_BYTES - 1, "%s%s", "hccl-", uniqueIdGot.c_str());
     947          292 :     CHK_PRT_RET(
     948              :         (ret == -1),
     949              :         HCCL_ERROR("[Get][UniqueId]errNo[0x%016llx] get unique id failed,uniqueId[%p]", HCCL_ERROR_CODE(ret), uniqueId),
     950              :         HCCL_E_MEMORY);
     951              : 
     952          292 :     return HCCL_SUCCESS;
     953          292 : }
     954              : 
     955            1 : HcclResult hcclComm::CreateCommCCLbuffer() const
     956              : {
     957            1 :     CHK_RET(communicator_->CreateCommCCLbuffer());
     958              : 
     959            1 :     return HCCL_SUCCESS;
     960              : }
     961              : 
     962            0 : HcclResult hcclComm::CreateIndirectCCLbuf()
     963              : {
     964            0 :     CHK_RET(DeviceMem::alloc(indirectInCCLbuffer_, sizeof(uintptr_t), true));
     965            0 :     CHK_RET(DeviceMem::alloc(indirectOutCCLbuffer_, sizeof(uintptr_t), true));
     966              : 
     967            0 :     return HCCL_SUCCESS;
     968              : }
     969              : 
     970            0 : void hcclComm::ReleaseIndirectCCLbuf()
     971              : {
     972            0 :     indirectInCCLbuffer_.free();
     973            0 :     indirectOutCCLbuffer_.free();
     974            0 : }
     975              : 
     976            0 : HcclResult hcclComm::GetIndirectInCCLbuf(void*& ptr, u64& size)
     977              : {
     978            0 :     ptr = indirectInCCLbuffer_.ptr();
     979            0 :     size = sizeof(uintptr_t);
     980            0 :     return HCCL_SUCCESS;
     981              : }
     982              : 
     983            0 : HcclResult hcclComm::GetIndirectOutCCLbuf(void*& ptr, u64& size)
     984              : {
     985            0 :     ptr = indirectOutCCLbuffer_.ptr();
     986            0 :     size = sizeof(uintptr_t);
     987            0 :     return HCCL_SUCCESS;
     988              : }
     989         1832 : std::string hcclComm::GetIdentifier() { return identifier_; }
     990              : 
     991            2 : std::string hcclComm::GetCCLbufferName() { return cclBuffName_; }
     992              : 
     993            1 : HcclResult hcclComm::CommCheckErrorCqe(HcclResult& result)
     994              : {
     995            1 :     CHK_RET(communicator_->GetCqeError(result));
     996              : 
     997            1 :     return HCCL_SUCCESS;
     998              : }
     999              : 
    1000            0 : HcclResult hcclComm::CommCheckOpInconsistentError(HcclResult& result)
    1001              : {
    1002            0 :     CHK_RET(communicator_->GetOpInconsistentError(result));
    1003              : 
    1004            0 :     return HCCL_SUCCESS;
    1005              : }
    1006              : 
    1007          412 : HcclResult hcclComm::InitImpl(DevType deviceType, const CommConfig& commConfig)
    1008              : {
    1009          412 :     HCCL_INFO(
    1010              :         "InitImpl Implementation isHeterogComm_[%d] isHaveCpuRank_[%d] deviceType[%d] isSpecialType_[%d]",
    1011              :         isHeterogComm_, isHaveCpuRank_, deviceType, isSpecialType_);
    1012              : 
    1013          412 :     communicator_.reset(new (std::nothrow) HcclCommunicator(commConfig));
    1014          411 :     CHK_SMART_PTR_NULL(communicator_);
    1015          411 :     deviceType_ = deviceType;
    1016          411 :     CHK_RET(RegistTaskAbortHandler());
    1017              : 
    1018          412 :     return HCCL_SUCCESS;
    1019              : }
    1020              : 
    1021            0 : HcclResult hcclComm::CreateBarrierMemory()
    1022              : {
    1023            0 :     if (isFirstBarrier_) {
    1024              :         // 申请device内存
    1025            0 :         CHK_RET(DeviceMem::alloc(barrierInMemory_, HCCL_BARRIER_DEFAULT_COUNT * sizeof(float)));
    1026            0 :         CHK_RET(DeviceMem::alloc(barrierOutMemory_, HCCL_BARRIER_DEFAULT_COUNT * sizeof(float)));
    1027              : 
    1028            0 :         barrierSendBuf = static_cast<void*>(barrierInMemory_.ptr());
    1029            0 :         barrierRecvBuf = static_cast<void*>(barrierOutMemory_.ptr());
    1030              : 
    1031              :         // device内存清0
    1032              :         // 申请host内存,并将初始值设置为0
    1033            0 :         HostMem barrierHostMem = HostMem::alloc(HCCL_BARRIER_DEFAULT_COUNT * sizeof(float));
    1034            0 :         CHK_SMART_PTR_NULL(barrierHostMem);
    1035            0 :         s32 sRet = memset_s(barrierHostMem.ptr(), barrierHostMem.size(), 0, barrierHostMem.size());
    1036            0 :         CHK_PRT_RET(sRet != EOK, HCCL_ERROR("[Create][BarrierMemory]mem set failed.errorno[%d]", sRet), HCCL_E_MEMORY);
    1037              : 
    1038            0 :         CHK_RET(hrtMemSyncCopy(
    1039              :             barrierSendBuf, barrierInMemory_.size(), barrierHostMem.ptr(), barrierHostMem.size(),
    1040              :             HcclRtMemcpyKind::HCCL_RT_MEMCPY_KIND_HOST_TO_DEVICE));
    1041              : 
    1042            0 :         CHK_RET(hrtMemSyncCopy(
    1043              :             barrierRecvBuf, barrierOutMemory_.size(), barrierHostMem.ptr(), barrierHostMem.size(),
    1044              :             HcclRtMemcpyKind::HCCL_RT_MEMCPY_KIND_HOST_TO_DEVICE));
    1045              : 
    1046            0 :         isFirstBarrier_ = false;
    1047            0 :     }
    1048            0 :     return HCCL_SUCCESS;
    1049              : }
    1050              : 
    1051            0 : HcclResult hcclComm::GetInCCLbuffer(void*& buffer, u64& size)
    1052              : {
    1053            0 :     CHK_RET(communicator_->GetInCCLbuffer(buffer, size));
    1054              : 
    1055            0 :     return HCCL_SUCCESS;
    1056              : }
    1057            0 : HcclResult hcclComm::GetOutCCLbuffer(void*& buffer, u64& size)
    1058              : {
    1059            0 :     CHK_RET(communicator_->GetOutCCLbuffer(buffer, size));
    1060              : 
    1061            0 :     return HCCL_SUCCESS;
    1062              : }
    1063              : 
    1064          346 : HcclResult hcclComm::GetUserRank(u32& userRank)
    1065              : {
    1066          346 :     userRank = communicator_->GetUserRank();
    1067              : 
    1068          346 :     return HCCL_SUCCESS;
    1069              : }
    1070              : 
    1071           71 : HcclResult hcclComm::GetGroupRank(u32& userRank)
    1072              : {
    1073           71 :     userRank = communicator_->GetGroupRank();
    1074              : 
    1075           71 :     return HCCL_SUCCESS;
    1076              : }
    1077              : 
    1078          330 : HcclResult hcclComm::GetRankSize(u32& rankSize)
    1079              : {
    1080          330 :     rankSize = communicator_->GetRankSize();
    1081              : 
    1082          330 :     return HCCL_SUCCESS;
    1083              : }
    1084              : 
    1085            0 : HcclResult hcclComm::HcclSelectAlg(
    1086              :     HcclCMDType opType, u64 count, void* counts, HcclDataType dataType, HcclReduceOp op, int32_t aivCoreLimit,
    1087              :     bool& ifAiv, std::string& algName)
    1088              : {
    1089            0 :     return communicator_->HcclSelectAlg(opType, count, counts, dataType, op, aivCoreLimit, ifAiv, algName);
    1090              : }
    1091              : 
    1092            0 : HcclResult hcclComm::HcclCalcNumBlocks(
    1093              :     HcclCMDType opType, u64 count, void* counts, HcclDataType dataType, int32_t aivCoreLimit, std::string& algName,
    1094              :     u32& numBlocks)
    1095              : {
    1096            0 :     return communicator_->HcclCalcNumBlocks(opType, count, counts, dataType, aivCoreLimit, algName, numBlocks);
    1097              : }
    1098              : 
    1099            0 : HcclResult hcclComm::HcclGetAlgExecParam(
    1100              :     const std::string& tag, u64 count, void* inputPtr, void* outputPtr, HcclCMDType opType, bool clearEnable,
    1101              :     HcclDataType dataType, HcclReduceOp op, void*& commContext, u64& len, u32 aivCoreLimit)
    1102              : {
    1103            0 :     return communicator_->HcclGetAlgExecParam(
    1104            0 :         tag, opType, count, inputPtr, outputPtr, clearEnable, dataType, op, commContext, len, aivCoreLimit);
    1105              : }
    1106              : 
    1107            1 : HcclResult hcclComm::SetAicpuCommEngine(bool isAicpuCommEngine)
    1108              : {
    1109            1 :     return communicator_->SetAicpuCommEngine(isAicpuCommEngine);
    1110              : }
    1111              : 
    1112          153 : HcclResult hcclComm::GetWorkspaceSubStreamNum(
    1113              :     u64 count, HcclDataType dataType, HcclReduceOp op, const std::string& algName, u64& streamNum, u64 dataSize,
    1114              :     bool ifAiv, HcclCMDType optype) const
    1115              : {
    1116          153 :     return communicator_->GetWorkspaceSubStreamNum(count, dataType, op, algName, streamNum, dataSize, ifAiv, optype);
    1117              : }
    1118              : HcclResult
    1119           91 : hcclComm::GetWorkspaceMemSize(const std::string& opType, u64 count, HcclDataType dataType, u32& rankSize, u64& size)
    1120              : {
    1121           91 :     return communicator_->GetWorkspaceMemSize(opType, count, dataType, rankSize, size, deviceType_);
    1122              : }
    1123              : 
    1124            0 : HcclResult hcclComm::GetAllReduceScratchSize(const u64 count, const HcclDataType dataType, u64& scratchSize) const
    1125              : {
    1126            0 :     return communicator_->GetAllReduceScratchSize(count, dataType, scratchSize);
    1127              : }
    1128              : 
    1129              : // 设定 workspace 资源
    1130              : HcclResult
    1131          155 : hcclComm::SetWorkspaceResource(const std::string& tag, void* memPtr, u64 maxSize, std::vector<rtStream_t>& stream)
    1132              : {
    1133          155 :     return communicator_->SetWorkspaceResource(tag, memPtr, maxSize, stream);
    1134              : }
    1135              : 
    1136              : HcclResult
    1137           95 : hcclComm::CreateOpBasedResources(const HcclCMDType& opType, const std::string& tag, const HcomCollOpInfo& opInfo)
    1138              : {
    1139           95 :     return communicator_->CreateOpBasedResources(opType, tag, opInfo);
    1140              : }
    1141              : 
    1142            0 : HcclResult hcclComm::GetDeviceNumPerAggregation(u32& deviceNumPerAggregation)
    1143              : {
    1144            0 :     return communicator_->GetDeviceNumPerAggregation(deviceNumPerAggregation);
    1145              : }
    1146              : 
    1147            0 : HcclResult hcclComm::GetBandWidthPerNPU(u32 level, float& bandWidth)
    1148              : {
    1149            0 :     return communicator_->GetBandWidthPerNPU(level, bandWidth);
    1150              : }
    1151              : 
    1152            0 : HcclResult hcclComm::GetAlltoAllStagedWorkSpaceMemSize(
    1153              :     u64* sendCounts, u64* sdispls, HcclDataType sendType, u64* recvCounts, u64* rdispls, HcclDataType recvType,
    1154              :     u64& memSize) const
    1155              : {
    1156            0 :     CHK_RET(communicator_->GetAlltoAllStagedWorkSpaceMemSize(
    1157              :         sendCounts, sdispls, sendType, recvCounts, rdispls, recvType, memSize));
    1158            0 :     return HCCL_SUCCESS;
    1159              : }
    1160              : 
    1161            0 : HcclResult hcclComm::GetAlltoAllStagedWorkSpaceMemSize(
    1162              :     std::vector<SendRecvInfo>& allMeshAggregationSendRecvInfo, u64& memSize) const
    1163              : {
    1164            0 :     CHK_RET(communicator_->GetAlltoAllStagedWorkSpaceMemSize(allMeshAggregationSendRecvInfo, memSize));
    1165            0 :     return HCCL_SUCCESS;
    1166              : }
    1167              : 
    1168           92 : HcclResult hcclComm::SetGlobalWorkSpace(std::vector<void*>& globalWorkSpaceAddr)
    1169              : {
    1170           92 :     CHK_RET(communicator_->SetGlobalWorkSpace(globalWorkSpaceAddr));
    1171              : 
    1172           92 :     return HCCL_SUCCESS;
    1173              : }
    1174              : 
    1175            0 : HcclResult hcclComm::SetAttachedStream(u32 graphId, const std::vector<rtStream_t>& streams)
    1176              : {
    1177            0 :     CHK_RET(communicator_->SetAttachedStream(graphId, streams));
    1178            0 :     return HCCL_SUCCESS;
    1179              : }
    1180              : 
    1181            0 : HcclResult hcclComm::GetandClearOverFlowTasks(std::vector<HcclDumpInfo>& hcclDumpInfo)
    1182              : {
    1183            0 :     CHK_RET(communicator_->GetandClearOverFlowTasks(hcclDumpInfo));
    1184              : 
    1185            0 :     return HCCL_SUCCESS;
    1186              : }
    1187              : 
    1188            0 : HcclResult hcclComm::SetCommDispatcherCtx()
    1189              : {
    1190            0 :     DispatcherCtxPtr dispatherCtx = GetDispatcherCtx(identifier_.c_str());
    1191            0 :     CHK_PTR_NULL(dispatherCtx);
    1192            0 :     HCCL_INFO("[%s] dispatherCtx = [%p]", __func__, dispatherCtx);
    1193            0 :     CHK_RET(SetDispatcherCtx(dispatherCtx));
    1194            0 :     return HCCL_SUCCESS;
    1195              : }
    1196              : 
    1197            0 : HcclResult hcclComm::ReleaseCommDispatcherCtx() { return HCCL_SUCCESS; }
    1198              : 
    1199            0 : HcclResult hcclComm::SupportDeterministicOptim(bool& isDeterministicOptim)
    1200              : {
    1201            0 :     CHK_RET(communicator_->SupportDeterministicOptim(isDeterministicOptim));
    1202              : 
    1203            0 :     return HCCL_SUCCESS;
    1204              : }
    1205              : 
    1206            0 : HcclResult hcclComm::GetHccsLinkNum(u32& numHccsLink) { return communicator_->GetHccsLinkNum(numHccsLink); }
    1207              : 
    1208          236 : HcclResult hcclComm::GetDeviceId(s32& deviceId)
    1209              : {
    1210          236 :     CHK_SMART_PTR_NULL(communicator_);
    1211          235 :     CHK_RET(communicator_->GetDeviceId(deviceId));
    1212              : 
    1213          235 :     return HCCL_SUCCESS;
    1214              : }
    1215              : 
    1216            0 : HcclResult hcclComm::GetDevType(DevType& devType)
    1217              : {
    1218            0 :     devType = deviceType_;
    1219            0 :     return HCCL_SUCCESS;
    1220              : }
    1221              : 
    1222            0 : HcclResult hcclComm::IsStandardCard(bool& isStandardCard)
    1223              : {
    1224            0 :     isStandardCard = communicator_->IsStandardCard();
    1225              : 
    1226            0 :     return HCCL_SUCCESS;
    1227              : }
    1228              : 
    1229            0 : HcclResult hcclComm::Is310PDuoCard(bool& is310PDuoCard)
    1230              : {
    1231            0 :     is310PDuoCard = communicator_->Is310PDuoCard();
    1232            0 :     return HCCL_SUCCESS;
    1233              : }
    1234              : 
    1235          235 : bool hcclComm::IsNeedResetDevice() { return isResetDevice_; }
    1236              : 
    1237            0 : HcclResult hcclComm::ResetDeviceEnable()
    1238              : {
    1239            0 :     isResetDevice_ = true;
    1240            0 :     return HCCL_SUCCESS;
    1241              : }
    1242              : 
    1243          633 : HcclResult hcclComm::SaveTraceInfo(std::string& logInfo)
    1244              : {
    1245          633 :     CHK_PRT(communicator_->SaveTraceInfo(logInfo));
    1246              : 
    1247          633 :     return HCCL_SUCCESS;
    1248              : }
    1249              : 
    1250            1 : bool hcclComm::GetCommResource(const std::string& tag, void** commContext)
    1251              : {
    1252              :     /* 增加输出日志关键字 */
    1253            1 :     HCCL_INFO("HCCL_KEY_INFO: GetCommResource commContext[%p]", commContext);
    1254              : 
    1255            1 :     return (communicator_->GetCommResource(tag, commContext));
    1256              : }
    1257              : 
    1258            7 : bool hcclComm::GetCommResource(void*& commContext)
    1259              : {
    1260            7 :     HCCL_INFO("HCCL_KEY_INFO: GetCommResource commContext[%p]", commContext);
    1261            7 :     return communicator_->GetCommResource(commContext);
    1262              : }
    1263              : 
    1264          236 : HcclResult hcclComm::SetStopFlag(bool value)
    1265              : {
    1266          236 :     if (communicator_ != nullptr) {
    1267          235 :         return communicator_->SetStopFlag(value);
    1268              :     }
    1269            1 :     return HCCL_SUCCESS;
    1270              : }
    1271              : 
    1272          540 : HcclResult hcclComm::SetState(HcclCommState state)
    1273              : {
    1274          540 :     if (communicator_ != nullptr) {
    1275          540 :         return communicator_->SetState(state);
    1276              :     }
    1277            0 :     return HCCL_SUCCESS;
    1278              : }
    1279              : 
    1280          506 : HcclCommState hcclComm::GetState()
    1281              : {
    1282          506 :     if (communicator_ != nullptr) {
    1283          505 :         return communicator_->GetState();
    1284              :     }
    1285            1 :     return HcclCommState::IDLE;
    1286              : }
    1287              : 
    1288            1 : HcclResult hcclComm::AllocComResourceByTiling(const std::string& algConfig, void* param)
    1289              : {
    1290            1 :     HCCL_INFO("HCCL_KEY_INFO: AllocComResourceByTiling algConfig[%s].", algConfig.c_str());
    1291            1 :     return communicator_->AllocComResourceByTiling(algConfig, param);
    1292              : }
    1293              : 
    1294            1 : HcclResult hcclComm::CreateCommResource(
    1295              :     const std::string& tag, rtStream_t aiCpuStream, bool isOpbaseMode, void** commContext, const std::string& algConfig)
    1296              : {
    1297              :     /* 增加输出日志关键字 */
    1298            1 :     HCCL_INFO(
    1299              :         "HCCL_KEY_INFO: CreateCommResource commContext[%p], isOpbaseMode[%u], algConfig[%s].", commContext,
    1300              :         isOpbaseMode, algConfig.c_str());
    1301              : 
    1302            1 :     CHK_RET(communicator_->CreateCommResource(tag, aiCpuStream, isOpbaseMode, commContext, algConfig));
    1303              : 
    1304            1 :     return HCCL_SUCCESS;
    1305              : }
    1306              : 
    1307            0 : HcclResult hcclComm::GetAicpuOpStreamNotify(HcclRtStream* opStream, u8 aicpuNotifyNum, void** aicpuNotify)
    1308              : {
    1309              :     /* 增加输出日志关键字 */
    1310            0 :     HCCL_INFO("HCCL_KEY_INFO: GetAicpuOpStreamNotify commContext[%p]", opStream);
    1311              : 
    1312            0 :     CHK_RET(communicator_->GetAicpuOpStreamNotify(opStream, aicpuNotifyNum, aicpuNotify));
    1313              : 
    1314            0 :     return HCCL_SUCCESS;
    1315              : }
    1316              : 
    1317            2 : HcclResult hcclComm::Mc2AiCpuStreamAllocAndGet(u32 streamMode, rtStream_t& aiCpuStream)
    1318              : {
    1319              :     /* 增加输出日志关键字 */
    1320            2 :     HCCL_INFO("HCCL_KEY_INFO: Mc2AiCpuStreamAllocAndGet streamMode[%u]", streamMode);
    1321              : 
    1322            2 :     CHK_RET(communicator_->Mc2AiCpuStreamAllocAndGet(streamMode, aiCpuStream));
    1323            2 :     CHK_PTR_NULL(aiCpuStream);
    1324              : 
    1325            2 :     return HCCL_SUCCESS;
    1326              : }
    1327              : 
    1328            0 : HcclResult hcclComm::GetTopoDesc(HcclTopoDescs* topoDescs, uint32_t topoSize)
    1329              : {
    1330            0 :     HCCL_INFO("HCCL_KEY_INFO: GetTopoDesc topoDescs[%p] topoSize[%u]", topoDescs, topoSize);
    1331              : 
    1332            0 :     CHK_RET(communicator_->GetTopoDesc(topoDescs, topoSize));
    1333              : 
    1334            0 :     return HCCL_SUCCESS;
    1335              : }
    1336              : 
    1337            0 : HcclResult hcclComm::GetCommUserMemSize(uint64_t& size)
    1338              : {
    1339            0 :     HcclResult ret = communicator_->GetCommUserMemSize(size);
    1340            0 :     CHK_PRT_RET(ret != HCCL_SUCCESS, HCCL_INFO("[%s]call trace: hcclRet -> %d", __func__, ret), ret);
    1341            0 :     return HCCL_SUCCESS;
    1342              : }
    1343          235 : HcclResult hcclComm::SetDeterministicConfig(const u8 deterministic)
    1344              : {
    1345          235 :     CHK_RET(communicator_->SetDeterministicConfig(deterministic));
    1346          235 :     return HCCL_SUCCESS;
    1347              : }
    1348              : 
    1349          235 : HcclResult hcclComm::SetAivModeConfig(const bool aivMode)
    1350              : {
    1351          235 :     CHK_RET(communicator_->SetAivModeConfig(aivMode));
    1352          235 :     return HCCL_SUCCESS;
    1353              : }
    1354              : 
    1355          235 : HcclResult hcclComm::SetOnlyAivModeConfig(const bool isOnlyAiv)
    1356              : {
    1357          235 :     CHK_RET(communicator_->SetOnlyAivModeConfig(isOnlyAiv));
    1358          235 :     return HCCL_SUCCESS;
    1359              : }
    1360              : 
    1361            0 : HcclResult hcclComm::GetOnlyAivModeConfig(bool& isOnlyAiv)
    1362              : {
    1363            0 :     isOnlyAiv = communicator_->GetConfigIsOnlyAivMode();
    1364            0 :     return HCCL_SUCCESS;
    1365              : }
    1366              : 
    1367          235 : HcclResult hcclComm::SetAicpuUnfoldConfig(const bool aicpuUnfold)
    1368              : {
    1369          235 :     CHK_RET(communicator_->SetAicpuUnfoldConfig(aicpuUnfold));
    1370          235 :     return HCCL_SUCCESS;
    1371              : }
    1372              : 
    1373          235 : HcclResult hcclComm::SetExecTimeOutConfig(const s32 execTimeOut)
    1374              : {
    1375          235 :     CHK_RET(communicator_->SetExecTimeOutConfig(execTimeOut));
    1376          235 :     return HCCL_SUCCESS;
    1377              : }
    1378              : 
    1379          235 : HcclResult hcclComm::SetAlgoConfig(const std::map<HcclCMDType, std::vector<HcclAlgoType>>& algoMap)
    1380              : {
    1381          235 :     CHK_RET(communicator_->SetAlgoConfig(algoMap));
    1382          235 :     return HCCL_SUCCESS;
    1383              : }
    1384              : 
    1385            0 : u64 hcclComm::GetConfigInCCLbufferSize() { return inCCLbufferSize_; }
    1386              : 
    1387            0 : u64 hcclComm::GetConfigOutCCLbufferSize() { return outCCLbufferSize_; }
    1388              : 
    1389            0 : u32 hcclComm::GetRankTableCrc() { return communicator_->GetRankTableCrc(); }
    1390              : 
    1391            0 : u32 hcclComm::GetServerNum() { return communicator_->GetServerNum(); }
    1392              : 
    1393            1 : u32 hcclComm::GetModuleNum() { return communicator_->GetModuleNum(); }
    1394              : 
    1395            0 : u32 hcclComm::GetRealUserRank() const { return communicator_->GetRealUserRank(); }
    1396              : 
    1397            1 : HcclResult hcclComm::GetCommParams(HcclCommParams& params)
    1398              : {
    1399            1 :     CHK_RET(communicator_->GetCommParams(params));
    1400            1 :     params.deviceType = deviceType_;
    1401            1 :     params.isHeterogComm = isHeterogComm_;
    1402            1 :     params.identifier = identifier_;
    1403            1 :     return HCCL_SUCCESS;
    1404              : }
    1405              : 
    1406            1 : HcclResult hcclComm::GetCommRankTable(RankTable_t& rankTable)
    1407              : {
    1408            1 :     CHK_RET(communicator_->GetCommRankTable(rankTable));
    1409            1 :     return HCCL_SUCCESS;
    1410              : }
    1411              : 
    1412            1 : HcclResult hcclComm::Suspend()
    1413              : {
    1414            1 :     CHK_RET(communicator_->Suspend());
    1415            1 :     return HCCL_SUCCESS;
    1416              : }
    1417              : 
    1418            0 : HcclResult hcclComm::InitZeroCopyMemoryAgent()
    1419              : {
    1420            0 :     CHK_SMART_PTR_NULL(communicator_);
    1421            0 :     CHK_RET(communicator_->InitZeroCopyMemoryAgent());
    1422            0 :     return HCCL_SUCCESS;
    1423              : }
    1424              : 
    1425          236 : HcclResult hcclComm::DeinitZeroCopyMemoryAgent()
    1426              : {
    1427          236 :     CHK_SMART_PTR_NULL(communicator_);
    1428          235 :     CHK_RET(communicator_->DeinitZeroCopyMemoryAgent());
    1429          235 :     return HCCL_SUCCESS;
    1430              : }
    1431              : 
    1432            1 : HcclResult hcclComm::SetMemoryRange(void* baseVirPtr, size_t size, size_t alignment, uint64_t flags)
    1433              : {
    1434            1 :     CHK_SMART_PTR_NULL(communicator_);
    1435            1 :     CHK_RET(communicator_->SetMemoryRange(baseVirPtr, size, alignment, flags));
    1436            1 :     return HCCL_SUCCESS;
    1437              : }
    1438              : 
    1439            1 : HcclResult hcclComm::UnsetMemoryRange(void* baseVirPtr)
    1440              : {
    1441            1 :     CHK_SMART_PTR_NULL(communicator_);
    1442            1 :     CHK_RET(communicator_->UnsetMemoryRange(baseVirPtr));
    1443            1 :     return HCCL_SUCCESS;
    1444              : }
    1445              : 
    1446            1 : HcclResult hcclComm::ActivateCommMemory(void* virPtr, size_t size, size_t offset, void* handle, uint64_t flags)
    1447              : {
    1448            1 :     CHK_SMART_PTR_NULL(communicator_);
    1449            1 :     CHK_RET(communicator_->ActivateCommMemory(virPtr, size, offset, handle, flags));
    1450            1 :     return HCCL_SUCCESS;
    1451              : }
    1452              : 
    1453            1 : HcclResult hcclComm::DeactivateCommMemory(void* virPtr)
    1454              : {
    1455            1 :     CHK_SMART_PTR_NULL(communicator_);
    1456            1 :     CHK_RET(communicator_->DeactivateCommMemory(virPtr));
    1457            1 :     return HCCL_SUCCESS;
    1458              : }
    1459              : 
    1460           13 : HcclResult hcclComm::GetNumBlocks(u32& numBlocks) { return communicator_->GetNumBlocks(numBlocks); }
    1461              : 
    1462          302 : HcclResult hcclComm::SetAivCoreLimit(u32 aivCoreLimit)
    1463              : {
    1464          302 :     CHK_SMART_PTR_NULL(communicator_);
    1465          302 :     return communicator_->SetAivCoreLimit(aivCoreLimit);
    1466              : }
    1467              : 
    1468            1 : HcclResult hcclComm::SwitchNic(uint32_t nRanks, uint32_t* ranks, bool* useBackup)
    1469              : {
    1470            1 :     CHK_SMART_PTR_NULL(communicator_);
    1471            1 :     CHK_RET(communicator_->SwitchNic(nRanks, ranks, useBackup));
    1472            1 :     return HCCL_SUCCESS;
    1473              : }
    1474          235 : HcclResult hcclComm::InitHccpChannel()
    1475              : {
    1476              :     /* 增加输出日志关键字 */
    1477          235 :     HCCL_INFO("NslbDp try to init hccp ");
    1478          235 :     return communicator_->InitHccpChannel();
    1479              : }
    1480              : 
    1481          404 : std::vector<RankInfo> hcclComm::GetRankLists() { return communicator_->GetRankLists(); }
    1482              : 
    1483            0 : HcclResult hcclComm::GetLocalCCLBuf(void** addr, uint64_t* size)
    1484              : {
    1485            0 :     CHK_SMART_PTR_NULL(communicator_);
    1486            0 :     CHK_RET(communicator_->GetLocalCCLBuf(addr, size));
    1487            0 :     return HCCL_SUCCESS;
    1488              : }
    1489              : 
    1490            6 : HcclResult hcclComm::GetRemoteCCLBuf(uint32_t remoteRank, void** addr, uint64_t* size)
    1491              : {
    1492            6 :     CHK_SMART_PTR_NULL(communicator_);
    1493            6 :     CHK_RET(communicator_->GetRemoteCCLBuf(remoteRank, addr, size));
    1494            4 :     return HCCL_SUCCESS;
    1495              : }
    1496              : 
    1497            0 : HcclResult hcclComm::SetGroupMode(bool isGroup)
    1498              : {
    1499            0 :     isGroupMode_ = isGroup;
    1500            0 :     CHK_SMART_PTR_NULL(communicator_);
    1501            0 :     CHK_RET(communicator_->SetGroupMode(isGroup));
    1502            0 :     return HCCL_SUCCESS;
    1503              : }
    1504              : 
    1505            0 : bool hcclComm::GetGroupMode() { return isGroupMode_; }
    1506              : 
    1507            0 : HcclResult hcclComm::GetKFCWorkSpace(void** addr, uint64_t* size)
    1508              : {
    1509            0 :     CHK_SMART_PTR_NULL(communicator_);
    1510            0 :     CHK_RET(communicator_->GetKFCWorkSpace(addr, size));
    1511            0 :     return HCCL_SUCCESS;
    1512              : }
    1513              : 
    1514           92 : bool hcclComm::IsCommunicatorV2()
    1515              : {
    1516           92 :     if (devType_ == DevType::DEV_TYPE_950 || devType_ == DevType::DEV_TYPE_960) {
    1517           72 :         return true;
    1518              :     }
    1519           20 :     return false;
    1520              : }
    1521              : 
    1522            0 : HcclResult hcclComm::SetHcclQos(u32 hcclQos)
    1523              : {
    1524              :     // 校验config中QoS的合法性
    1525            0 :     if (hcclQos == HCCL_COMM_QOS_CONFIG_NOT_SET) {
    1526            0 :         HCCL_INFO(
    1527              :             "[SetHcclQos]The QoS do not use the config configuration. "
    1528              :             "It will use environment variables to configure. QoS[%u]",
    1529              :             EnvConfig::HCCL_QOS_DEFAULT);
    1530            0 :         hcclQos_ = EnvConfig::HCCL_QOS_DEFAULT;
    1531            0 :         communicator_->SetHcclQos(EnvConfig::HCCL_QOS_DEFAULT);
    1532            0 :         return HCCL_SUCCESS;
    1533              :     }
    1534              : 
    1535              :     // 若设置的hcclQos不在有效范围内,则使用默认值
    1536            0 :     if (hcclQos > EnvConfig::HCCL_QOS_MAX) {
    1537            0 :         HCCL_INFO(
    1538              :             "[SetHcclQos]hcclQos is invalid, expect[%u, %u], actual[%u]. "
    1539              :             "It will use the default value. QoS[%u]",
    1540              :             EnvConfig::HCCL_QOS_MIN, EnvConfig::HCCL_QOS_MAX, hcclQos, EnvConfig::HCCL_QOS_DEFAULT);
    1541            0 :         hcclQos_ = EnvConfig::HCCL_QOS_DEFAULT;
    1542            0 :         communicator_->SetHcclQos(EnvConfig::HCCL_QOS_DEFAULT);
    1543            0 :         return HCCL_SUCCESS;
    1544              :     }
    1545              : 
    1546            0 :     HCCL_INFO("[SetHcclQos] hcclQos[%u]", hcclQos);
    1547            0 :     hcclQos_ = hcclQos;
    1548            0 :     communicator_->SetHcclQos(hcclQos);
    1549              : 
    1550            0 :     return HCCL_SUCCESS;
    1551              : }
    1552              : 
    1553            0 : u32 hcclComm::GetHcclQos() { return hcclQos_; }
    1554              : 
    1555            0 : HcclResult hcclComm::RegisterWindow(void* ptr, size_t size, HcclCommSymWindow* winHandle)
    1556              : {
    1557            0 :     CHK_SMART_PTR_NULL(communicator_);
    1558            0 :     CHK_RET(communicator_->RegisterWindow(ptr, size, winHandle));
    1559            0 :     return HCCL_SUCCESS;
    1560              : }
    1561              : 
    1562            0 : HcclResult hcclComm::DeregisterWindow(HcclCommSymWindow winHandle)
    1563              : {
    1564            0 :     CHK_SMART_PTR_NULL(communicator_);
    1565            0 :     CHK_RET(communicator_->DeregisterWindow(winHandle));
    1566            0 :     return HCCL_SUCCESS;
    1567              : }
    1568              : 
    1569            0 : HcclResult hcclComm::GetCommSymWin(void* ptr, size_t size, HcclCommSymWindow* winHandle, size_t* offset)
    1570              : {
    1571            0 :     CHK_SMART_PTR_NULL(communicator_);
    1572            0 :     CHK_RET(communicator_->GetCommSymWin(ptr, size, winHandle, offset));
    1573            0 :     return HCCL_SUCCESS;
    1574              : }
    1575              : 
    1576            0 : aclrtBinHandle hcclComm::GetBinHandle() { return binHandle_; }
    1577              : 
    1578              : } // namespace hccl
        

Generated by: LCOV version 2.0-1