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: 24.2 % 33 8
Test Date: 2026-08-04 10:52:23 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 : }
      27              : 
      28            1 : DlHalFunctionV2::~DlHalFunctionV2()
      29              : {
      30            1 :         if (handle_ != nullptr) {
      31            0 :                 (void)dlclose(handle_);
      32            0 :                 handle_ = nullptr;
      33              :         }
      34            1 : }
      35              : 
      36            0 : HcclResult DlHalFunctionV2::DlHalFunctionEschedInit()
      37              : {
      38            0 :         HCCL_INFO("DlHalFunctionEschedInit start");
      39            0 :         dlHalEschedSubmitEvent = (drvError_t(*)(unsigned int, struct event_summary *))dlsym(handle_,
      40            0 :                 "halEschedSubmitEvent");
      41            0 :         CHK_SMART_PTR_NULL(dlHalEschedSubmitEvent);
      42              : 
      43            0 :         dlHalDrvQueryProcessHostPid = (drvError_t(*)(int, unsigned int*, unsigned int*, unsigned int*, unsigned int*))dlsym(handle_,
      44            0 :                 "drvQueryProcessHostPid");
      45            0 :         CHK_SMART_PTR_NULL(dlHalDrvQueryProcessHostPid);
      46              : 
      47            0 :         dlHalGetDeviceInfo = (drvError_t(*)(uint32_t, int32_t, int32_t, int64_t *))dlsym(handle_, "halGetDeviceInfo");
      48            0 :     CHK_SMART_PTR_NULL(dlHalGetDeviceInfo);
      49              : 
      50            0 :         HCCL_INFO("DlHalFunction::DlHalFunctionEschedInit end");
      51              : 
      52            0 :         return HCCL_SUCCESS;
      53              : }
      54              : 
      55            0 : HcclResult DlHalFunctionV2::DlHalFunctionInit()
      56              : {
      57            0 :         HCCL_INFO("DlHalFunctionInit start");
      58            0 :         std::lock_guard<std::mutex> lock(handleMutex_);
      59            0 :         if (handle_ == nullptr) {
      60            0 :                 handle_ = dlopen("libascend_hal.so", RTLD_NOW);
      61            0 :                 const char* errMsg = dlerror();
      62            0 :                 CHK_PRT_RET(handle_ == nullptr, HCCL_ERROR("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              : }
        

Generated by: LCOV version 2.0-1