LCOV - code coverage report
Current view: top level - legacy/ascend910/platform/common - dlhns_function.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 22.6 % 31 7
Test Date: 2026-08-18 17:47:01 Functions: 42.9 % 7 3

            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 "dlhns_function.h"
      12              : 
      13              : #include <string>
      14              : #include <map>
      15              : #include "hccl_dl.h"
      16              : #include "log.h"
      17              : 
      18              : namespace hccl {
      19              : 
      20            5 : DlHnsFunction& DlHnsFunction::GetInstance()
      21              : {
      22            5 :     static DlHnsFunction hcclDlHnsFunction;
      23            5 :     return hcclDlHnsFunction;
      24              : }
      25              : 
      26            2 : DlHnsFunction::DlHnsFunction() : handle_(nullptr) {}
      27              : 
      28            2 : DlHnsFunction::~DlHnsFunction()
      29              : {
      30            2 :     if (handle_ != nullptr) {
      31            0 :         (void)HcclDlclose(handle_);
      32            0 :         handle_ = nullptr;
      33              :     }
      34            2 : }
      35              : 
      36            0 : HcclResult DlHnsFunction::DlHnsFunctionRoceInit()
      37              : {
      38            0 :     dlHnsIbvExtPostSend = (int (*)(
      39              :         struct ibv_qp*, struct ibv_send_wr*, struct ibv_send_wr**, struct IbvPostSendExtAddt*,
      40            0 :         struct IbvPostSendExtResp*))HcclDlsym(handle_, "ibv_ext_post_send");
      41            0 :     CHK_SMART_PTR_NULL(dlHnsIbvExtPostSend);
      42              : 
      43              :     dlHnsIbvExpPostSend
      44            0 :         = (int (*)(struct ibv_qp*, struct ibv_send_wr*, struct ibv_send_wr**, struct WrExpRsp*))HcclDlsym(
      45            0 :             handle_, "ibv_exp_post_send");
      46            0 :     CHK_SMART_PTR_NULL(dlHnsIbvExpPostSend);
      47            0 :     return HCCL_SUCCESS;
      48              : }
      49              : 
      50            0 : HcclResult DlHnsFunction::DlHnsFunctionSoInit()
      51              : {
      52            0 :     if (handle_ == nullptr) {
      53            0 :         handle_ = HcclDlopen("libhns-rdmav25.so", RTLD_NOW);
      54            0 :         if (handle_ != nullptr) {
      55            0 :             return HCCL_SUCCESS;
      56              :         }
      57            0 :         return HCCL_E_INTERNAL;
      58              :     } else {
      59            0 :         HCCL_INFO("roce_user_api dlopen again!");
      60              :     }
      61            0 :     return HCCL_SUCCESS;
      62              : }
      63              : 
      64            0 : HcclResult DlHnsFunction::DlHnsFunctionInit()
      65              : {
      66            0 :     std::lock_guard<std::mutex> lock(handleMutex_);
      67            0 :     CHK_RET(DlHnsFunctionSoInit());
      68            0 :     CHK_RET(DlHnsFunctionRoceInit());
      69              : 
      70            0 :     return HCCL_SUCCESS;
      71            0 : }
      72              : 
      73              : } // namespace hccl
        

Generated by: LCOV version 2.0-1