LCOV - code coverage report
Current view: top level - base_comm/common - dlurma_function.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 92.9 % 28 26
Test Date: 2026-08-18 17:47:01 Functions: 83.3 % 6 5

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 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 "dlurma_function.h"
      12              : #include "hccl_next_dl.h"
      13              : #include "log.h"
      14              : 
      15              : namespace hcomm {
      16            8 : DlUrmaFunction& DlUrmaFunction::GetInstance()
      17              : {
      18            8 :     static DlUrmaFunction hcclDlUrmaFunction;
      19            8 :     return hcclDlUrmaFunction;
      20              : }
      21              : 
      22            1 : DlUrmaFunction::DlUrmaFunction() : handle_(nullptr) {}
      23              : 
      24            1 : DlUrmaFunction::~DlUrmaFunction()
      25              : {
      26            1 :     std::lock_guard<std::mutex> lock(handleMutex_);
      27            1 :     if (handle_ != nullptr) {
      28            1 :         (void)HcclNextDlclose(handle_);
      29            1 :         handle_ = nullptr;
      30              :     }
      31            1 : }
      32              : 
      33            8 : HcclResult DlUrmaFunction::DlUrmaFunctionApiInit()
      34              : {
      35            0 :     dlUrmaPostJettySendWr = (urma_status_t(*)(urma_jetty_t * jetty, urma_jfs_wr_t * wr, urma_jfs_wr_t * *bad_wr))
      36            8 :         HcclNextDlsym(handle_, "urma_post_jetty_send_wr");
      37            8 :     CHK_SMART_PTR_NULL(dlUrmaPostJettySendWr);
      38              : 
      39            8 :     dlUrmaPollJfc = (int (*)(urma_jfc_t* jfc, int cr_cnt, urma_cr_t* cr))HcclNextDlsym(handle_, "urma_poll_jfc");
      40            8 :     CHK_SMART_PTR_NULL(dlUrmaPollJfc);
      41            8 :     return HCCL_SUCCESS;
      42              : }
      43              : 
      44            8 : HcclResult DlUrmaFunction::DlUrmaFunctionInit()
      45              : {
      46            8 :     std::lock_guard<std::mutex> lock(handleMutex_);
      47            8 :     if (handle_ == nullptr) {
      48            1 :         handle_ = HcclNextDlopen("liburma.so.0", RTLD_NOW);
      49            1 :         if (handle_ == nullptr) {
      50            0 :             handle_ = HcclNextDlopen("/lib64/liburma.so.0", RTLD_NOW);
      51              :         }
      52            1 :         const char* errMsg = dlerror();
      53            1 :         CHK_PRT_RET(
      54              :             handle_ == nullptr,
      55              :             HCCL_ERROR(
      56              :                 "dlopen [%s] failed, %s", "liburma.so.0",
      57              :                 (errMsg == nullptr) ? "please check the file exist or permission denied." : errMsg),
      58              :             HCCL_E_OPEN_FILE_FAILURE);
      59              :     }
      60              : 
      61            8 :     CHK_RET(DlUrmaFunctionApiInit());
      62            8 :     return HCCL_SUCCESS;
      63            8 : }
      64              : } // namespace hcomm
        

Generated by: LCOV version 2.0-1