LCOV - code coverage report
Current view: top level - legacy/ascend950/unified_platform/common - dlhal_function_v2.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 22.6 % 31 7
Test Date: 2026-08-18 17:47:01 Functions: 50.0 % 6 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 "dlhal_function_v2.h"
      12              : 
      13              : #include <string>
      14              : #include <map>
      15              : #include "log.h"
      16              : #include <dlfcn.h>
      17              : 
      18              : namespace Hccl {
      19            1 : DlHalFunctionV2& DlHalFunctionV2::GetInstance()
      20              : {
      21            1 :     static DlHalFunctionV2 hcclDlHalFunction;
      22            1 :     return hcclDlHalFunction;
      23              : }
      24              : 
      25            1 : DlHalFunctionV2::DlHalFunctionV2() : handle_(nullptr) {}
      26              : 
      27            1 : DlHalFunctionV2::~DlHalFunctionV2()
      28              : {
      29            1 :     if (handle_ != nullptr) {
      30            0 :         (void)dlclose(handle_);
      31            0 :         handle_ = nullptr;
      32              :     }
      33            1 : }
      34              : 
      35            0 : HcclResult DlHalFunctionV2::DlHalFunctionEschedInit()
      36              : {
      37            0 :     HCCL_INFO("DlHalFunctionEschedInit start");
      38            0 :     dlHalEschedSubmitEvent = (drvError_t(*)(unsigned int, struct event_summary*))dlsym(handle_, "halEschedSubmitEvent");
      39            0 :     CHK_SMART_PTR_NULL(dlHalEschedSubmitEvent);
      40              : 
      41            0 :     dlHalDrvQueryProcessHostPid = (drvError_t(*)(int, unsigned int*, unsigned int*, unsigned int*, unsigned int*))dlsym(
      42            0 :         handle_, "drvQueryProcessHostPid");
      43            0 :     CHK_SMART_PTR_NULL(dlHalDrvQueryProcessHostPid);
      44              : 
      45            0 :     dlHalGetDeviceInfo = (drvError_t(*)(uint32_t, int32_t, int32_t, int64_t*))dlsym(handle_, "halGetDeviceInfo");
      46            0 :     CHK_SMART_PTR_NULL(dlHalGetDeviceInfo);
      47              : 
      48            0 :     HCCL_INFO("DlHalFunction::DlHalFunctionEschedInit end");
      49              : 
      50            0 :     return HCCL_SUCCESS;
      51              : }
      52              : 
      53            0 : HcclResult DlHalFunctionV2::DlHalFunctionInit()
      54              : {
      55            0 :     HCCL_INFO("DlHalFunctionInit start");
      56            0 :     std::lock_guard<std::mutex> lock(handleMutex_);
      57            0 :     if (handle_ == nullptr) {
      58            0 :         handle_ = dlopen("libascend_hal.so", RTLD_NOW);
      59            0 :         const char* errMsg = dlerror();
      60            0 :         CHK_PRT_RET(
      61              :             handle_ == nullptr,
      62              :             HCCL_ERROR(
      63              :                 "dlopen [%s] failed, %s", "libascend_hal.so",
      64              :                 (errMsg == nullptr) ? "please check the file exist or permission denied." : errMsg),
      65              :             HCCL_E_OPEN_FILE_FAILURE);
      66              :     }
      67              : 
      68            0 :     CHK_RET(DlHalFunctionEschedInit());
      69            0 :     HCCL_INFO("DlHalFunction::DlHalFunctionInit end");
      70            0 :     return HCCL_SUCCESS;
      71            0 : }
      72              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1