LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_template/aiv_alg_template - aiv_temp_reduce_scatter_mesh_1D.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 66 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 7 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 "hccl_aiv_utils.h"
      12              : #include "aiv_ins.h"
      13              : #include "aiv_temp_reduce_scatter_mesh_1D.h"
      14              : #include "executor_utils.h"
      15              : 
      16              : namespace Hccl {
      17              : 
      18            0 : AivTempReduceScatterMesh1D::AivTempReduceScatterMesh1D(
      19              :     const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
      20            0 :     const std::map<RankId, u32>& tempVirtRankMap)
      21            0 :     : AivAlgTemplateBase(virtualRank, tempRankSize, tempVTopo, tempVirtRankMap)
      22            0 : {}
      23              : 
      24            0 : AivTempReduceScatterMesh1D::~AivTempReduceScatterMesh1D() {}
      25              : 
      26            0 : u32 AivTempReduceScatterMesh1D::CalcScratchMultiple(BufferType inBuffType, BufferType outBuffType)
      27              : {
      28              :     (void)inBuffType;
      29              :     (void)outBuffType;
      30              :     // 小数据量下,这里是2*rankSize基本不影响,大数据量下,需要2倍的cclBuffer去并发读
      31            0 :     return 2 * tempRankSize_;
      32              : }
      33              : 
      34            0 : HcclResult AivTempReduceScatterMesh1D::CalcRes(AlgTempResReq& tempResReq)
      35              : {
      36            0 :     tempResReq.queNum = 1;
      37            0 :     tempResReq.streamNum = tempResReq.queNum;
      38            0 :     HCCL_INFO("[CalcRes] tempResReq.queNum[%u]", tempResReq.queNum);
      39            0 :     CHK_RET(CalcResLinksMesh(myRank_, tempRankSize_, tempVTopo_, linkNumBtwPeers_, tempResReq));
      40            0 :     return HcclResult::HCCL_SUCCESS;
      41              : }
      42              : 
      43            0 : HcclResult AivTempReduceScatterMesh1D::CalNumBlocks(u32& numBlocks, u64 dataSize, u32 numBlocksLimit)
      44              : {
      45            0 :     numBlocks = numBlocksLimit;
      46            0 :     if (dataSize < REDUCE_SCATTER_SMALL_COUNT_512KB) { // 小数据量,走原来极致低时延的流程
      47            0 :         constexpr uint32_t stepNum = 2;
      48            0 :         if (numBlocks > stepNum * tempRankSize_) {
      49            0 :             numBlocks = stepNum * tempRankSize_;
      50              :         }
      51              :     }
      52            0 :     HCCL_INFO("[AivTempReduceScatterMesh1D] Actually use core num[%u]", numBlocks);
      53            0 :     return HcclResult::HCCL_SUCCESS;
      54              : }
      55              : 
      56            0 : HcclResult AivTempReduceScatterMesh1D::GenExtIns(
      57              :     const TempFuncs& tempFuncs, const TemplateDataParams& templateDataParams, const ResLinks& tempLinks,
      58              :     std::vector<InsQuePtr>& tempInsQues)
      59              : {
      60            0 :     HCCL_INFO("[AivTempReduceScatterMesh1D] GenExtIns start");
      61            0 :     CHK_PRT_RET(
      62              :         tempInsQues.empty(), HCCL_ERROR("[AivTempReduceScatterMesh1D] empty queue"), HcclResult::HCCL_E_INTERNAL);
      63            0 :     CHK_PTR_NULL(tempInsQues[0]);
      64            0 :     std::vector<LinkData> allLinks;
      65            0 :     for (auto iter = tempLinks.begin(); iter != tempLinks.end(); ++iter) {
      66            0 :         allLinks.emplace_back(iter->second.at(0));
      67              :     }
      68              : 
      69            0 :     IncSliceId(); // 自动增长sliceId,传入aivTag
      70              : 
      71            0 :     AivOpArgs aivReduceScatterArgs;
      72            0 :     aivReduceScatterArgs.cmdType = HcclCMDType::HCCL_CMD_REDUCE_SCATTER;
      73            0 :     aivReduceScatterArgs.input = templateDataParams.buffInfo.inBuffBaseOff;
      74            0 :     aivReduceScatterArgs.output = templateDataParams.buffInfo.outBuffBaseOff;
      75            0 :     aivReduceScatterArgs.rank = u32(myRank_);
      76            0 :     aivReduceScatterArgs.rankSize = tempRankSize_;
      77            0 :     aivReduceScatterArgs.count = templateDataParams.sliceSize / DataTypeSizeGet(dataType_);
      78            0 :     aivReduceScatterArgs.dataType = dataType_;
      79            0 :     aivReduceScatterArgs.op = reduceOp_;
      80            0 :     aivReduceScatterArgs.root = root_;
      81            0 :     aivReduceScatterArgs.aivTag = sliceId_; // 传入aivTag,Lauch时重新组装为aivTag
      82            0 :     aivReduceScatterArgs.isOpBase = (tempFuncs.opMode == OpMode::OPBASE);
      83            0 :     aivReduceScatterArgs.xRankSize = tempVTopo_[0].size();
      84            0 :     aivReduceScatterArgs.yRankSize = 0;
      85            0 :     aivReduceScatterArgs.zRankSize = 0;
      86            0 :     for (u32 i = 0; i < tempVTopo_[0].size(); i++) {
      87            0 :         aivReduceScatterArgs.topo_[i] = tempVTopo_[0][i];
      88              :     }
      89            0 :     if (tempVTopo_.size() > 1) {
      90            0 :         aivReduceScatterArgs.yRankSize = tempVTopo_[1].size();
      91            0 :         for (u32 i = 0; i < tempVTopo_[1].size(); i++) {
      92            0 :             aivReduceScatterArgs.topo_[TOPO_LEN_Y_OFFSET + i] = tempVTopo_[1][i];
      93              :         }
      94              :     }
      95            0 :     if (tempVTopo_.size() == MAX_DIM_NUM) {
      96            0 :         aivReduceScatterArgs.zRankSize = tempVTopo_[MAX_DIM_NUM - 1].size();
      97            0 :         for (u32 i = 0; i < tempVTopo_[MAX_DIM_NUM - 1].size(); i++) {
      98            0 :             aivReduceScatterArgs.topo_[TOPO_LEN_Z_OFFSET + i] = tempVTopo_[MAX_DIM_NUM - 1][i];
      99              :         }
     100              :     }
     101              : 
     102            0 :     u64 dataSize = op_.dataCount * DataTypeSizeGet(dataType_);
     103            0 :     CHK_RET(CalNumBlocks(aivReduceScatterArgs.numBlocks, dataSize, op_.numBlocksLimit));
     104              : 
     105            0 :     aivReduceScatterArgs.inputSliceStride = templateDataParams.inputSliceStride;
     106            0 :     aivReduceScatterArgs.outputSliceStride = templateDataParams.outputSliceStride;
     107            0 :     aivReduceScatterArgs.repeatNum = templateDataParams.repeatNum;
     108            0 :     aivReduceScatterArgs.inputRepeatStride = templateDataParams.inputRepeatStride;
     109            0 :     aivReduceScatterArgs.outputRepeatStride = templateDataParams.outputRepeatStride;
     110              : 
     111              :     std::unique_ptr<Instruction> aivInsReduceScatterMesh1D
     112            0 :         = std::make_unique<AivInstruction>(allLinks, aivReduceScatterArgs);
     113              : 
     114            0 :     tempInsQues[0]->Append(std::move(aivInsReduceScatterMesh1D));
     115              : 
     116            0 :     HCCL_INFO("[AivTempReduceScatterMesh1D] GenExtIns finished");
     117            0 :     return HcclResult::HCCL_SUCCESS;
     118            0 : }
     119              : 
     120              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1