LCOV - code coverage report
Current view: top level - legacy/ascend910/common/debug/profiling - dlrt_function.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 76.7 % 30 23
Test Date: 2026-08-04 10:52:23 Functions: 75.0 % 8 6

            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 "dlrt_function.h"
      12              : #include "log.h"
      13              : 
      14              : namespace hccl {
      15          310 : DlRtFunction &DlRtFunction::GetInstance()
      16              : {
      17          310 :     static DlRtFunction hcclDlRtFunction;
      18          310 :     return hcclDlRtFunction;
      19              : }
      20              : 
      21            8 : DlRtFunction::DlRtFunction()
      22              : {
      23            8 : }
      24              : 
      25            8 : DlRtFunction::~DlRtFunction()
      26              : {
      27            8 :     if (handle_ != nullptr) {
      28            0 :         (void)dlclose(handle_);
      29            0 :         handle_ = nullptr;
      30              :     }
      31            8 : }
      32              : 
      33            1 : rtError_t rtProfRegisterCtrlCallbackStub(uint32_t modelid, rtProfCtrlHandle callback)
      34              : {
      35            1 :     HCCL_WARNING("Entry rtProfRegisterCtrlCallbackStub");
      36            1 :     return RT_ERROR_NONE;
      37              : }
      38              : 
      39          309 : HcclResult DlRtFunction::DlRtFunctionStubInit()
      40              : {
      41          309 :     dlrtProfRegisterCtrlCallback = (rtError_t(*)(uint32_t, rtProfCtrlHandle))rtProfRegisterCtrlCallbackStub;
      42          309 :     return HCCL_SUCCESS;
      43              : }
      44              : 
      45            0 : HcclResult DlRtFunction::DlRtFunctionInterInit()
      46              : {
      47            0 :     dlrtProfRegisterCtrlCallback = (rtError_t(*)(uint32_t, rtProfCtrlHandle))dlsym(handle_,
      48            0 :         "rtProfRegisterCtrlCallback");
      49            0 :     return HCCL_SUCCESS;
      50              : }
      51              : 
      52          309 : HcclResult DlRtFunction::DlRtFunctionInit()
      53              : {
      54          309 :     std::lock_guard<std::mutex> lock(handleMutex_);
      55          309 :     if (handle_ == nullptr) {
      56          309 :         handle_ = dlopen("libruntime.so", RTLD_NOW);
      57              :     }
      58          309 :     if (handle_ != nullptr) {
      59            0 :         CHK_RET(DlRtFunctionInterInit());
      60              :     } else {
      61          309 :         CHK_RET(DlRtFunctionStubInit());
      62          309 :         HCCL_WARNING("dlopen libruntime.so failed");
      63              :     }
      64          309 :     return HCCL_SUCCESS;
      65          309 : }
      66              : }
        

Generated by: LCOV version 2.0-1