LCOV - code coverage report
Current view: top level - base_comm/resources/southbound_adpt - hcomm_adapter_runtime.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 77.8 % 18 14
Test Date: 2026-08-18 17:47:01 Functions: 100.0 % 1 1

            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 "hcomm_adapter_runtime.h"
      12              : 
      13              : #include "adapter_rts_common.h"
      14              : 
      15              : namespace hcomm {
      16              : 
      17              : constexpr uint32_t kDefaultResourceId = 0U;
      18              : 
      19          363 : HcclResult ResolveRuntimeDevicePhyId(uint32_t& devicePhyId, bool& noDevice)
      20              : {
      21          363 :     uint32_t deviceCount = 0;
      22          363 :     HcclResult ret = hrtGetDeviceCount(&deviceCount);
      23          363 :     if (ret != HCCL_SUCCESS) {
      24            0 :         HCCL_WARNING(
      25              :             "[HcommAdapterRuntime][%s] get device count failed, ret[%d], use resource id[%u].", __func__, ret,
      26              :             kDefaultResourceId);
      27            0 :         devicePhyId = kDefaultResourceId;
      28            0 :         noDevice = true;
      29            0 :         return HCCL_SUCCESS;
      30              :     }
      31              : 
      32          363 :     if (deviceCount == 0) {
      33            2 :         devicePhyId = kDefaultResourceId;
      34            2 :         noDevice = true;
      35            2 :         return HCCL_SUCCESS;
      36              :     }
      37              : 
      38          361 :     int32_t devLogicId = 0;
      39          361 :     CHK_RET(hrtGetDevice(&devLogicId));
      40          361 :     CHK_RET(hrtGetDevicePhyIdByIndex(static_cast<uint32_t>(devLogicId), devicePhyId));
      41          361 :     noDevice = false;
      42          361 :     HCCL_INFO(
      43              :         "[HcommAdapterRuntime][%s] deviceCount[%u], devLogicId[%d], devicePhyId[%u].", __func__, deviceCount,
      44              :         devLogicId, devicePhyId);
      45          361 :     return HCCL_SUCCESS;
      46              : }
      47              : 
      48              : } // namespace hcomm
        

Generated by: LCOV version 2.0-1