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

Generated by: LCOV version 2.0-1