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

Generated by: LCOV version 2.0-1