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_v_mesh_1D_mem2mem.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 50 0
Test Date: 2026-07-28 12:11:00 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 <ios>
      12              : #include <iostream>
      13              : 
      14              : #include "ccu_temp_reduce_scatter_v_mesh_1D_mem2mem.h"
      15              : #include "ccu_instruction_reduce_scatter_v_mesh1d_mem2mem.h"
      16              : #include "ccu_context_reduce_scatter_v_mesh1d_mem2mem.h"
      17              : 
      18              : #include "log.h"
      19              : #include "ccu_rank_group.h"
      20              : #include "ccu_ctx_creator_registry.h"
      21              : #include "alg_data_trans_wrapper.h"
      22              : 
      23              : namespace Hccl {
      24              : static CcuInstRegister<CcuContextReduceScatterVMeshMem2Mem1D>
      25              :     g_registrarReduceScatterVmem2mem(CcuInstType::CCU_REDUCE_SCATTER_V_MESH_1D_MEM2MEM_DIRECT);
      26              : 
      27            0 : CcuTempReduceScatterVMeshMem2Mem1D::CcuTempReduceScatterVMeshMem2Mem1D(const RankId virtualRank, const u32 tempRankSize,
      28              :                                                          const std::vector<std::vector<RankId>> &tempVTopo,
      29            0 :                                                          const std::map<RankId, u32>            &tempVirtRankMap)
      30            0 :     : CcuAlgTemplateBase(virtualRank, tempRankSize, tempVTopo, tempVirtRankMap)
      31              : {
      32            0 : }
      33              : 
      34            0 : CcuTempReduceScatterVMeshMem2Mem1D::~CcuTempReduceScatterVMeshMem2Mem1D()
      35              : {
      36            0 : }
      37              : 
      38            0 : void CcuTempReduceScatterVMeshMem2Mem1D::InitReduceInfo(const ReduceOp &reduceOp, const DataType &dataType)
      39              : {
      40            0 :     reduceOp_ = reduceOp;
      41            0 :     dataType_ = dataType;
      42            0 : }
      43              : 
      44            0 : HcclResult CcuTempReduceScatterVMeshMem2Mem1D::CalcRes(AlgTempResReq &tempResReq)
      45              : {
      46            0 :     tempResReq.queNum    = 1;
      47            0 :     tempResReq.streamNum = tempResReq.queNum;
      48            0 :     HCCL_INFO("[CalcRes] tempResReq.queNum[%u]", tempResReq.queNum);
      49            0 :     CHK_RET(CalcResLinksMesh(myRank_, tempRankSize_, tempVTopo_, linkNumBtwPeers_, tempResReq));
      50            0 :     return HcclResult::HCCL_SUCCESS;
      51              : }
      52              : 
      53            0 : HcclResult CcuTempReduceScatterVMeshMem2Mem1D::GenExtIns(const TempFuncs          &tempFuncs,
      54              :                                                   const TemplateDataParams &templateDataParams,
      55              :                                                   const ResLinks &tempLinks, std::vector<InsQuePtr> &tempInsQues)
      56              : {
      57            0 :     CHK_PRT_RET(tempInsQues.empty(),
      58              :         HCCL_ERROR("[CcuTempReduceScatterVMeshMem2Mem1D] empty queue"), HcclResult::HCCL_E_INTERNAL);
      59            0 :     CHK_PTR_NULL(tempInsQues[0]);
      60            0 :     opMode_   = tempFuncs.opMode;
      61            0 :     buffInfo_ = templateDataParams.buffInfo;
      62            0 :     CcuInstructionReduceScatterVMeshMem2Mem1D ccuIns;
      63            0 :     std::vector<uint64_t>              dimSize;
      64            0 :     dimSize.push_back(tempRankSize_);
      65              : 
      66              :     uint64_t inputAddr
      67            0 :         = BufferTypeToAddr(templateDataParams.buffInfo.inBuffType) + templateDataParams.buffInfo.inBuffBaseOff;
      68              :     uint64_t outputAddr
      69            0 :         = BufferTypeToAddr(templateDataParams.buffInfo.outBuffType) + templateDataParams.buffInfo.outBuffBaseOff;
      70              :     uint64_t scratchAddr
      71            0 :         = BufferTypeToAddr(templateDataParams.buffInfo.scratBuffType) + templateDataParams.buffInfo.scratchBuffBaseOff;
      72              : 
      73            0 :     uint64_t mySliceSize         = templateDataParams.sliceSize;
      74            0 :     uint64_t mySliceInputOffset  = templateDataParams.inputSliceStride;
      75              : 
      76              :     uint64_t token;
      77            0 :     CHK_RET(GetToken(op_, token));
      78              : 
      79            0 :     ccuIns.Init(static_cast<uint32_t>(myRank_), inputAddr, outputAddr, scratchAddr, mySliceSize, mySliceSize, mySliceInputOffset, token, op_, tempVTopo_);
      80            0 :     HCCL_INFO("[CcuTempReduceScatterVMeshMem2Mem1D] Run Init: myRank_[%d], dimSize[%llu], inputAddr[%llu],"
      81              :               "outputAddr[%llu], mySliceSize[%llu], mySliceInputOffset[%llu]",
      82              :               myRank_, dimSize[0], inputAddr, outputAddr, mySliceSize, mySliceInputOffset);
      83              : 
      84            0 :     std::vector<LinkData> links;
      85            0 :     for (auto &pair : tempLinks) {
      86            0 :         if (pair.second.empty()) {
      87            0 :             continue;
      88              :         }
      89            0 :         links.push_back(pair.second[0]);
      90              :     }
      91            0 :     HCCL_INFO("[CcuTempReduceScatterVMeshMem2Mem1D] links.size[%zu]", links.size());
      92            0 :     ccuIns.SetLinks(links);
      93              : 
      94            0 :     RankGroup rankGroup;
      95            0 :     for (auto &peer : tempVTopo_[0]) {
      96            0 :         rankGroup.AddRank(peer);
      97              :     }
      98            0 :     ccuIns.SetRankGroup(rankGroup);
      99              : 
     100            0 :     u32 cntCkeNum = 3;
     101            0 :     ccuIns.SetCntCkeNum(cntCkeNum);
     102            0 :     tempInsQues[0]->Append(std::move(std::make_unique<CcuInstructionReduceScatterVMeshMem2Mem1D>(ccuIns)));
     103              : 
     104            0 :     return HcclResult::HCCL_SUCCESS;
     105            0 : }
     106              : 
     107            0 : u32 CcuTempReduceScatterVMeshMem2Mem1D::CalcScratchMultiple(BufferType input, BufferType output)
     108              : {
     109              :     (void)input;
     110              :     (void)output;
     111              :     // one shot 场景,scratch Buffer 需要是 usrIn的rankSize倍
     112            0 :     return tempRankSize_;
     113              : }
     114              : 
     115              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1