LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_all_gather_v - coll_all_gather_v_ring_for_910_93_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 90 0
Test Date: 2026-08-04 10:52:23 Functions: 0.0 % 8 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 "coll_all_gather_v_ring_for_910_93_executor.h"
      12              : #include <numeric>
      13              : 
      14              : namespace hccl {
      15            0 : CollAllGatherVRingFor91093Executor::CollAllGatherVRingFor91093Executor(const HcclDispatcher dispatcher,
      16            0 :     std::unique_ptr<TopoMatcher> &topoMatcher)
      17            0 :     : CollAllGatherRingFor91093Executor(dispatcher, topoMatcher)
      18              : {
      19            0 :     isAllGatherV_ = true;
      20            0 :     desc_.level1SupportedAlgos = {
      21              :         AlgTypeLevel1::ALG_LEVEL1_NHR,
      22              :         AlgTypeLevel1::ALG_LEVEL1_NB,
      23              :         AlgTypeLevel1::ALG_LEVEL1_RING
      24            0 :     };
      25            0 : }
      26              : 
      27            0 : bool CollAllGatherVRingFor91093Executor::IsSmallData(const u64 size)
      28              : {
      29              :     (void) size;
      30            0 :     return false;
      31              : }
      32              : 
      33            0 : u64 CollAllGatherVRingFor91093Executor::CalcDstMemOffset(const OpParam &param, u32 perDataSize, u64 inputMemSize) const
      34              : {
      35              :     (void) inputMemSize;
      36            0 :     const auto *counts = static_cast<const u64 *>(param.VDataDes.counts);
      37            0 :     const u64 offset = std::accumulate(counts, counts + topoAttr_.userRank, 0ULL);
      38            0 :     return offset * perDataSize;
      39              : }
      40              : 
      41            0 : HcomCollOpInfo CollAllGatherVRingFor91093Executor::GetHcomCollOpInfo(const OpParam &param, const ExecMem &execMem) const
      42              : {
      43            0 :     HcomCollOpInfo opInfo = {
      44            0 :         "", execMem.inputPtr, execMem.outputPtr, execMem.count, param.VDataDes.dataType, param.root,
      45            0 :         param.reduceType, 0 // 暂不支持MC2的strideCount特性
      46            0 :     };
      47            0 :     return opInfo;
      48              : }
      49              : 
      50            0 : std::vector<Slice> CollAllGatherVRingFor91093Executor::PrepareSlicesL2(const OpParam &param,
      51              :     const SubCommInfo &level2CommInfo, const SubCommInfo &level1CommInfo, const SubCommInfo &level0CommInfo,
      52              :     u32 perDataSize, u64 inputMemSize) const
      53              : {
      54              :     (void) inputMemSize;
      55            0 :     std::vector<Slice> level2DataSegsSlice;
      56            0 :     const auto *counts = static_cast<u64 *>(param.VDataDes.counts);
      57            0 :     const u32 level0RankSize = level0CommInfo.localRankSize;
      58            0 :     const u32 level0ServerIndex = level0CommInfo.localRank;
      59            0 :     const u32 level1RankSize = level1CommInfo.localRankSize;
      60            0 :     const u32 level1ServerIndex = level1CommInfo.localRank;
      61            0 :     const u32 level2RankSize = level2CommInfo.localRankSize;
      62            0 :     for (u32 i = 0; i < level2RankSize; i++) {
      63            0 :         const u32 rank = i * level1RankSize * level0RankSize + level1ServerIndex * level0RankSize + level0ServerIndex;
      64            0 :         Slice sliceTemp;
      65            0 :         sliceTemp.size = counts[rank] * perDataSize;
      66            0 :         const u64 offset = std::accumulate(counts, counts + rank, 0ULL);
      67            0 :         sliceTemp.offset = offset * perDataSize;
      68            0 :         level2DataSegsSlice.push_back(sliceTemp);
      69              :     }
      70            0 :     return level2DataSegsSlice;
      71            0 : }
      72              : 
      73            0 : std::vector<Slice> CollAllGatherVRingFor91093Executor::PrepareSlicesL1(const OpParam &param,
      74              :     const SubCommInfo &level2CommInfo, const SubCommInfo &level1CommInfo, const SubCommInfo &level0CommInfo,
      75              :     u32 perDataSize, u64 inputMemSize) const
      76              : {
      77              :     (void) inputMemSize;
      78            0 :     const auto *counts = static_cast<u64 *>(param.VDataDes.counts);
      79            0 :     const u32 level0RankSize = level0CommInfo.localRankSize;
      80            0 :     const u32 level0ServerIndex = level0CommInfo.localRank;
      81            0 :     const u32 level1RankSize = level1CommInfo.localRankSize;
      82            0 :     const u32 level2RankSize = level2CommInfo.localRankSize;
      83            0 :     std::vector<Slice> level1DataSegsSlice;
      84            0 :     for (u32 j = 0; j < level1RankSize; j++) {
      85            0 :         for (u32 i = 0; i < level2RankSize; i++) {
      86            0 :             Slice level1Slice;
      87            0 :             const u32 rank = i * level1RankSize * level0RankSize + j * level0RankSize + level0ServerIndex;
      88            0 :             level1Slice.size = counts[rank] * perDataSize;
      89            0 :             const u64 offset = std::accumulate(counts, counts + rank, 0ULL);
      90            0 :             level1Slice.offset = offset * perDataSize;
      91            0 :             level1DataSegsSlice.push_back(level1Slice);
      92              :         }
      93              :     }
      94            0 :     return level1DataSegsSlice;
      95            0 : }
      96              : 
      97            0 : HcclResult CollAllGatherVRingFor91093Executor::PrepareSlicesL0(std::vector<std::vector<Slice>> &multRingsSlice,
      98              :     const OpParam &param, const SubCommInfo &level2CommInfo, const SubCommInfo &level1CommInfo,
      99              :     const SubCommInfo &level0CommInfo, u32 perDataSize, u64 inputMemSize)
     100              : {
     101              :     (void) inputMemSize;
     102            0 :     HCCL_CONFIG_INFO(HCCL_ALG,
     103              :         "[CollAllGatherVRingFor91093Executor][PrepareSlicesL0] userRank[%u] starts.", topoAttr_.userRank);
     104            0 :     const auto *counts = static_cast<u64 *>(param.VDataDes.counts);
     105            0 :     const u32 level0RankSize = level0CommInfo.localRankSize;
     106            0 :     const u32 level1RankSize = level1CommInfo.localRankSize;
     107            0 :     const u32 level2RankSize = level2CommInfo.localRankSize;
     108            0 :     std::vector<Slice> dataSegsSlice;
     109            0 :     for (u32 k = 0; k < level0RankSize; k++) {  // 根据数据量计算每个环上数据的偏移和大小
     110            0 :         for (u32 i = 0; i < level2RankSize; i++) {
     111            0 :             for (u32 j = 0; j < level1RankSize; j++) {
     112            0 :                 Slice sliceTemp;
     113            0 :                 const u32 rank = i * level1RankSize * level0RankSize + j * level0RankSize + k;
     114            0 :                 sliceTemp.size = counts[rank] * perDataSize;
     115            0 :                 const u64 offset = std::accumulate(counts, counts + rank, 0ULL);
     116            0 :                 sliceTemp.offset = offset * perDataSize;    // no displs
     117            0 :                 dataSegsSlice.push_back(sliceTemp);
     118              :             }
     119              :         }
     120              :     }
     121            0 :     multRingsSlice.push_back(dataSegsSlice);
     122            0 :     return HCCL_SUCCESS;
     123            0 : }
     124              : 
     125              : // AGV不支持MC2的strideCount特性
     126            0 : HcclResult CollAllGatherVRingFor91093Executor::PrepareUserMemSlices(std::vector<std::vector<Slice>> &userMemSlices,
     127              :     const std::vector<std::vector<Slice>> &multRingsSlice, const OpParam &param, const SubCommInfo &level2CommInfo,
     128              :     const SubCommInfo &level1CommInfo, const SubCommInfo &level0CommInfo, u32 perDataSize, u64 inputMemSize)
     129              : {
     130              :     (void) inputMemSize;
     131              :     (void) multRingsSlice;
     132            0 :     const auto *counts = static_cast<u64 *>(param.VDataDes.counts);
     133            0 :     const auto *displs = static_cast<u64 *>(param.VDataDes.displs);
     134            0 :     std::vector<Slice> dataSegsSlice;
     135            0 :     const u32 level0RankSize = level0CommInfo.localRankSize;
     136            0 :     const u32 level1RankSize = level1CommInfo.localRankSize;
     137            0 :     const u32 level2RankSize = level2CommInfo.localRankSize;
     138            0 :     for (u32 k = 0; k < level0RankSize; k++) {  // 根据数据量计算每个环上数据的偏移和大小
     139            0 :         for (u32 i = 0; i < level2RankSize; i++) {
     140            0 :             for (u32 j = 0; j < level1RankSize; j++) {
     141            0 :                 Slice sliceTemp;
     142            0 :                 const u32 rank = i * level1RankSize * level0RankSize + j * level0RankSize + k;
     143            0 :                 sliceTemp.size = counts[rank] * perDataSize;
     144            0 :                 sliceTemp.offset = displs[rank] * perDataSize;    // with displs
     145            0 :                 dataSegsSlice.push_back(sliceTemp);
     146              :             }
     147              :         }
     148              :     }
     149            0 :     userMemSlices.push_back(dataSegsSlice);
     150            0 :     return HCCL_SUCCESS;
     151            0 : }
     152              : 
     153              : REGISTER_EXEC("AllGatherVRingFor91093Executor", AllGatherVRingFor91093, CollAllGatherVRingFor91093Executor);
     154              : 
     155              : } // namespace hccl
        

Generated by: LCOV version 2.0-1