LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/resource_manager/connection/ub_ci_updater - ub_ci_updater_manager.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 86.8 % 38 33
Test Date: 2026-08-04 10:52:23 Functions: 100.0 % 6 6

            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 "ub_ci_updater_manager.h"
      12              : #include "dev_ub_connection.h"
      13              : 
      14              : namespace Hccl {
      15              : 
      16          196 : UbCiUpdaterManager::UbCiUpdaterManager(const RmaConnManager *rmaConnMgr) : rmaConnMgrPtr(rmaConnMgr)
      17              : {
      18          196 : }
      19              : 
      20          196 : UbCiUpdaterManager::~UbCiUpdaterManager()
      21              : {
      22          196 :     ubCiUpdaters.clear();
      23          196 : }
      24              : 
      25            2 : void UbCiUpdaterManager::SaveConnsCi(const std::string &opTag)
      26              : {
      27            2 :     auto ubCiUpdatersPair = ubCiUpdaters.emplace(opTag, BatchCreate(opTag));
      28            4 :     for (auto &ubCiUpdater : ubCiUpdatersPair.first->second) {
      29            2 :         if (ubCiUpdater == nullptr) {
      30            0 :             continue;
      31              :         }
      32            2 :         ubCiUpdater->SaveCi();
      33              :     }
      34            2 : }
      35              : 
      36            1 : void UbCiUpdaterManager::UpdateConnsCi(const std::string &opTag)
      37              : {
      38            1 :     if (ubCiUpdaters.find(opTag) == ubCiUpdaters.end()) {
      39            0 :         return;
      40              :     }
      41            1 :     std::vector<DevUbConnection::UbCiUpdater *> tmpUbCiUpdaters = Get(opTag);
      42            2 :     for (auto &ubCiUpdater : tmpUbCiUpdaters) {
      43            1 :         if (ubCiUpdater == nullptr) {
      44            0 :             continue;
      45              :         }
      46            1 :         ubCiUpdater->UpdateCi();
      47              :     }
      48            1 : }
      49              : 
      50            2 : std::vector<std::unique_ptr<DevUbConnection::UbCiUpdater>> UbCiUpdaterManager::BatchCreate(const std::string &opTag) const
      51              : {
      52            2 :     std::vector<std::unique_ptr<DevUbConnection::UbCiUpdater>> tmpUbCiUpdaters;
      53            4 :     for (auto &rmaConn : rmaConnMgrPtr->GetOpTagConns(opTag)) {
      54            2 :         if (rmaConn->GetRmaConnType() == RmaConnType::UB) {
      55            2 :             if (dynamic_cast<DevUbConnection *>(rmaConn)->GetUbJfcMode() == HrtUbJfcMode::STARS_POLL) {
      56            2 :                 tmpUbCiUpdaters.emplace_back(std::make_unique<DevUbConnection::UbCiUpdater>(
      57            4 :                     dynamic_cast<DevUbConnection *>(rmaConn)));
      58              :             }
      59              :         }
      60            2 :     }
      61            2 :     return tmpUbCiUpdaters;
      62            0 : }
      63              : 
      64            2 : std::vector<DevUbConnection::UbCiUpdater *> UbCiUpdaterManager::Get(const std::string &opTag)
      65              : {
      66            2 :     std::vector<DevUbConnection::UbCiUpdater *> tmpUbCiUpdaters;
      67            2 :     auto tagIter = ubCiUpdaters.find(opTag);
      68            4 :     for (auto &ubCiUpdater : tagIter->second) {
      69            2 :         tmpUbCiUpdaters.emplace_back(ubCiUpdater.get());
      70              :     }
      71            2 :     return tmpUbCiUpdaters;
      72            0 : }
      73              : 
      74              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1