LCOV - code coverage report
Current view: top level - coll_communicator_mgr/communicator - coll_comm_mgr.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 82.6 % 23 19
Test Date: 2026-07-28 12:11:00 Functions: 83.3 % 6 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              : #include "coll_comm_mgr.h"
      11              : #include "ns_recovery/task_abort_handler.h"
      12              : #include "cluster_monitor.h"
      13              : 
      14              : namespace hccl {
      15              : 
      16              : CollCommMgr* CollCommMgr::instance_ = nullptr;
      17              : static std::once_flag instanceFlag;
      18              : 
      19          236 : CollCommMgr* CollCommMgr::GetInstance() 
      20              : {
      21          236 :     std::call_once(instanceFlag, [&] {
      22            6 :         instance_ = new CollCommMgr();
      23            6 :     });
      24          236 :     return instance_;
      25              : }
      26              : 
      27          139 : hcomm::ClusterMonitor &CollCommMgr::GetClusterMonitor(s32 deviceLogicId)
      28              : {
      29          139 :     if (static_cast<u32>(deviceLogicId) >= MAX_MODULE_DEVICE_NUM) {
      30            0 :             HCCL_WARNING("[ClusterMonitor][%s]deviceLogicId[%d] >= %u, invalid",
      31              :                 __func__, deviceLogicId, MAX_MODULE_DEVICE_NUM);
      32            0 :             return clusterMonitor_[0];
      33              :         }
      34          139 :         return clusterMonitor_[deviceLogicId];
      35              : }
      36              : 
      37           97 : void CollCommMgr::RegisteCollComm(CollComm* collComm)
      38              : {
      39           97 :     std::lock_guard<std::mutex> lock(mutex_);
      40           97 :     allCollComms_[collComm->GetCommId()] = collComm;
      41              :     // 注册到需要的地方
      42           97 :     HcclTaskAbortHandler::GetInstance().Register(collComm);
      43           97 : }
      44              : 
      45          123 : void CollCommMgr::UnRegisteCollComm(CollComm* collComm)
      46              : {
      47          123 :     std::lock_guard<std::mutex> lock(mutex_);
      48          123 :     allCollComms_.erase(collComm->GetCommId());
      49              :     // 从通信域里面注销
      50          123 :     HcclTaskAbortHandler::GetInstance().UnRegister(collComm);
      51          123 :     (void)GetClusterMonitor(collComm->GetDeviceLogicId()).UnRegisterToClusterMonitor(collComm);
      52          123 : }
      53              : 
      54            0 : std::unordered_map<std::string, CollComm*> CollCommMgr::GetAllCollComms()
      55              : {
      56            0 :     return allCollComms_;
      57              : }
      58              : 
      59              : }
        

Generated by: LCOV version 2.0-1