LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_template/ins_alg_template - ins_temp_broadcast_mesh1D_oneshot.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 "log.h"
      12              : 
      13              : #include "alg_data_trans_wrapper.h"
      14              : #include "ins_alg_template/ins_temp_broadcast_mesh1D_oneshot.h"
      15              : 
      16              : namespace Hccl {
      17            0 : InsTempBroadcastMesh1DOneShot::InsTempBroadcastMesh1DOneShot(
      18              :     const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
      19            0 :     const std::map<RankId, u32>& tempVirtRankMap)
      20            0 :     : InsAlgTemplateBase(virtualRank, tempRankSize, tempVTopo, tempVirtRankMap)
      21            0 : {}
      22              : 
      23            0 : InsTempBroadcastMesh1DOneShot::~InsTempBroadcastMesh1DOneShot() {}
      24              : 
      25            0 : HcclResult InsTempBroadcastMesh1DOneShot::CalcRes(AlgTempResReq& tempResReq)
      26              : {
      27            0 :     tempResReq.queNum = tempVTopo_[0].size() - 1 > 0 ? tempVTopo_[0].size() - 1 : 1;
      28            0 :     tempResReq.streamNum = tempResReq.queNum;
      29            0 :     tempResReq.queNotifys = CreateMasterSlaveQueNotifiesRequest(tempResReq.queNum);
      30            0 :     QId centerQ = 0;
      31            0 :     tempResReq.localWaitGroupCntNotify.emplace_back(centerQ, 0);
      32            0 :     tempResReq.localBcastPostCntNotify.emplace_back(centerQ, 0);
      33            0 :     CHK_RET(CalcResLinksMesh(myRank_, tempRankSize_, tempVTopo_, linkNumBtwPeers_, tempResReq));
      34            0 :     HCCL_DEBUG(
      35              :         "[InsTempBroadcastMesh1DOneShot]CalcRes: queNum[%u], myRank[%d], tempRankSize[%u]", tempResReq.queNum, myRank_,
      36              :         tempRankSize_);
      37            0 :     return HcclResult::HCCL_SUCCESS;
      38              : }
      39              : 
      40            0 : u32 InsTempBroadcastMesh1DOneShot::CalcScratchMultiple(BufferType inBuffType, BufferType outBuffType)
      41              : {
      42              :     (void)inBuffType;
      43              :     (void)outBuffType;
      44            0 :     if (op_.opMode == OpMode::OPBASE) {
      45            0 :         return 1;
      46              :     } else {
      47            0 :         return 0;
      48              :     }
      49              : }
      50              : 
      51            0 : HcclResult InsTempBroadcastMesh1DOneShot::GenExtIns(
      52              :     const TempFuncs& tempFuncs, const TemplateDataParams& templateDataParams, const ResLinks& tempLinks,
      53              :     std::vector<InsQuePtr>& tempInsQues)
      54              : {
      55            0 :     if (tempVTopo_[0].size() == 1) {
      56            0 :         return HcclResult::HCCL_SUCCESS;
      57              :     }
      58              : 
      59            0 :     HCCL_INFO("[InsTempBroadcastMesh1DOneShot][Run] Broadcast1DMesh start: rank[%d] end", myRank_);
      60            0 :     opMode_ = tempFuncs.opMode;
      61            0 :     queNum_ = tempVTopo_[0].size() - 1;
      62            0 :     CHK_PRT_RET(
      63              :         queNum_ != tempInsQues.size(),
      64              :         HCCL_ERROR("[CollAlgFactory] [InsTempBroadcastMesh1DOneShot] Rank [%d], requiredQue Error.", myRank_),
      65              :         HcclResult::HCCL_E_INTERNAL);
      66            0 :     UsrData usrData;
      67            0 :     usrData.usrInSlices.emplace_back(
      68            0 :         BufferType::INPUT, templateDataParams.buffInfo.inBuffBaseOff, templateDataParams.sliceSize);
      69            0 :     usrData.scratchInSlices.emplace_back(BufferType::SCRATCH, 0, templateDataParams.sliceSize);
      70            0 :     usrData.scratchOutSlices.emplace_back(BufferType::SCRATCH, 0, templateDataParams.sliceSize);
      71            0 :     usrData.usrOutSlices.emplace_back(
      72            0 :         BufferType::INPUT, templateDataParams.buffInfo.inBuffBaseOff, templateDataParams.sliceSize);
      73            0 :     if (root_ == u32(myRank_)) {
      74            0 :         CHK_RET(PreSyncInterQueues(tempInsQues));
      75            0 :         for (u32 i = 0; i < tempVTopo_[0].size() - 1; i++) {
      76            0 :             u32 neighborRank = (myRank_ + 1 + i) % tempVTopo_[0].size();
      77            0 :             const LinkData& linkSend = tempLinks.at(neighborRank)[0];
      78            0 :             std::vector<DataSlice> txSlices;
      79            0 :             if (opMode_ == OpMode::OPBASE) {
      80            0 :                 txSlices = usrData.scratchOutSlices;
      81              :             } else {
      82            0 :                 txSlices = usrData.usrInSlices;
      83              :             }
      84            0 :             SlicesList txSlicesList(usrData.usrInSlices, txSlices);
      85            0 :             DataInfo sendData(linkSend, txSlicesList);
      86            0 :             CHK_PRT_RET(
      87              :                 Send(sendData, tempInsQues[i], 0, true, DmaMode::PUT),
      88              :                 HCCL_ERROR("[InsTempBroadcastMesh1DOneShot] BatchSend failed"), HcclResult::HCCL_E_INTERNAL);
      89            0 :         }
      90            0 :         CHK_RET(PostSyncInterQueues(tempInsQues));
      91              :     } else {
      92            0 :         const LinkData& linkRecv = tempLinks.at(root_)[0];
      93            0 :         std::vector<DataSlice> rxSlices;
      94            0 :         if (opMode_ == OpMode::OPBASE) {
      95            0 :             rxSlices = usrData.scratchOutSlices;
      96              :         } else {
      97            0 :             rxSlices = usrData.usrInSlices;
      98              :         }
      99            0 :         SlicesList rxSlicesList(usrData.usrInSlices, rxSlices);
     100            0 :         DataInfo recvData(linkRecv, rxSlicesList);
     101            0 :         CHK_PRT_RET(
     102              :             Recv(recvData, tempInsQues[0], 0, true, DmaMode::PUT),
     103              :             HCCL_ERROR("[InsTempBroadcastMesh1DOneShot] BatchRecv failed"), HcclResult::HCCL_E_INTERNAL);
     104            0 :         if (opMode_ == OpMode::OPBASE) {
     105            0 :             LocalCopySlices(tempInsQues[0], usrData.scratchOutSlices, usrData.usrInSlices);
     106              :         }
     107            0 :     }
     108            0 :     HCCL_INFO("[InsTempBroadcastMesh1DOneShot][Run] Broadcast1DMesh finished: rank[%d] end", myRank_);
     109              : 
     110            0 :     return HcclResult::HCCL_SUCCESS;
     111            0 : }
     112              : 
     113              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1