LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_template/ins_alg_template - ins_temp_all_reduce_aicpu_reduce_mesh_2D.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 48 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 "log.h"
      12              : 
      13              : #include "alg_data_trans_wrapper.h"
      14              : #include "ins_temp_all_reduce_aicpu_reduce_mesh_2D.h"
      15              : #include "ins_temp_all_gather_mesh_2D.h"
      16              : 
      17              : namespace Hccl {
      18            0 : InsTempAllReduceAicpuReduceMesh2D::InsTempAllReduceAicpuReduceMesh2D(
      19              :     const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
      20            0 :     const std::map<RankId, u32>& tempVirtRankMap)
      21            0 :     : InsAlgTemplateBase(virtualRank, tempRankSize, tempVTopo, tempVirtRankMap)
      22            0 : {}
      23              : 
      24            0 : InsTempAllReduceAicpuReduceMesh2D::~InsTempAllReduceAicpuReduceMesh2D() {}
      25              : 
      26            0 : HcclResult InsTempAllReduceAicpuReduceMesh2D::CalcRes(AlgTempResReq& tempResReq)
      27              : {
      28            0 :     const int TwoD = 2;
      29            0 :     CHK_PRT_RET(
      30              :         tempVTopo_.size() < TwoD,
      31              :         HCCL_ERROR("[InsTempAllReduceAicpuReduceMesh2D] tempVTopo_ mismatch size:%zu", tempVTopo_.size()),
      32              :         HcclResult::HCCL_E_INTERNAL);
      33            0 :     CHK_PRT_RET(
      34              :         tempVTopo_[0].size() <= 1 || tempVTopo_[1].size() <= 1,
      35              :         HCCL_ERROR(
      36              :             "[InsTempAllReduceAicpuReduceMesh2D] tempVTopo_ size error, size:%zu %zu", tempVTopo_[0].size(),
      37              :             tempVTopo_[1].size()),
      38              :         HcclResult::HCCL_E_INTERNAL);
      39            0 :     tempResReq.queNum = tempVTopo_[0].size() - 1 + tempVTopo_[1].size() - 1;
      40              : 
      41            0 :     tempResReq.streamNum = tempResReq.queNum;
      42            0 :     tempResReq.queNotifys = CreateMasterSlaveQueNotifiesRequest(tempResReq.queNum);
      43            0 :     HCCL_DEBUG("InsTempAllReduceAicpuReduceMesh2D::CalcRes queNotifys size[%zu]", tempResReq.queNotifys.size());
      44              : 
      45            0 :     QId centerQ = 0;
      46            0 :     tempResReq.localWaitGroupCntNotify.emplace_back(centerQ, 0);
      47            0 :     tempResReq.localBcastPostCntNotify.emplace_back(centerQ, 0);
      48            0 :     CHK_RET(CalcResLinksMesh2D(myRank_, tempVTopo_, linkNumBtwPeers_, tempResReq));
      49            0 :     return HcclResult::HCCL_SUCCESS;
      50              : }
      51              : 
      52            0 : u32 InsTempAllReduceAicpuReduceMesh2D::CalcScratchMultiple(BufferType inBuffType, BufferType outBuffType) const
      53              : {
      54              :     (void)inBuffType;
      55              :     (void)outBuffType;
      56            0 :     return tempRankSize_;
      57              : }
      58              : 
      59            0 : HcclResult InsTempAllReduceAicpuReduceMesh2D::RunAicpuLocalReduce(
      60              :     const TemplateDataParams& templateDataParams, std::vector<InsQuePtr>& tempInsQues)
      61              : {
      62            0 :     DataSlice dataSlice = DataSlice(BufferType::SCRATCH, 0, templateDataParams.sliceSize);
      63            0 :     for (u32 rankId = 1; rankId < tempRankSize_; rankId++) {
      64              :         DataSlice addSlice
      65            0 :             = DataSlice(BufferType::SCRATCH, templateDataParams.sliceSize * rankId, templateDataParams.sliceSize);
      66            0 :         AicpuReduce(tempInsQues[0], addSlice, dataSlice, dataType_, redOp_);
      67              :     }
      68              :     DataSlice outputSlice
      69            0 :         = DataSlice(BufferType::OUTPUT, templateDataParams.buffInfo.inBuffBaseOff, templateDataParams.sliceSize);
      70            0 :     LocalCopy(tempInsQues[0], dataSlice, outputSlice);
      71            0 :     return HCCL_SUCCESS;
      72              : }
      73              : 
      74            0 : HcclResult InsTempAllReduceAicpuReduceMesh2D::GenExtIns(
      75              :     const TempFuncs& tempFuncs, const TemplateDataParams& templateDataParams, const ResLinks& tempLinks,
      76              :     std::vector<InsQuePtr>& tempInsQues)
      77              : {
      78            0 :     HCCL_INFO("[InsTempAllReduceAicpuReduceMesh2D] Run start");
      79            0 :     if (tempVTopo_[0].size() == 1) {
      80            0 :         return HcclResult::HCCL_SUCCESS;
      81              :     }
      82            0 :     opMode_ = tempFuncs.opMode;
      83            0 :     queNum_ = tempVTopo_[0].size() - 1 + tempVTopo_[1].size() - 1;
      84            0 :     CHK_PRT_RET(
      85              :         queNum_ > tempInsQues.size(),
      86              :         HCCL_ERROR("[CollAlgFactory] [InsTempAllReduceAicpuReduceMesh2D] Rank [%d], requiredQue Error.", myRank_),
      87              :         HcclResult::HCCL_E_INTERNAL);
      88              : 
      89            0 :     InsTempAllGatherMesh2D allgatherMesh2D(myRank_, tempRankSize_, tempVTopo_, tempVirtRankMap_);
      90            0 :     TempFuncs allgatherFuncs = tempFuncs;
      91            0 :     TemplateDataParams allgatherParams = templateDataParams;
      92            0 :     allgatherFuncs.isBottom = false;
      93            0 :     allgatherParams.buffInfo.outBuffBaseOff = 0;
      94            0 :     allgatherParams.outputSliceStride = templateDataParams.sliceSize;
      95            0 :     allgatherMesh2D.SetDataType(dataType_);
      96            0 :     allgatherMesh2D.GenExtIns(allgatherFuncs, allgatherParams, tempLinks, tempInsQues);
      97            0 :     StreamSync(tempInsQues);
      98            0 :     RunAicpuLocalReduce(templateDataParams, tempInsQues);
      99            0 :     HCCL_INFO("[InsTempAllReduceAicpuReduceMesh2D] Run finished");
     100            0 :     return HCCL_SUCCESS;
     101            0 : }
     102              : 
     103              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1