LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/communicator - comm_topo_desc.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 45.5 % 33 15
Test Date: 2026-07-28 12:11:00 Functions: 62.5 % 8 5

            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 "comm_topo_desc.h"
      12              : #include "log.h"
      13              : 
      14              : namespace Hccl {
      15           10 : CommTopoDesc &CommTopoDesc::GetInstance()
      16              : {
      17           10 :     static CommTopoDesc commTopoDesc;
      18           10 :     return commTopoDesc;
      19              : }
      20              : 
      21            1 : CommTopoDesc::CommTopoDesc()
      22              : {
      23            1 : }
      24              : 
      25            1 : CommTopoDesc::~CommTopoDesc()
      26              : {
      27            1 : }
      28              : 
      29            5 : void CommTopoDesc::SaveRankSize(std::string &str, uint32_t rankSize)
      30              : {
      31            5 :     std::unique_lock<std::mutex> topoDescLock(lock_);
      32            5 :     rankSizeMap_[str] = rankSize;
      33            5 : }
      34              : 
      35            5 : void CommTopoDesc::SaveL0TopoType(std::string &str, CommTopo topoType)
      36              : {
      37            5 :     std::unique_lock<std::mutex> topoDescLock(lock_);
      38            5 :     l0TopoTypeMap_[str] = topoType;
      39            5 : }
      40              : 
      41            0 : HcclResult CommTopoDesc::GetRankSize(std::string &str, uint32_t *rankSize)
      42              : {
      43            0 :     std::unique_lock<std::mutex> topoDescLock(lock_);
      44            0 :     auto it = rankSizeMap_.find(str);
      45            0 :     if (it != rankSizeMap_.end()) {
      46            0 :         *rankSize = it->second;
      47            0 :         return HCCL_SUCCESS;
      48              :     } else {
      49            0 :         HCCL_ERROR("commName[%s] not found, please check comm init", str.c_str());
      50            0 :         return HCCL_E_PARA;
      51              :     }
      52            0 : }
      53              : 
      54            0 : HcclResult CommTopoDesc::GetL0TopoType(std::string &str, CommTopo *topoType)
      55              : {
      56            0 :     std::unique_lock<std::mutex> topoDescLock(lock_);
      57            0 :     auto it = l0TopoTypeMap_.find(str);
      58            0 :     if (it != l0TopoTypeMap_.end()) {
      59            0 :         *topoType = it->second;
      60            0 :         return HCCL_SUCCESS;
      61              :     } else {
      62            0 :         HCCL_ERROR("commName[%s] not found, please check comm init", str.c_str());
      63            0 :         return HCCL_E_PARA;
      64              :     }
      65            0 : }
      66              : }
        

Generated by: LCOV version 2.0-1