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

Generated by: LCOV version 2.0-1