LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/base/alg_template - asymmetric_hierarchical_concatenate_nslb.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 34 0
Test Date: 2026-08-04 10:52:23 Functions: 0.0 % 4 0

            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_ahc_base_pub.h"
      12              : #include <iostream>
      13              : #include <fstream>
      14              : 
      15              : namespace hccl {
      16              : 
      17            0 : HcclResult CommAHCBaseInfo::GetNBNslbDstRanks(const u32 rank, const std::vector<u32> commGroups,
      18              :     std::vector<u32> &dstRanks)
      19              : {
      20            0 :     CHK_PRT_RET(rank >= commGroups.size(),
      21              :         HCCL_ERROR("[CalcNBTransportReq][CalcDstRanks] rank [%u] exceed commGroups Size [%u]  error", 
      22              :         rank, commGroups.size() ), HCCL_E_INTERNAL);
      23              : 
      24            0 :     for (auto i = 0; static_cast<u32>(1 << i) < commGroups.size(); ++i) {
      25              :         // 正方向第2^i个节点的rank号
      26            0 :         const u32 targetRankPos = static_cast<u32>(rank + (1 << i)) % commGroups.size();
      27            0 :         dstRanks.push_back(commGroups[targetRankPos]);
      28              :  
      29              :         // 反方向第2^i个节点的rank号
      30            0 :         const u32 targetRankNeg = static_cast<u32>(rank + commGroups.size() - (1 << i)) % commGroups.size();
      31              : 
      32            0 :         HCCL_DEBUG("[CalcNBTransportReq][CalcDstRanks] local rank[%u], remote rank[%u]", commGroups[rank], commGroups[targetRankNeg]);
      33              : 
      34            0 :         dstRanks.push_back(commGroups[targetRankNeg]);
      35              :     }
      36              :  
      37            0 :     return HCCL_SUCCESS;
      38              : }
      39              : 
      40            0 : HcclResult CommAHCBaseInfo::GetNHRNslbDstRanks(const u32 rank, const std::vector<u32> commGroups,
      41              :     std::vector<u32> &dstRanks)
      42              : {
      43            0 :     CHK_PRT_RET(rank >= commGroups.size(),
      44              :         HCCL_ERROR("[CalcNHRTransportReq][CalcDstRanks] rank [%u] exceed commGroups Size [%u]  error", 
      45              :         rank, commGroups.size() ), HCCL_E_INTERNAL);
      46              :     
      47            0 :     for (auto i = 0; static_cast<u32>(1 << i) < commGroups.size(); ++i) {
      48              :         // 正方向第2^i个节点的rank号
      49            0 :         const u32 targetRankPos = static_cast<u32>(rank + (1 << i)) % commGroups.size();
      50            0 :         dstRanks.push_back(commGroups[targetRankPos]);
      51              :  
      52              :         // 反方向第2^i个节点的rank号
      53            0 :         const u32 targetRankNeg = static_cast<u32>(rank + commGroups.size() - (1 << i)) % commGroups.size();
      54              : 
      55            0 :         HCCL_DEBUG("[CalcNHRTransportReq][CalcDstRanks] local rank[%u], remote rank[%u]", commGroups[rank], commGroups[targetRankNeg]);
      56              :     
      57            0 :         dstRanks.push_back(commGroups[targetRankNeg]);
      58              :     }
      59              :  
      60            0 :     return HCCL_SUCCESS;
      61              : }
      62              : 
      63            0 : HcclResult CommAHCBaseInfo::GetRingNslbDstRanks(const u32 rank, const std::vector<u32> commGroups, std::vector<u32> &dstRanks)
      64              : {
      65            0 :     CHK_PRT_RET(rank >= commGroups.size(),
      66              :         HCCL_ERROR("[CalcRingTransportReq][CalcDstRanks] rank [%u] exceed commGroups Size [%u]  error", 
      67              :         rank, commGroups.size() ), HCCL_E_INTERNAL);
      68              :     
      69              :     // 正方向下一个节点的rank号
      70            0 :     const u32 targetRankPos = static_cast<u32>(rank + 1) % commGroups.size();
      71            0 :     dstRanks.push_back(commGroups[targetRankPos]);
      72              :  
      73              :     // 反方向下一个节点的rank号
      74            0 :     const u32 targetRankNeg = static_cast<u32>(rank + commGroups.size() - 1) % commGroups.size();
      75              :     
      76            0 :     HCCL_DEBUG("[CalcRingTransportReq][CalcDstRanks] local rank[%u], remote rank[%u]", commGroups[rank], commGroups[targetRankNeg]);
      77              : 
      78            0 :     dstRanks.push_back(commGroups[targetRankNeg]);
      79              :  
      80            0 :     return HCCL_SUCCESS;
      81              : }
      82              : 
      83            0 : HcclResult CommAHCBaseInfo::GetDstRanksByType(AHCTemplateType type, const u32 rank, const std::vector<u32> commGroups, std::vector<u32> &dstRanks)
      84              : {
      85            0 :     if (type == AHCTemplateType::AHC_TEMPLATE_NB) {
      86            0 :         CHK_RET(GetRingNslbDstRanks(rank, commGroups, dstRanks));
      87              :     }
      88            0 :     if (type == AHCTemplateType::AHC_TEMPLATE_NHR) {
      89            0 :         CHK_RET(GetRingNslbDstRanks(rank, commGroups, dstRanks));
      90              :     }
      91            0 :     if (type == AHCTemplateType::AHC_TEMPLATE_NHR) {
      92            0 :         CHK_RET(GetRingNslbDstRanks(rank, commGroups, dstRanks));
      93              :     }
      94            0 :     return HCCL_SUCCESS;
      95              : }
      96              : 
      97              : }
        

Generated by: LCOV version 2.0-1