LCOV - code coverage report
Current view: top level - legacy/ascend950/framework/service - connections_builder.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 55.3 % 38 21
Test Date: 2026-07-28 12:11:00 Functions: 100.0 % 4 4

            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 "connections_builder.h"
      12              : #include "stl_util.h"
      13              : #include "exception_util.h"
      14              : #include "rma_conn_exception.h"
      15              : #include "communicator_impl.h"
      16              : 
      17              : #include <list>
      18              : 
      19              : namespace Hccl {
      20            1 : vector<LinkData> ConnectionsBuilder::GetAvailableLinksVec() const
      21              : {
      22            2 :     return vector<LinkData>(availableLinks.begin(), availableLinks.end());
      23              : }
      24              : 
      25            8 : void ConnectionsBuilder::BatchBuild(const std::string &opTag, const vector<LinkData> &links)
      26              : {
      27            8 :     vector<LinkData> pendingLinks;
      28            8 :     for (auto &link : links) {
      29            0 :         if (Contain(availableLinks, link)) {
      30            0 :             continue;
      31              :         }
      32            0 :         pendingLinks.emplace_back(link);
      33              :     }
      34           24 :     HCCL_INFO("[%s]opTag[%s] links size[%u], pendingLinks size[%u]", __func__, opTag.c_str(), links.size(), pendingLinks.size());
      35              : 
      36            8 :     if (pendingLinks.empty()) {
      37            8 :         return;
      38              :     }
      39              : 
      40              :     // rmaConnections创建
      41            0 :     HCCL_INFO("create rma connection start");
      42            0 :     CreateRmaConnections(opTag, pendingLinks);
      43            0 :     HCCL_INFO("create rma connection end");
      44              : 
      45            0 :     availableLinks.insert(pendingLinks.begin(), pendingLinks.end());
      46            8 : }
      47              : 
      48            1 : void ConnectionsBuilder::CreateRmaConnections(const std::string &opTag, const vector<LinkData> &links) const
      49              : {
      50            1 :     list<RmaConnection *> connTasks;
      51            2 :     for (auto &link : links) {
      52            1 :         connTasks.emplace_back(connManager->Create(opTag, link));
      53              :     }
      54            1 :     CHECK_NULLPTR(comm, "[ConnectionsBuilder::CreateRmaConnections] comm is nullptr!");
      55            1 :     if (!comm->GetOpCcuFeatureFlag()) { // 非CCU展开,则在transport中交换 connection // 直接return,下面删除?
      56            1 :         return;
      57              :     }
      58              :     // CCU使用的connection,则走到下面来搞,待CCU transport搞定后,再删除下面这段
      59            0 :     while (!connTasks.empty()) {
      60            0 :         for (auto connIter = connTasks.begin(); connIter != connTasks.end();) {
      61            0 :             CHECK_NULLPTR((*connIter), "[ConnectionsBuilder::CreateRmaConnections] (*connIter) is nullptr!");
      62            0 :             auto status = (*connIter)->GetStatus();
      63            0 :             if (status == RmaConnStatus::READY) {
      64            0 :                 connIter = connTasks.erase(connIter);
      65            0 :             } else if (status == RmaConnStatus::CONN_INVALID || status == RmaConnStatus::CLOSE) {
      66            0 :                 THROW<RmaConnException>(StringFormat("Invalid status occurs when creating RMA connection %s!",
      67            0 :                                                      (*connIter)->Describe().c_str()));
      68              :             } else {
      69            0 :                 ++connIter;
      70              :             }
      71              :         }
      72              :     }
      73            1 : }
      74              : 
      75           18 : ConnectionsBuilder::ConnectionsBuilder(CommunicatorImpl &communicator)
      76              : {
      77           18 :     this->comm  = &communicator;
      78           18 :     connManager = &(comm->GetRmaConnManager());
      79           18 : }
      80              : 
      81              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1