LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_template/ccu_alg_template - ccu_temp_reduce_scatter_mesh_1D_mem2mem.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 62 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 8 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 <ios>
      12              : #include <iostream>
      13              : 
      14              : #include "log.h"
      15              : 
      16              : #include "ccu_instruction_reduce_scatter_mesh1d_mem2mem.h"
      17              : #include "ccu_rank_group.h"
      18              : #include "ccu_ctx_creator_registry.h"
      19              : #include "ccu_context_reduce_scatter_mesh1d_mem2mem.h"
      20              : #include "ccu_temp_reduce_scatter_mesh_1D_mem2mem.h"
      21              : 
      22              : namespace Hccl {
      23              : static CcuInstRegister<CcuContextReduceScatterMeshMem2Mem1D>
      24              :     g_registrarReduceScatter(CcuInstType::CCU_REDUCE_SCATTER_MESH_1D_MEM2MEM);
      25              : 
      26            0 : CcuTempReduceScatterMeshMem2Mem1D::CcuTempReduceScatterMeshMem2Mem1D(
      27              :     const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
      28            0 :     const std::map<RankId, u32>& tempVirtRankMap)
      29            0 :     : CcuAlgTemplateBase(virtualRank, tempRankSize, tempVTopo, tempVirtRankMap)
      30            0 : {}
      31              : 
      32            0 : CcuTempReduceScatterMeshMem2Mem1D::~CcuTempReduceScatterMeshMem2Mem1D() {}
      33              : 
      34            0 : void CcuTempReduceScatterMeshMem2Mem1D::InitReduceInfo(const ReduceOp& reduceOp, const DataType& dataType)
      35              : {
      36            0 :     reduceOp_ = reduceOp;
      37            0 :     dataType_ = dataType;
      38            0 : }
      39              : 
      40            0 : HcclResult CcuTempReduceScatterMeshMem2Mem1D::CalcRes(AlgTempResReq& tempResReq)
      41              : {
      42              :     // 按照IODienum来确定stream数量,支持1D和2D的template
      43            0 :     tempResReq.queNum = 1;
      44            0 :     tempResReq.streamNum = tempResReq.queNum;
      45            0 :     HCCL_DEBUG("[CalcRes] tempResReq.queNum[%u]", tempResReq.queNum);
      46            0 :     CHK_RET(CalcResLinksMesh(myRank_, tempRankSize_, tempVTopo_, linkNumBtwPeers_, tempResReq));
      47            0 :     return HcclResult::HCCL_SUCCESS;
      48              : }
      49              : 
      50            0 : u32 CcuTempReduceScatterMeshMem2Mem1D::CalcScratchMultiple(BufferType input, BufferType output)
      51              : {
      52              :     (void)input;
      53              :     (void)output;
      54              :     // one shot场景,scratch Buffer需要是usrIn的rankSize倍
      55            0 :     return tempRankSize_;
      56              : }
      57              : 
      58            0 : HcclResult CcuTempReduceScatterMeshMem2Mem1D::GenExtIns(
      59              :     const TempFuncs& tempFuncs, const TemplateDataParams& templateDataParams, const ResLinks& tempLinks,
      60              :     std::vector<InsQuePtr>& tempInsQues)
      61              : {
      62            0 :     CHK_PRT_RET(
      63              :         tempInsQues.empty(), HCCL_ERROR("[CcuTempReduceScatterMeshMem2Mem1D] empty queue"),
      64              :         HcclResult::HCCL_E_INTERNAL);
      65            0 :     CHK_PTR_NULL(tempInsQues[0]);
      66            0 :     opMode_ = tempFuncs.opMode;
      67            0 :     buffInfo_ = templateDataParams.buffInfo;
      68            0 :     CcuInstructionReduceScatterMeshMem2Mem1D ccuIns;
      69            0 :     std::vector<uint64_t> dimSize;
      70            0 :     dimSize.push_back(tempRankSize_);
      71              : 
      72            0 :     uint32_t rankId = myRank_;
      73            0 :     uint64_t repeatNumTmp = templateDataParams.repeatNum;
      74            0 :     const CollAlgOperator& op = op_;
      75            0 :     const std::vector<std::vector<RankId>>& tempVTopo = tempVTopo_;
      76            0 :     uint64_t inputAddr = BufferTypeToAddr(buffInfo_.inBuffType) + buffInfo_.inBuffBaseOff;
      77            0 :     uint64_t outputAddr = BufferTypeToAddr(buffInfo_.outBuffType) + buffInfo_.outBuffBaseOff;
      78              :     uint64_t token;
      79            0 :     CHK_RET(GetToken(op_, token));
      80            0 :     uint64_t scratchAddr = BufferTypeToAddr(buffInfo_.scratBuffType) + buffInfo_.scratchBuffBaseOff;
      81            0 :     uint64_t inputSliceStride = templateDataParams.inputSliceStride;
      82            0 :     uint64_t inputRepeatStride = templateDataParams.inputRepeatStride;
      83            0 :     uint64_t outputRepeatStride = templateDataParams.outputRepeatStride;
      84            0 :     uint64_t normalSliceSize = templateDataParams.sliceSize;
      85            0 :     uint64_t lastSliceSize = templateDataParams.tailSize;
      86              : 
      87            0 :     uint64_t repeatNum = UINT64_MAX - repeatNumTmp;
      88            0 :     ccuIns.Init(
      89            0 :         tempVirtRankMap_[rankId], repeatNum, op, tempVTopo, inputAddr, outputAddr, token, scratchAddr, inputSliceStride,
      90              :         inputRepeatStride, outputRepeatStride, normalSliceSize, lastSliceSize);
      91              : 
      92            0 :     HCCL_DEBUG(
      93              :         "[CcuTempReduceScatterMeshMem2Mem1D] Run Init: rankId[%u], repeatNum[%u], inputAddr[%llu], "
      94              :         "outputAddr[%llu], scratchAddr[%llu], inputSliceStride[%llu], "
      95              :         "inputRepeatStride[%llu], outputRepeatStride[%llu], normalSliceSize[%llu], lastSliceSize[%llu]",
      96              :         rankId, repeatNum, inputAddr, outputAddr, scratchAddr, inputSliceStride, inputRepeatStride, outputRepeatStride,
      97              :         normalSliceSize, lastSliceSize);
      98              : 
      99            0 :     std::vector<LinkData> links;
     100            0 :     for (auto& pair : tempLinks) {
     101            0 :         if (pair.second.empty()) {
     102            0 :             continue;
     103              :         }
     104            0 :         links.push_back(pair.second[0]);
     105              :     }
     106            0 :     HCCL_DEBUG("[CcuTempReduceScatterMeshMem2Mem1D] links.size[%zu]", links.size());
     107            0 :     ccuIns.SetLinks(links);
     108              : 
     109            0 :     RankGroup rankGroup;
     110            0 :     for (auto& peer : tempVTopo_[0]) {
     111            0 :         rankGroup.AddRank(peer);
     112              :     }
     113            0 :     u32 cntCkeNum = 4; // context里要用的前后同步的信号数
     114            0 :     ccuIns.SetCntCkeNum(cntCkeNum);
     115            0 :     ccuIns.SetRankGroup(rankGroup);
     116            0 :     HCCL_DEBUG("CcuTempReduceScatterMeshMem2Mem1D is [%s]", ccuIns.Describe().c_str());
     117            0 :     ccuIns.Describe();
     118            0 :     tempInsQues[0]->Append(std::move(std::make_unique<CcuInstructionReduceScatterMeshMem2Mem1D>(
     119              :         ccuIns))); // 将一个新创建的 CcuInstructionReduceScatterMesh1DMem2Mem 对象添加到 tempInsQues[0] 管理的指令队列
     120              : 
     121            0 :     return HcclResult::HCCL_SUCCESS;
     122            0 : }
     123              : 
     124            0 : HcclResult CcuTempReduceScatterMeshMem2Mem1D::GenExtIns(
     125              :     const RankGraph* rankGraph, const TemplateInfo& tmpInfo, const std::vector<InsQuePtr>& tempInsQues) const
     126              : {
     127              :     (void)rankGraph;
     128              :     (void)tmpInfo;
     129              :     (void)tempInsQues;
     130              :     // 框架解析aicpuIns,算法的algCompnnetLite在device侧直接调用Run()
     131            0 :     return HcclResult::HCCL_SUCCESS;
     132              : }
     133              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1