LCOV - code coverage report
Current view: top level - legacy/ascend910/framework/communicator/impl - comm_topo_desc.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 41.9 % 31 13
Test Date: 2026-08-18 17:47:01 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 "log.h"
      12              : #include "comm_topo_desc.h"
      13              : 
      14              : namespace hccl {
      15         1046 : CommTopoDesc& CommTopoDesc::GetInstance()
      16              : {
      17         1046 :     static CommTopoDesc commTopoDesc;
      18         1046 :     return commTopoDesc;
      19              : }
      20              : 
      21            9 : CommTopoDesc::CommTopoDesc() {}
      22              : 
      23            9 : CommTopoDesc::~CommTopoDesc() {}
      24              : 
      25          523 : void CommTopoDesc::SaveRankSize(std::string& str, uint32_t rankSize)
      26              : {
      27          523 :     std::unique_lock<std::mutex> topoDescLock(lock_);
      28          523 :     rankSizeMap_[str] = rankSize;
      29          523 : }
      30              : 
      31          523 : void CommTopoDesc::SaveL0TopoType(std::string& str, CommTopo topoType)
      32              : {
      33          523 :     std::unique_lock<std::mutex> topoDescLock(lock_);
      34          523 :     l0TopoTypeMap_[str] = topoType;
      35          523 : }
      36              : 
      37            0 : HcclResult CommTopoDesc::GetRankSize(std::string& str, uint32_t* rankSize)
      38              : {
      39            0 :     std::unique_lock<std::mutex> topoDescLock(lock_);
      40            0 :     auto it = rankSizeMap_.find(str);
      41            0 :     if (it != rankSizeMap_.end()) {
      42            0 :         *rankSize = it->second;
      43            0 :         return HCCL_SUCCESS;
      44              :     } else {
      45            0 :         HCCL_ERROR("commName[%s] not found, please check comm init", str.c_str());
      46            0 :         return HCCL_E_PARA;
      47              :     }
      48            0 : }
      49              : 
      50            0 : HcclResult CommTopoDesc::GetL0TopoType(std::string& str, CommTopo* topoType)
      51              : {
      52            0 :     std::unique_lock<std::mutex> topoDescLock(lock_);
      53            0 :     auto it = l0TopoTypeMap_.find(str);
      54            0 :     if (it != l0TopoTypeMap_.end()) {
      55            0 :         *topoType = it->second;
      56            0 :         return HCCL_SUCCESS;
      57              :     } else {
      58            0 :         HCCL_ERROR("commName[%s] not found, please check comm init", str.c_str());
      59            0 :         return HCCL_E_PARA;
      60              :     }
      61            0 : }
      62              : } // namespace hccl
        

Generated by: LCOV version 2.0-1