LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_template/ins_alg_template - ins_temp_reduce_scatter_aicpu_reduce_mesh_2D.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 39 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_reduce_scatter_aicpu_reduce_mesh_2D.h"
      15              : 
      16              : namespace Hccl {
      17            0 : InsTempReduceScatterAicpuReduceMesh2D::InsTempReduceScatterAicpuReduceMesh2D(
      18              :     const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
      19            0 :     const std::map<RankId, u32>& tempVirtRankMap)
      20              :     : InsAlgTemplateBase(virtualRank, tempRankSize, tempVTopo, tempVirtRankMap),
      21            0 :       alltoallMesh2D_(myRank_, tempRankSize_, tempVTopo_, tempVirtRankMap_)
      22            0 : {}
      23              : 
      24            0 : InsTempReduceScatterAicpuReduceMesh2D::~InsTempReduceScatterAicpuReduceMesh2D() {}
      25              : 
      26            0 : HcclResult InsTempReduceScatterAicpuReduceMesh2D::CalcRes(AlgTempResReq& tempResReq)
      27              : {
      28            0 :     CHK_RET(alltoallMesh2D_.CalcRes(tempResReq));
      29            0 :     return HcclResult::HCCL_SUCCESS;
      30              : }
      31              : 
      32            0 : u32 InsTempReduceScatterAicpuReduceMesh2D::CalcScratchMultiple(BufferType inBuffType, BufferType outBuffType) const
      33              : {
      34              :     (void)inBuffType;
      35              :     (void)outBuffType;
      36            0 :     const u32 executor2DTemp = 4;
      37            0 :     return tempRankSize_ * executor2DTemp;
      38              : }
      39              : 
      40            0 : HcclResult InsTempReduceScatterAicpuReduceMesh2D::RunAicpuLocalReduce(
      41              :     const TemplateDataParams& templateDataParams, std::vector<InsQuePtr>& tempInsQues)
      42              : {
      43            0 :     u64 baseOffset = templateDataParams.sliceSize * tempRankSize_;
      44            0 :     DataSlice dataSlice = DataSlice(BufferType::SCRATCH, baseOffset, templateDataParams.sliceSize);
      45            0 :     for (u32 rankId = 1; rankId < tempRankSize_; rankId++) {
      46              :         DataSlice addSlice = DataSlice(
      47            0 :             BufferType::SCRATCH, baseOffset + templateDataParams.sliceSize * rankId, templateDataParams.sliceSize);
      48            0 :         AicpuReduce(tempInsQues[0], addSlice, dataSlice, dataType_, redOp_);
      49              :     }
      50              :     DataSlice outputSlice
      51            0 :         = DataSlice(BufferType::OUTPUT, templateDataParams.buffInfo.inBuffBaseOff, templateDataParams.sliceSize);
      52            0 :     LocalCopy(tempInsQues[0], dataSlice, outputSlice);
      53            0 :     return HCCL_SUCCESS;
      54              : }
      55              : 
      56            0 : HcclResult InsTempReduceScatterAicpuReduceMesh2D::GenExtIns(
      57              :     const TempFuncs& tempFuncs, const TemplateDataParams& templateDataParams, const ResLinks& tempLinks,
      58              :     std::vector<InsQuePtr>& tempInsQues)
      59              : {
      60            0 :     HCCL_INFO("[InsTempReduceScatterAicpuReduceMesh2D] Run start");
      61            0 :     if (tempVTopo_[0].size() == 1) {
      62            0 :         return HcclResult::HCCL_SUCCESS;
      63              :     }
      64            0 :     opMode_ = tempFuncs.opMode;
      65            0 :     queNum_ = tempVTopo_[0].size() + tempVTopo_[1].size();
      66            0 :     CHK_PRT_RET(
      67              :         queNum_ > tempInsQues.size(),
      68              :         HCCL_ERROR("[CollAlgFactory] [InsTempReduceScatterAicpuReduceMesh2D] Rank [%d], requiredQue Error.", myRank_),
      69              :         HcclResult::HCCL_E_INTERNAL);
      70              : 
      71            0 :     TempFuncs alltoallFuncs = tempFuncs;
      72            0 :     TemplateDataParams alltoallParams = templateDataParams;
      73            0 :     alltoallFuncs.isBottom = false;
      74            0 :     alltoallParams.buffInfo.outBuffBaseOff = templateDataParams.sliceSize * tempRankSize_;
      75            0 :     alltoallParams.outputSliceStride = templateDataParams.sliceSize;
      76            0 :     alltoallMesh2D_.SetDataType(dataType_);
      77            0 :     alltoallMesh2D_.GenExtIns(alltoallFuncs, alltoallParams, tempLinks, tempInsQues);
      78            0 :     StreamSync(tempInsQues);
      79            0 :     RunAicpuLocalReduce(templateDataParams, tempInsQues);
      80            0 :     HCCL_INFO("[InsTempReduceScatterAicpuReduceMesh2D] Run finished");
      81            0 :     return HCCL_SUCCESS;
      82            0 : }
      83              : 
      84              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1