LCOV - code coverage report
Current view: top level - base_comm/common - dlurma_function.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 93.3 % 30 28
Test Date: 2026-07-28 12:11:00 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 : }
      25              :  
      26            1 : DlUrmaFunction::~DlUrmaFunction()
      27              : {
      28            1 :     std::lock_guard<std::mutex> lock(handleMutex_);
      29            1 :     if (handle_ != nullptr) {
      30            1 :         (void)HcclNextDlclose(handle_);
      31            1 :         handle_ = nullptr;
      32              :     }
      33            1 : }
      34              :  
      35            8 : HcclResult DlUrmaFunction::DlUrmaFunctionApiInit()
      36              : {
      37            0 :     dlUrmaPostJettySendWr = (urma_status_t(*)(urma_jetty_t *jetty, urma_jfs_wr_t *wr, urma_jfs_wr_t **bad_wr))
      38            8 :         HcclNextDlsym(handle_, "urma_post_jetty_send_wr");
      39            8 :     CHK_SMART_PTR_NULL(dlUrmaPostJettySendWr);
      40              :  
      41           16 :     dlUrmaPollJfc = (int(*)(urma_jfc_t *jfc, int cr_cnt, urma_cr_t *cr))
      42            8 :         HcclNextDlsym(handle_, "urma_poll_jfc");
      43            8 :     CHK_SMART_PTR_NULL(dlUrmaPollJfc);
      44            8 :     return HCCL_SUCCESS;
      45              : }
      46              : 
      47            8 : HcclResult DlUrmaFunction::DlUrmaFunctionInit()
      48              : {
      49            8 :     std::lock_guard<std::mutex> lock(handleMutex_);
      50            8 :     if (handle_ == nullptr) {
      51            1 :         handle_ = HcclNextDlopen("liburma.so.0", RTLD_NOW);
      52            1 :         if (handle_ == nullptr) {
      53            0 :             handle_ = HcclNextDlopen("/lib64/liburma.so.0", RTLD_NOW);
      54              :         }
      55            1 :         const char* errMsg = dlerror();
      56            1 :         CHK_PRT_RET(handle_ == nullptr, HCCL_ERROR("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              : }
        

Generated by: LCOV version 2.0-1