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

Generated by: LCOV version 2.0-1