LCOV - code coverage report
Current view: top level - legacy/ascend910/hccd - hccd.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 216 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 13 0

            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 "hccl_types.h"
      12              : #include "hccl/base.h"
      13              : #include "hccl/hccl_ex.h"
      14              : #include "dlra_function.h"
      15              : #include "externalinput_pub.h"
      16              : #include "mr_manager.h"
      17              : #include "rank_consistentcy_checker.h"
      18              : #include "transport_heterog_def.h"
      19              : #include "transport_heterog.h"
      20              : #include "hccd_private.h"
      21              : // ltm指定config路径
      22              : #include "common/src/config.h"
      23              : #include "hccd_comm.h"
      24              : #include "hccd_pub.h"
      25              : #include "adapter_hal.h"
      26              : #include "dlhal_function.h"
      27              : #include <dlog_pub.h>
      28              : 
      29              : using namespace std;
      30              : using namespace hccl;
      31              : constexpr u32 TIME_THREE_TIMEGAP = 3;
      32              : 
      33            0 : HcclResult HccdGenerateCommId(hccl::HcclCommParams &params)
      34              : {
      35            0 :     s32 sRet = memset_s(params.id.internal, HCCL_ROOT_INFO_BYTES, 0, sizeof(params.id.internal));
      36            0 :     CHK_PRT_RET(sRet != EOK, HCCL_ERROR("[GenerateCommId]memory set error. return[%d].", sRet), HCCL_E_PARA);
      37              : 
      38              :     HcclRootInfo uniqueId;
      39            0 :     std::string group;
      40            0 :     CHK_RET(HccdComm::GetUniqueId(&uniqueId));
      41              : 
      42            0 :     group = "hccl_heterog_group";
      43              : 
      44            0 :     sRet = snprintf_s(params.id.internal, HCCL_ROOT_INFO_BYTES, HCCL_ROOT_INFO_BYTES - 1, "%s%s%s",
      45              :         uniqueId.internal, "-", group.c_str());
      46            0 :     CHK_PRT_RET(sRet == -1, HCCL_ERROR("[GenerateCommId]errNo[0x%016llx] sal snprintf_s error",
      47              :         HCCL_ERROR_CODE(HCCL_E_INTERNAL)), HCCL_E_INTERNAL);
      48            0 :     HCCL_INFO("params.id.internal [%s]", params.id.internal);
      49            0 :     return HCCL_SUCCESS;
      50            0 : }
      51              : int32_t DlogSetAttr(LogAttr logAttrInfo) __attribute((weak));
      52            0 : HcclResult HcclInitComm(const char* rankTableM, uint32_t rank, const CommAttr* attr, HcclComm* comm,
      53              :     HccdInfo &rankInfo)
      54              : {
      55            0 :     HcclResult ret = HCCL_SUCCESS;
      56            0 :     HcclUs startut = TIME_NOW();
      57            0 :     auto timeGap = TIME_NOW() - startut;
      58              : 
      59              :     // 入参合法性检查
      60            0 :     CHK_PTR_NULL(rankTableM);
      61            0 :     CHK_PTR_NULL(comm);
      62            0 :     CHK_PTR_NULL(attr);
      63              : 
      64              :     // 为了解决云助端device 日志不上传的问题,需要调用DlogSetAttr
      65            0 :     CHK_RET(DlHalFunction::GetInstance().DlHalFunctionInit());
      66            0 :     unsigned int chipId = 0;
      67            0 :     unsigned int vfid = 0;
      68            0 :     unsigned int hostPid = 0;
      69            0 :     unsigned int cpType = 0;
      70            0 :     int curPid = SalGetPid();
      71            0 :     CHK_RET(HrtHalDrvQueryProcessHostPid(curPid, &chipId, &vfid, &hostPid, &cpType));
      72            0 :     LogAttr logattr{};
      73            0 :     logattr.type = APPLICATION;
      74            0 :     logattr.pid = hostPid;
      75            0 :     logattr.deviceId = attr->deviceId;
      76            0 :     if (DlogSetAttr!= nullptr && DlogSetAttr(logattr) != 0) {
      77            0 :         HCCL_ERROR("DlogSetAttr failed");
      78            0 :         return HCCL_E_SYSCALL;
      79              :     }
      80              : 
      81            0 :     std::string rankTableStr = rankTableM;
      82              : 
      83              :     /* 接口交互信息日志 */
      84            0 :     HCCL_RUN_INFO("Entry-HcclInitComm:clusterInfo, rank[%u]", rank);
      85            0 :     if (attr->mode != WorkMode::HCCL_MODE_AI_CPU) {
      86            0 :         CHK_RET(DlRaFunction::GetInstance().DlRaFunctionInit());
      87              :     }
      88              : 
      89              :     /* --------------初始化------------------------- */
      90            0 :     bool errorFlag = false;
      91            0 :     hccl::HccdComm* pComm = nullptr;
      92              :     do {
      93              :         // 初始化外部参数
      94            0 :         ret = InitExternalInput();
      95            0 :         CHK_PRT_BREAK(ret != HCCL_SUCCESS, HCCL_ERROR("[Init][HccdComm]errNo[0x%016llx] init external input error",
      96              :             HCCL_ERROR_CODE(ret)), errorFlag = true);
      97              : 
      98            0 :         ret = InitExternalInputHeterog();
      99            0 :         CHK_PRT_BREAK(ret != HCCL_SUCCESS, HCCL_ERROR("[Init][HccdComm]errNo[0x%016llx] init external input error",
     100              :             HCCL_ERROR_CODE(ret)), errorFlag = true);
     101              : 
     102              :         // 解析rankTable_json对象,将解析的信息保存在rankinfo中,ranktableCRC计算
     103            0 :         ret = HcclParseRanktable(rankTableStr, to_string(rank), rankInfo.params, rankInfo.rankTable);
     104            0 :         CHK_PRT_BREAK(ret != HCCL_SUCCESS, HCCL_ERROR("[Init][HccdComm]errNo[0x%016llx] hccl analysis ranktable "\
     105              :             "info error:rank [%u]", HCCL_ERROR_CODE(ret), rank), errorFlag = true);
     106              : 
     107              :         // 生成通信域标识符
     108            0 :         ret = HccdGenerateCommId(rankInfo.params);
     109            0 :         CHK_PRT_RET(ret != HCCL_SUCCESS, HCCL_ERROR("[Init][OtherInfo]errNo[0x%016llx] generate CommId error",\
     110              :             HCCL_ERROR_CODE(HCCL_E_INTERNAL)), HCCL_E_INTERNAL);
     111              : 
     112            0 :         for (auto &rankIter : rankInfo.rankTable.rankList) {
     113            0 :             if (rankIter.rankId == rank) {
     114            0 :                 if (attr->mode != WorkMode::HCCL_MODE_PS && attr->mode != WorkMode::HCCL_MODE_AI_CPU) {
     115            0 :                     rankIter.deviceInfo.devicePhyId = attr->deviceId;
     116            0 :                     break;
     117              :                 }
     118              :             }
     119              :         }
     120              : 
     121              :         // new新对象
     122            0 :         pComm = new (std::nothrow) hccl::HccdComm(rankInfo.rankTable.collectiveId);
     123            0 :         CHK_PTR_NULL(pComm);
     124              : 
     125              :         // 根据rankinfo结构体的内容,初始化通信域
     126            0 :         rankInfo.params.commHandle = pComm;
     127            0 :         rankInfo.params.attr = *attr;
     128            0 :         ret = pComm->init(rankInfo.params, rankInfo.rankTable);
     129            0 :         CHK_PRT_BREAK(ret != HCCL_SUCCESS, HCCL_ERROR("[Init][HccdComm]errNo[0x%016llx] HeterogComm init error",
     130              :             HCCL_ERROR_CODE(ret)), errorFlag = true);
     131              : 
     132            0 :         TransportHeterog::RecordRankTableCrc(rankInfo.params.ranktableCrc);
     133              : 
     134              :         // 打印rankTable信息
     135            0 :         ret = ShowRanktableConfigInfo(rankInfo.cloudFlag, rankInfo.params, rankInfo.rankTable);
     136            0 :         CHK_PRT_BREAK(ret != HCCL_SUCCESS, HCCL_ERROR("[Init][HccdComm]errNo[0x%016llx] put ranktable info error",
     137              :             HCCL_ERROR_CODE(ret)), errorFlag = true);
     138              : 
     139            0 :         *comm = pComm;
     140              :     } while (0);
     141              : 
     142            0 :     if (errorFlag) {
     143            0 :         HCCL_ERROR("[Init][CommClusterInfo]HeterogCommClusterInfto failed, return[0x%016llx]", HCCL_ERROR_CODE(ret));
     144            0 :         (void)HcclFinalizeComm(pComm);
     145            0 :         return ret;
     146              :     }
     147              : 
     148            0 :     HCCL_RUN_INFO("HcclInitComm success,take time [%lld]us, collectiveId[%s], rankSize[%u], rank[%u]",
     149              :         TAKE_TIME_US((TIME_NOW() - startut), (TIME_THREE_TIMEGAP * timeGap)), pComm->GetIdentifier().c_str(),
     150              :         rankInfo.rankTable.rankNum, rank);
     151            0 :     return HCCL_SUCCESS;
     152            0 : }
     153              : 
     154            0 : HcclResult HcclInitComm(const char* rankTableM, uint32_t rank, const CommAttr* attr, HcclComm* comm)
     155              : {
     156            0 :     HccdInfo rankInfo;
     157            0 :     return HcclInitComm(rankTableM, rank, attr, comm, rankInfo);
     158            0 : }
     159              : 
     160            0 : HcclResult HcclFinalizeComm(HcclComm comm)
     161              : {
     162            0 :     HcclUs startut = TIME_NOW();
     163            0 :     auto timeGap = TIME_NOW() - startut;
     164            0 :     u32 rankSize = 0;
     165            0 :     u32 rank = 0;
     166              :     // 入参检查
     167            0 :     CHK_PRT_RET(
     168              :         comm == nullptr, HCCL_WARNING("[Destroy][HcclHeterogComm]An empty comm given, skip destroy."), HCCL_SUCCESS);
     169              :     // 指针类型转换hcclComm*<-void*
     170            0 :     hccl::HccdComm* hccdComm = static_cast<hccl::HccdComm *>(comm);
     171            0 :     HCCL_RUN_INFO("Entry-HcclFinalizeComm: comm[%p].", comm);
     172              : 
     173            0 :     HcclResult ret = HCCL_SUCCESS;
     174            0 :     bool errorFlag = false;
     175              :     do {
     176              :         // 记录打印信息
     177            0 :         ret = hccdComm->GetUserRank(rank);
     178            0 :         CHK_PRT_BREAK(ret != HCCL_SUCCESS, HCCL_ERROR("[Finalize][HccdComm]errNo[0x%016llx] get user rank error.",
     179              :             HCCL_ERROR_CODE(ret)), errorFlag = true);
     180            0 :         ret = hccdComm->GetRankSize(rankSize);
     181            0 :         CHK_PRT_BREAK(ret != HCCL_SUCCESS, HCCL_ERROR("[Finalize][HccdComm]errNo[0x%016llx] get rank size error.",
     182              :             HCCL_ERROR_CODE(ret)), errorFlag = true);
     183              :     } while (0);
     184              : 
     185            0 :     std::string collectiveId = hccdComm->GetIdentifier();
     186              :     // 模型运行结束后hcom destroy时,将记录的rank table crc置为0
     187            0 :     TransportHeterog::RecordRankTableCrc(0);
     188              : 
     189              :     // 释放资源
     190            0 :     delete hccdComm;
     191            0 :     hccdComm = nullptr;
     192              : 
     193            0 :     if (errorFlag) {
     194            0 :         HCCL_ERROR("[Finalize][HccdComm]HcclFinalizeComm failed, return[0x%016llx].", HCCL_ERROR_CODE(ret));
     195            0 :         return ret;
     196              :     }
     197              : 
     198            0 :     HcclUs endut = TIME_NOW();
     199              :     /* 关键状态记录 */
     200            0 :     HCCL_RUN_INFO("HcclFinalizeComm success, take time [%lld]us, collectiveId[%s], rankSize[%u], rank[%u].",
     201              :         TAKE_TIME_US((endut - startut), (TIME_THREE_TIMEGAP * timeGap)), collectiveId.c_str(), rankSize, rank);
     202            0 :     return HCCL_SUCCESS;
     203            0 : }
     204              : 
     205              : // 注册全局内存,全进程共享,以优化RDMA性能
     206            0 : HcclResult HcclRegisterMemory(HcclComm comm, void* buffer, uint64_t size)
     207              : {
     208            0 :     CHK_PTR_NULL(comm);
     209            0 :     CHK_PTR_NULL(buffer);
     210            0 :     HcclUs startut = TIME_NOW();
     211              : 
     212            0 :     hccl::HccdComm* hccdComm = static_cast<hccl::HccdComm *>(comm);
     213            0 :     u32 localRank = INVALID_VALUE_RANKID;
     214            0 :     CHK_RET(hccdComm->GetUserRank(localRank));
     215            0 :     HCCL_RUN_INFO("Entry-HcclRegisterMemory: comm[%s], addr[%p], size[%llu] localRank[%u].",
     216              :         hccdComm->GetIdentifier().c_str(), buffer, size, localRank);
     217              : 
     218            0 :     CHK_RET(hccdComm->RegisterMemory(buffer, size));
     219              : 
     220            0 :     HCCL_RUN_INFO("Hccl Register Memory success, take time [%lld]us, addr[%p], size[%llu].",
     221              :         DURATION_US(TIME_NOW() - startut), buffer, size);
     222            0 :     return HCCL_SUCCESS;
     223              : }
     224              : 
     225              : // 解注册全局内存,全进程共享,以优化RDMA性能
     226            0 : HcclResult HcclUnregisterMemory(HcclComm comm, void* buffer)
     227              : {
     228            0 :     CHK_PTR_NULL(comm);
     229            0 :     CHK_PTR_NULL(buffer);
     230            0 :     HcclUs startut = TIME_NOW();
     231              : 
     232            0 :     hccl::HccdComm* hccdComm = static_cast<hccl::HccdComm *>(comm);
     233            0 :     u32 localRank = INVALID_VALUE_RANKID;
     234            0 :     CHK_RET(hccdComm->GetUserRank(localRank));
     235            0 :     HCCL_RUN_INFO("Entry-HcclUnregisterMemory: comm[%s], addr[%p], localRank[%u].",
     236              :         hccdComm->GetIdentifier().c_str(), buffer, localRank);
     237              : 
     238            0 :     CHK_RET(hccdComm->UnregisterMemory(buffer));
     239              : 
     240            0 :     HCCL_RUN_INFO("Hccl Unregister Memory success, take time [%lld]us, addr[%p].",
     241              :         DURATION_US(TIME_NOW() - startut), buffer);
     242            0 :     return HCCL_SUCCESS;
     243              : }
     244              : 
     245              : // 以进程粒度注册全局内存,多Server场景使用
     246            0 : HcclResult HcclRegisterGlobalMemory(void* addr, u64 size)
     247              : {
     248            0 :     CHK_PTR_NULL(addr);
     249            0 :     HcclUs startut = TIME_NOW();
     250            0 :     HcclResult ret = MrManager::GetInstance().RegGlobalMr(addr, size);
     251            0 :     CHK_PRT_RET(ret != HCCL_SUCCESS,
     252              :         HCCL_ERROR("[HcclRegisterGlobalMemory]errNo[0x%016llx] Hccl Register Global Memory failed, size[%llu].",
     253              :         HCCL_ERROR_CODE(ret), size), ret);
     254            0 :     HCCL_INFO("Hccl Register Global success, take time [%lld]us.",
     255              :         DURATION_US(TIME_NOW() - startut));
     256            0 :     return HCCL_SUCCESS;
     257              : }
     258              : 
     259              : // 以进程粒度注销全局内存,多Server场景使用
     260            0 : HcclResult HcclUnregisterGlobalMemory(void* addr)
     261              : {
     262            0 :     CHK_PTR_NULL(addr);
     263            0 :     HcclUs startut = TIME_NOW();
     264            0 :     HcclResult ret = MrManager::GetInstance().DeRegGlobalMr(addr);
     265            0 :     CHK_PRT_RET(ret != HCCL_SUCCESS,
     266              :         HCCL_ERROR("[HcclUnregisterGlobalMemory]errNo[0x%016llx] Hccl Unregister Global Memory failed.",
     267              :         HCCL_ERROR_CODE(ret)), ret);
     268            0 :     HCCL_INFO("Hccl Unregister Global success, take time [%lld]us.",
     269              :         DURATION_US(TIME_NOW() - startut));
     270            0 :     return HCCL_SUCCESS;
     271              : }
     272              : 
     273              : // 异步发送数据,发送完成后会通过event上报完成状态。根据{commHandle, dstRank, tag}为粒度,顺序发送。不同的颗粒间可并行。
     274            0 : int HcclIsend(void* buffer, int count, HcclDataType dataType, int dstRank, int tag, HcclComm comm,
     275              :     HcclRequest* request)
     276              : {
     277            0 :     CHK_PTR_NULL(comm);
     278            0 :     CHK_PTR_NULL(request);
     279            0 :     CHK_PRT_RET(buffer == nullptr && count != 0, HCCL_ERROR("HcclIsend failed, buffer is nullptr, count is %d", count),
     280              :         HCCL_E_PARA);
     281              : 
     282            0 :     hccl::HccdComm* hccdComm = static_cast<hccl::HccdComm *>(comm);
     283            0 :     u32 localRank = INVALID_VALUE_RANKID;
     284            0 :     u32 userRequire = 0;
     285            0 :     CHK_RET(hccdComm->GetUserRank(localRank));
     286              : 
     287              :     /* 接口交互信息日志 */
     288            0 :     HCCL_INFO("Entry-HcclIsend: comm[%s] localRank[%u] dstRank[%d] tag[%d]: addr[%p] count[%d] dtype[%s] "\
     289              :         "request[%p]", hccdComm->GetIdentifier().c_str(), localRank, dstRank, tag, buffer, count,
     290              :         GetDataTypeEnumStr(dataType).c_str(), request);
     291              : 
     292            0 :     TIME_PRINT(CHK_RET(hccdComm->Isend(buffer, count, dataType, static_cast<u32>(dstRank), tag, *request, userRequire)));
     293              : 
     294              :     /* 关键状态记录 */
     295            0 :     HCCL_INFO("HcclIsend success. comm[%s] localRank[%u] dstRank[%d] tag[%d]: addr[%p] count[%d] dtype[%s] "\
     296              :         "*request[%p].", hccdComm->GetIdentifier().c_str(), localRank, dstRank, tag, buffer, count,
     297              :         GetDataTypeEnumStr(dataType).c_str(), *request);
     298            0 :     return HCCL_SUCCESS;
     299              : }
     300              : 
     301              : // 类mpi 查询已捕获的recv request操作信息,根据{commHandle, peerRank, tag}为粒度,按照recv request接收顺序依次返回已捕获的
     302            0 : int HcclImprobe(int srcRank, int tag, HcclComm comm, int* flag, HcclMessage* msg, HcclStatus* status)
     303              : {
     304              :     // 入参校验
     305            0 :     CHK_PTR_NULL(comm);
     306            0 :     CHK_PTR_NULL(flag);
     307            0 :     CHK_PTR_NULL(msg);
     308            0 :     CHK_PTR_NULL(status);
     309              : 
     310              :     // 关键日志记录
     311            0 :     hccl::HccdComm* hccdComm = static_cast<hccl::HccdComm *>(comm);
     312            0 :     u32 localRank = INVALID_VALUE_RANKID;
     313            0 :     CHK_RET(hccdComm->GetUserRank(localRank));
     314            0 :     HCCL_INFO("Entry-HcclImprobe: comm[%s] srcRank[%d] localRank[%u] tag[%d]",
     315              :         hccdComm->GetIdentifier().c_str(), srcRank, localRank, tag);
     316              :     // 获取 recv request entry
     317            0 :     CHK_RET(hccdComm->Improbe(static_cast<u32>(srcRank), tag, *flag,
     318              :         *msg, *status));
     319            0 :     HcclMessageInfo* hcclMsg = static_cast<HcclMessageInfo *>(*msg);
     320            0 :     if (*flag == HCCL_IMPROBE_COMPLETED) {
     321            0 :         hcclMsg->commHandle = comm;
     322              :     }
     323              :     // 关键日志记录
     324            0 :     HCCL_INFO("HcclImprobe success. comm[%s] srcRank[%d] localRank[%u] tag[%d]: flag[%d] status[%d] count[%d] msg[%p].",
     325              :         hccdComm->GetIdentifier().c_str(), srcRank, localRank, tag, *flag, status->error, status->count, *msg);
     326            0 :     return HCCL_SUCCESS;
     327              : }
     328              : 
     329            0 : int HcclGetCount(const HcclStatus *status, HcclDataType dataType, int *count)
     330              : {
     331              :        // 入参校验
     332            0 :     CHK_PTR_NULL(status);
     333            0 :     CHK_PTR_NULL(count);
     334              : 
     335            0 :     if (status->error != 0) {
     336            0 :         HCCL_WARNING("GetCount::Failed to obtain the count status[%d].", status->error);
     337            0 :         return HCCL_E_PARA;
     338              :     }
     339              : 
     340            0 :     *count = status->count;
     341              : 
     342              :      // 关键日志记录
     343            0 :     HCCL_INFO("HcclGetCount success. peerRank[%d] tag[%d] status[%d] dataType[%s] count[%d].",
     344              :         status->srcRank, status->tag, status->error, GetDataTypeEnumStr(dataType).c_str(), *count);
     345            0 :     return HCCL_SUCCESS;
     346              : }
     347              : 
     348            0 : int HcclImrecv(void* buffer, int count, HcclDataType dataType, HcclMessage* msg, HcclRequest* request)
     349              : {
     350            0 :     CHK_PTR_NULL(msg);
     351            0 :     CHK_PTR_NULL(*msg);
     352            0 :     CHK_PTR_NULL(request);
     353              : 
     354            0 :     HcclMessageInfo* hcclMsg = static_cast<HcclMessageInfo *>(*msg);
     355            0 :     hccl::HccdComm* hccdComm = static_cast<hccl::HccdComm *>(hcclMsg->commHandle);
     356            0 :     CHK_PTR_NULL(hccdComm);
     357            0 :     uint32_t peerRank = hcclMsg->envelope.envelope.epParam.src.rank;
     358            0 :     uint32_t tag = hcclMsg->envelope.envelope.epParam.src.tag;
     359              :     /* 接口交互信息日志 */
     360            0 :     HCCL_INFO("Entry-HcclImrecv: comm[%s] peerRank[%u] tag[%u]: addr[%p] count[%d] dtype[%s] msg[%p]",
     361              :         hccdComm->GetIdentifier().c_str(), peerRank, tag, buffer, count, GetDataTypeEnumStr(dataType).c_str(), *msg);
     362              : 
     363            0 :     TIME_PRINT(CHK_RET(hccdComm->Imrecv(buffer, count, dataType, *msg, *request)));
     364              : 
     365            0 :     HcclRequestInfo* hcclReq = static_cast<HcclRequestInfo *>(*request);
     366            0 :     hcclReq->commHandle = hccdComm;
     367              :     /* 关键状态记录 */
     368            0 :     HCCL_INFO("HcclImrecv success. comm[%s] peerRank[%u] tag[%u]: addr[%p] count[%d] dtype[%s] msg[%p] request[%p].",
     369              :         hccdComm->GetIdentifier().c_str(), peerRank, tag, buffer, count, GetDataTypeEnumStr(dataType).c_str(), *msg,
     370              :         *request);
     371            0 :     return HCCL_SUCCESS;
     372              : }
     373              : 
     374            0 : int HcclTestSome(int count, HcclRequest requestArray[], int* compCount,
     375              :     int compIndices[], HcclStatus compStatus[])
     376              : {
     377              :     // 入参校验
     378            0 :     CHK_PTR_NULL(compCount);
     379            0 :     CHK_PTR_NULL(requestArray);
     380            0 :     CHK_PTR_NULL(compIndices);
     381            0 :     CHK_PTR_NULL(compStatus);
     382              : 
     383            0 :     *compCount = 0;
     384            0 :     bool errorFlag = false;
     385            0 :     HcclResult ret = HCCL_SUCCESS;
     386            0 :     for (int i = 0; i < count; ++i) {
     387            0 :         HcclRequestInfo *hcclReq = reinterpret_cast<HcclRequestInfo *>(requestArray[i]);
     388            0 :         if (hcclReq == nullptr) {
     389            0 :             HCCL_WARNING("[%d]th hcclRequest is nullptr, no need to testSome", i);
     390            0 :             continue;
     391              :         }
     392              : 
     393            0 :         hccl::HccdComm* hccdComm = reinterpret_cast<hccl::HccdComm *>(hcclReq->commHandle);
     394            0 :         CHK_PTR_NULL(hccdComm);
     395            0 :         s32 comp = HCCL_TEST_INCOMPLETED;
     396            0 :         ret = hccdComm->HcclTest(requestArray[i], comp, compStatus[*compCount]);
     397            0 :         if (ret != HCCL_SUCCESS) {
     398            0 :             compStatus[*compCount].error = GetExternalInputHcclIsTcpMode() ?
     399              :                 HCCL_E_TCP_TRANSFER : HCCL_E_ROCE_TRANSFER;
     400            0 :             compIndices[*compCount] = i;
     401            0 :             errorFlag = true;
     402            0 :             (*compCount)++;
     403            0 :         } else if (comp == HCCL_TEST_COMPLETED) {
     404            0 :             requestArray[i] = nullptr;
     405            0 :             compIndices[*compCount] = i;
     406            0 :             compStatus[*compCount].error = HCCL_SUCCESS;
     407            0 :             (*compCount)++;
     408              :         }
     409            0 :         HCCL_INFO("HcclTestSome: array[%d/%d] request[%p] comm[%s] peerRank[%u] tag[%d] type[%u] flag[%d] "
     410              :             "compCount[%d] status[%d]", i + 1, count, hcclReq, hccdComm->GetIdentifier().c_str(),
     411              :             hcclReq->transportRequest.epParam.src.rank, hcclReq->transportRequest.epParam.src.tag,
     412              :             hcclReq->transportRequest.requestType, comp, *compCount, hcclReq->transportRequest.status);
     413              :     }
     414            0 :     if (errorFlag) {
     415            0 :         HCCL_ERROR("HcclTestSome: some request link is exception");
     416            0 :         return HCCL_E_IN_STATUS;
     417              :     }
     418            0 :     return HCCL_SUCCESS;
     419              : }
        

Generated by: LCOV version 2.0-1