LCOV - code coverage report
Current view: top level - legacy/ascend910/hccd - hccl_raw.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 160 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/hccl_ex.h"
      12              : #include "hccl_types.h"
      13              : #include "hccl_comm_conn.h"
      14              : #include "hccl_comm_conn_mgr.h"
      15              : 
      16              : using namespace std;
      17              : using namespace hccl;
      18              : 
      19            0 : HcclResult HcclRawOpen(HcclConn* conn)
      20              : {
      21            0 :     CHK_PTR_NULL(conn);
      22              : 
      23            0 :     HCCL_RUN_INFO("Entry %s start conn[%llu]", __func__, hash<HcclConn *>{}(conn));
      24            0 :     HcclCommConn **comm = reinterpret_cast<HcclCommConn **>(conn);
      25            0 :     CHK_RET(HcclCommConnMgr::GetInstance().AddAndGetCommConn(*comm));
      26            0 :     HCCL_RUN_INFO("%s success conn[%llu]", __func__, hash<void *>{}(*comm));
      27              : 
      28            0 :     return HCCL_SUCCESS;
      29              : }
      30              : 
      31            0 : HcclResult HcclRawClose(HcclConn conn)
      32              : {
      33            0 :     CHK_PTR_NULL(conn);
      34              : 
      35            0 :     HCCL_RUN_INFO("Entry %s start conn[%llu]", __func__, hash<void *>{}(conn));
      36            0 :     HcclCommConn *comm = static_cast<HcclCommConn *>(conn);
      37            0 :     CHK_RET(HcclCommConnMgr::GetInstance().DelCommConn(comm));
      38            0 :     HCCL_RUN_INFO("%s success conn[%llu]", __func__, hash<void *>{}(conn));
      39              : 
      40            0 :     return HCCL_SUCCESS;
      41              : }
      42              : 
      43            0 : HcclResult HcclRawForceClose(HcclConn conn)
      44              : {
      45            0 :     CHK_PTR_NULL(conn);
      46              : 
      47            0 :     HCCL_RUN_INFO("Entry %s start conn[%llu]", __func__, hash<void *>{}(conn));
      48            0 :     HcclCommConn *comm = static_cast<HcclCommConn *>(conn);
      49            0 :     comm->SetForceClose();
      50            0 :     CHK_RET(HcclCommConnMgr::GetInstance().DelCommConn(comm));
      51            0 :     HCCL_RUN_INFO("%s success conn[%llu]", __func__, hash<void *>{}(conn));
      52              : 
      53            0 :     return HCCL_SUCCESS;
      54              : }
      55              : 
      56              : 
      57            0 : HcclResult HcclRawConnect(HcclConn conn, HcclAddr* connectAddr)
      58              : {
      59            0 :     CHK_PTR_NULL(conn);
      60            0 :     CHK_PTR_NULL(connectAddr);
      61              : 
      62            0 :     HCCL_DEBUG("Entry %s start", __func__);
      63            0 :     if (HcclCommConnMgr::GetInstance().IsExistCommConn(*connectAddr)) {
      64            0 :         HCCL_ERROR("cur client to remote ip[%s] port[%u] comm conn is exist.",
      65              :             HcclIpAddress((*connectAddr).info.tcp.ipv4Addr).GetReadableIP(), (*connectAddr).info.tcp.port);
      66            0 :         return HCCL_E_UNAVAIL;
      67              :     }
      68              :  
      69            0 :     if (HcclCommConnMgr::GetInstance().IsExceedMaxLinkNum(CLIENT_ROLE_SOCKET)) {
      70            0 :         HCCL_ERROR("The maximum number of communication connections that can be created is %u.", MAX_CONN_LINK_NUM);
      71            0 :         return HCCL_E_UNAVAIL;
      72              :     }
      73            0 :     HcclCommConn *comm = static_cast<HcclCommConn *>(conn);
      74            0 :     CHK_RET(comm->Connect(*connectAddr));
      75            0 :     HcclCommConnMgr::GetInstance().InsertConnectCommMap(*connectAddr, conn);
      76            0 :     HCCL_RUN_INFO("%s success conn[%llu] connectAddr[%llu]",
      77              :         __func__, hash<void *>{}(conn), hash<HcclAddr *>{}(connectAddr));
      78              : 
      79            0 :     return HCCL_SUCCESS;
      80              : }
      81              : 
      82            0 : HcclResult HcclRawBind(HcclConn conn, HcclAddr* bindAddr)
      83              : {
      84            0 :     CHK_PTR_NULL(conn);
      85            0 :     CHK_PTR_NULL(bindAddr);
      86              : 
      87            0 :     HCCL_RUN_INFO("Entry %s start", __func__);
      88            0 :     HcclCommConn *comm = static_cast<HcclCommConn *>(conn);
      89            0 :     CHK_RET(comm->Bind(*bindAddr));
      90            0 :     HCCL_RUN_INFO("%s success conn[%llu] bindAddr[%llu]",
      91              :         __func__, hash<void *>{}(conn), hash<HcclAddr *>{}(bindAddr));
      92              : 
      93            0 :     return HCCL_SUCCESS;
      94              : }
      95              : 
      96            0 : HcclResult HcclRawListen(HcclConn conn, int backLog)
      97              : {
      98            0 :     CHK_PTR_NULL(conn);
      99              : 
     100            0 :     HCCL_RUN_INFO("Entry %s start conn[%llu]", __func__, hash<void *>{}(conn));
     101            0 :     HcclCommConn *comm = static_cast<HcclCommConn *>(conn);
     102            0 :     CHK_RET(comm->Listen(backLog));
     103            0 :     HCCL_RUN_INFO("%s success", __func__);
     104              : 
     105            0 :     return HCCL_SUCCESS;
     106              : }
     107              : 
     108            0 : HcclResult HcclRawAccept(HcclConn conn, HcclAddr* acceptAddr, HcclConn* acceptConn)
     109              : {
     110            0 :     CHK_PTR_NULL(conn);
     111            0 :     CHK_PTR_NULL(acceptAddr);
     112            0 :     CHK_PTR_NULL(acceptConn);
     113              : 
     114            0 :     HCCL_DEBUG("Entry %s start", __func__);
     115            0 :     HcclCommConn *comm = static_cast<HcclCommConn *>(conn);
     116            0 :     HcclCommConn **newConn = reinterpret_cast<HcclCommConn **>(acceptConn);
     117              : 
     118            0 :     CHK_RET(comm->Accept(*acceptAddr, *newConn));
     119            0 :     CHK_RET(HcclCommConnMgr::GetInstance().AddCommConn(*newConn));
     120            0 :     HCCL_RUN_INFO("%s success conn[%llu] acceptAddr[%llu] acceptConn[%llu]",
     121              :         __func__, hash<void *>{}(conn), hash<HcclAddr *>{}(acceptAddr), hash<void *>{}(*newConn));
     122              : 
     123            0 :     return HCCL_SUCCESS;
     124              : }
     125              : 
     126            0 : HcclResult HcclRawIsend(const void* buf, int count, HcclDataType dataType, HcclConn conn, HcclRequest* request)
     127              : {
     128            0 :     CHK_PTR_NULL(conn);
     129            0 :     CHK_PTR_NULL(request);
     130              : 
     131            0 :     HCCL_DEBUG("Entry %s start", __func__);
     132            0 :     HcclCommConn *comm = static_cast<HcclCommConn *>(conn);
     133            0 :     CHK_RET(comm->Isend(buf, count, dataType, *request));
     134            0 :     HcclRequestInfo* hcclReq = static_cast<HcclRequestInfo *>(*request);
     135            0 :     hcclReq->commHandle = comm;
     136            0 :     HCCL_DEBUG("%s success", __func__);
     137              : 
     138            0 :     return HCCL_SUCCESS;
     139              : }
     140              : 
     141            0 : HcclResult HcclRawImprobe(HcclConn conn, int* flag, HcclMessage* msg, HcclStatus* status)
     142              : {
     143            0 :     CHK_PTR_NULL(conn);
     144            0 :     CHK_PTR_NULL(flag);
     145            0 :     CHK_PTR_NULL(msg);
     146            0 :     CHK_PTR_NULL(status);
     147              : 
     148            0 :     HCCL_DEBUG("Entry %s start", __func__);
     149            0 :     HcclCommConn *comm = static_cast<HcclCommConn *>(conn);
     150            0 :     CHK_RET(comm->Improbe(*flag, *msg, *status));
     151            0 :     HcclMessageInfo* hcclMsg = static_cast<HcclMessageInfo *>(*msg);
     152            0 :     if (*flag == HCCL_IMPROBE_COMPLETED) {
     153            0 :         hcclMsg->commHandle = comm;
     154              :     }
     155            0 :     HCCL_DEBUG("%s success", __func__);
     156              : 
     157            0 :     return HCCL_SUCCESS;
     158              : }
     159            0 : HcclResult HcclRawImrecv(void* buf, int count, HcclDataType datatype, HcclMessage* msg, HcclRequest* request)
     160              : {
     161            0 :     CHK_PTR_NULL(msg);
     162            0 :     CHK_PTR_NULL(*msg);
     163            0 :     CHK_PTR_NULL(request);
     164              : 
     165            0 :     HCCL_DEBUG("Entry %s start", __func__);
     166            0 :     HcclMessageInfo* hcclMsg = static_cast<HcclMessageInfo *>(*msg);
     167            0 :     HcclCommConn *comm = static_cast<HcclCommConn *>(hcclMsg->commHandle);
     168            0 :     CHK_RET(comm->Imrecv(buf, count, datatype, *msg, *request));
     169            0 :     HcclRequestInfo* hcclReq = static_cast<HcclRequestInfo *>(*request);
     170            0 :     hcclReq->commHandle = comm;
     171            0 :     *msg = nullptr;
     172            0 :     HCCL_DEBUG("%s success", __func__);
     173              : 
     174            0 :     return HCCL_SUCCESS;
     175              : }
     176              : 
     177            0 : HcclResult HcclRawImrecvScatter(void *buf[], int count[], int bufCount, HcclDataType datatype, HcclMessage *msg,
     178              :     HcclRequest *request)
     179              : {
     180            0 :     CHK_PTR_NULL(buf);
     181            0 :     CHK_PTR_NULL(count);
     182            0 :     CHK_PTR_NULL(msg);
     183            0 :     CHK_PTR_NULL(*msg);
     184            0 :     CHK_PTR_NULL(request);
     185              : 
     186            0 :     if (bufCount > MAX_SCATTER_BUF_NUM) {
     187            0 :         HCCL_ERROR("bufCount[%d] should less than %d", bufCount, MAX_SCATTER_BUF_NUM);
     188            0 :         return HCCL_E_PARA;
     189              :     }
     190              : 
     191            0 :     HCCL_DEBUG("Entry %s start", __func__);
     192            0 :     HcclMessageInfo *hcclMsg = static_cast<HcclMessageInfo *>(*msg);
     193            0 :     HcclCommConn *comm = static_cast<HcclCommConn *>(hcclMsg->commHandle);
     194            0 :     CHK_RET(comm->ImrecvScatter(buf, count, bufCount, datatype, *msg, *request));
     195            0 :     HcclRequestInfo *hcclReq = static_cast<HcclRequestInfo *>(*request);
     196            0 :     hcclReq->commHandle = comm;
     197            0 :     *msg = nullptr;
     198              : 
     199            0 :     return HCCL_SUCCESS;
     200              : }
     201              : 
     202            0 : HcclResult HcclRawGetCount(const HcclStatus* status, HcclDataType dataType, int* count)
     203              : {
     204              :     // 入参校验
     205            0 :     CHK_PTR_NULL(status);
     206            0 :     CHK_PTR_NULL(count);
     207              : 
     208            0 :     HCCL_DEBUG("Entry %s start", __func__);
     209            0 :     if (status->error != 0) {
     210            0 :         HCCL_WARNING("Failed to obtain the count status[%d].", status->error);
     211            0 :         return HCCL_E_PARA;
     212              :     }
     213              : 
     214            0 :     *count = status->count;
     215            0 :     HCCL_DEBUG("%s success. peerRank[%d] tag[%d] status[%d] dataType[%s] count[%d].",
     216              :         __func__, status->srcRank, status->tag, status->error, GetDataTypeEnumStr(dataType).c_str(), *count);
     217              : 
     218            0 :     return HCCL_SUCCESS;
     219              : }
     220              : 
     221            0 : HcclResult HcclRawTestSome(int count, HcclRequest requestArray[], int* compCount,
     222              :     int compIndices[], HcclStatus compStatus[])
     223              : {
     224              :     // 入参校验
     225            0 :     CHK_PTR_NULL(compCount);
     226            0 :     CHK_PTR_NULL(requestArray);
     227            0 :     CHK_PTR_NULL(compIndices);
     228            0 :     CHK_PTR_NULL(compStatus);
     229              : 
     230            0 :     HCCL_DEBUG("Entry %s start", __func__);
     231            0 :     *compCount = 0;
     232            0 :     bool errorFlag = false;
     233            0 :     HcclResult ret = HCCL_SUCCESS;
     234            0 :     for (int i = 0; i < count; ++i) {
     235            0 :         HcclRequestInfo *hcclReq = reinterpret_cast<HcclRequestInfo *>(requestArray[i]);
     236            0 :         if (hcclReq == nullptr) {
     237            0 :             HCCL_INFO("[%d]th hcclRequest is nullptr, no need to testSome", i);
     238            0 :             continue;
     239              :         }
     240              : 
     241            0 :         HcclCommConn* comm = reinterpret_cast<hccl::HcclCommConn *>(hcclReq->commHandle);
     242            0 :         CHK_PTR_NULL(comm);
     243              : 
     244            0 :         s32 comp = HCCL_TEST_INCOMPLETED;
     245            0 :         ret = comm->Test(requestArray[i], comp, compStatus[*compCount]);
     246            0 :         if (ret != HCCL_SUCCESS) {
     247            0 :             compStatus[*compCount].error = HCCL_E_ROCE_TRANSFER;
     248            0 :             compIndices[*compCount] = i;
     249            0 :             errorFlag = true;
     250            0 :             (*compCount)++;
     251            0 :         } else if (comp == HCCL_TEST_COMPLETED) {
     252            0 :             requestArray[i] = nullptr;
     253            0 :             compIndices[*compCount] = i;
     254            0 :             compStatus[*compCount].error = HCCL_SUCCESS;
     255            0 :             (*compCount)++;
     256              :         }
     257              : 
     258            0 :         HCCL_INFO("HcclRawTestSome: array[%d/%d] type[%u] flag[%d] compCount[%d] status[%d]",
     259              :             i + 1, count, hcclReq->transportRequest.requestType,
     260              :             comp, *compCount, hcclReq->transportRequest.status);
     261              :     }
     262              : 
     263            0 :     if (errorFlag) {
     264            0 :         HCCL_ERROR("HcclRawTestSome: some request link is exception");
     265            0 :         return HCCL_E_INTERNAL;
     266              :     }
     267              : 
     268            0 :     HCCL_DEBUG("%s success", __func__);
     269              : 
     270            0 :     return HCCL_SUCCESS;
     271              : }
        

Generated by: LCOV version 2.0-1