LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_template/aiv_alg_template - aiv_temp_reduce_mesh_1D.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 62 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 6 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 "executor_utils.h"
      12              : #include "hccl_aiv_utils.h"
      13              : #include "aiv_ins.h"
      14              : #include "aiv_temp_reduce_mesh_1D.h"
      15              : 
      16              : namespace Hccl {
      17              : 
      18            0 : AivTempReduceMesh1D::AivTempReduceMesh1D(const RankId virtualRank, const u32 tempRankSize,
      19            0 :     const std::vector<std::vector<RankId>> &tempVTopo, const std::map<RankId, u32> &tempVirtRankMap)
      20            0 :     : AivAlgTemplateBase(virtualRank, tempRankSize, tempVTopo, tempVirtRankMap)
      21              : {
      22            0 : }
      23              : 
      24            0 : AivTempReduceMesh1D::~AivTempReduceMesh1D()
      25              : {
      26            0 : }
      27              : 
      28            0 : HcclResult AivTempReduceMesh1D::CalcRes(AlgTempResReq &tempResReq)
      29              : {
      30            0 :     HCCL_INFO("[AivTempReduceMesh1D] Calculate communication resources start");
      31            0 :     tempResReq.queNum = 1;
      32            0 :     tempResReq.streamNum = tempResReq.queNum;
      33            0 :     CHK_RET(CalcResLinksMesh(myRank_, tempRankSize_, tempVTopo_, linkNumBtwPeers_, tempResReq));
      34            0 :     HCCL_INFO("[AivTempReduceMesh1D] Calculate communication resources finished, queNum[%u], streamNum[%u], linkNum[%u]",
      35              :         tempResReq.queNum, tempResReq.streamNum, tempResReq.links.size());
      36            0 :     return HcclResult::HCCL_SUCCESS;
      37              : }
      38              : 
      39            0 : u32 AivTempReduceMesh1D::CalcScratchMultiple(BufferType inBuffType, BufferType outBuffType)
      40              : {
      41              :     (void) inBuffType;
      42              :     (void) outBuffType;
      43            0 :     HCCL_INFO("[AivTempReduceMesh1D] Scratch multiple is [%u]", (tempRankSize_ - 1));
      44            0 :     return tempRankSize_ - 1;
      45              : }
      46              : 
      47            0 : HcclResult AivTempReduceMesh1D::GenExtIns(const TempFuncs &tempFuncs, const TemplateDataParams &templateDataParams, 
      48              :     const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues)
      49              : {
      50            0 :     HCCL_INFO("[AivTempReduceMesh1D] GenExtIns start rank[%u]", u32(myRank_));
      51            0 :     CHK_PRT_RET(tempInsQues.empty(),
      52              :         HCCL_ERROR("[AivTempReduceMesh1D] empty queue"), HcclResult::HCCL_E_INTERNAL);
      53            0 :     CHK_PTR_NULL(tempInsQues[0]);
      54            0 :     std::vector<LinkData> allLinks;
      55            0 :     for (auto iter = tempLinks.begin(); iter != tempLinks.end(); ++iter) {
      56            0 :         allLinks.emplace_back(iter->second.at(0));
      57              :     }
      58              : 
      59            0 :     IncSliceId();  // 自动增长sliceId,传入aivTag
      60              : 
      61            0 :     AivOpArgs aivReduceArgs;
      62            0 :     aivReduceArgs.cmdType = HcclCMDType::HCCL_CMD_REDUCE;
      63            0 :     aivReduceArgs.input = templateDataParams.buffInfo.inBuffBaseOff;
      64            0 :     aivReduceArgs.output = templateDataParams.buffInfo.outBuffBaseOff;
      65            0 :     aivReduceArgs.rank = u32(myRank_);
      66            0 :     aivReduceArgs.rankSize = tempRankSize_;
      67            0 :     aivReduceArgs.count = templateDataParams.sliceSize / DataTypeSizeGet(dataType_);
      68            0 :     aivReduceArgs.dataType = dataType_;
      69            0 :     aivReduceArgs.op = reduceOp_;
      70            0 :     aivReduceArgs.root = root_;
      71            0 :     aivReduceArgs.aivTag = sliceId_;  // 传入aivTag,Lauch时重新组装为aivTag
      72            0 :     aivReduceArgs.isOpBase = (tempFuncs.opMode == OpMode::OPBASE);
      73            0 :     aivReduceArgs.xRankSize = tempVTopo_[0].size();
      74            0 :     aivReduceArgs.yRankSize = 0;
      75            0 :     aivReduceArgs.zRankSize = 0;
      76              : 
      77            0 :     constexpr u32 level0 = 0;
      78            0 :     constexpr u32 level1 = 1;
      79            0 :     constexpr u32 level2 = 2;
      80            0 :     for (u32 i = 0; i < tempVTopo_[level0].size(); i++) {
      81            0 :         aivReduceArgs.topo_[i] = tempVTopo_[level0][i];
      82              :     }
      83            0 :     if (tempVTopo_.size() > level1) {
      84            0 :         aivReduceArgs.yRankSize = tempVTopo_[level1].size();
      85            0 :         for (u32 i = 0; i < tempVTopo_[level1].size(); i++) {
      86            0 :             aivReduceArgs.topo_[TOPO_LEN_Y_OFFSET + i] = tempVTopo_[level1][i];
      87              :         }
      88              :     }
      89            0 :     if (tempVTopo_.size() > level2) {
      90            0 :         aivReduceArgs.zRankSize = tempVTopo_[level2].size();
      91            0 :         for (u32 i = 0; i < tempVTopo_[level2].size(); i++) {
      92            0 :             aivReduceArgs.topo_[TOPO_LEN_Z_OFFSET + i] = tempVTopo_[level2][i];
      93              :         }
      94              :     }
      95              : 
      96            0 :     aivReduceArgs.inputSliceStride = templateDataParams.inputSliceStride;
      97            0 :     aivReduceArgs.outputSliceStride = templateDataParams.outputSliceStride;
      98            0 :     aivReduceArgs.repeatNum = templateDataParams.repeatNum;
      99            0 :     aivReduceArgs.inputRepeatStride = templateDataParams.inputRepeatStride;
     100            0 :     aivReduceArgs.outputRepeatStride = templateDataParams.outputRepeatStride;
     101              : 
     102            0 :     std::unique_ptr<Instruction>  aivInsReduceMesh1D = std::make_unique<AivInstruction>(allLinks, aivReduceArgs);
     103              : 
     104            0 :     tempInsQues[0]->Append(std::move(aivInsReduceMesh1D));
     105            0 :     HCCL_INFO("[AivTempReduceMesh1D] GenExtIns finished rank[%u]", u32(myRank_));
     106            0 :     return HcclResult::HCCL_SUCCESS;
     107            0 : }
     108              : 
     109              : }  // namespace Hccl
        

Generated by: LCOV version 2.0-1