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 % 51 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 <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(
      28              :     const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
      29            0 :     const std::map<RankId, u32>& tempVirtRankMap)
      30            0 :     : CcuAlgTemplateBase(virtualRank, tempRankSize, tempVTopo, tempVirtRankMap)
      31            0 : {}
      32              : 
      33            0 : CcuTempReduceScatterVMeshMem2Mem1D::~CcuTempReduceScatterVMeshMem2Mem1D() {}
      34              : 
      35            0 : void CcuTempReduceScatterVMeshMem2Mem1D::InitReduceInfo(const ReduceOp& reduceOp, const DataType& dataType)
      36              : {
      37            0 :     reduceOp_ = reduceOp;
      38            0 :     dataType_ = dataType;
      39            0 : }
      40              : 
      41            0 : HcclResult CcuTempReduceScatterVMeshMem2Mem1D::CalcRes(AlgTempResReq& tempResReq)
      42              : {
      43            0 :     tempResReq.queNum = 1;
      44            0 :     tempResReq.streamNum = tempResReq.queNum;
      45            0 :     HCCL_INFO("[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 : HcclResult CcuTempReduceScatterVMeshMem2Mem1D::GenExtIns(
      51              :     const TempFuncs& tempFuncs, const TemplateDataParams& templateDataParams, const ResLinks& tempLinks,
      52              :     std::vector<InsQuePtr>& tempInsQues)
      53              : {
      54            0 :     CHK_PRT_RET(
      55              :         tempInsQues.empty(), HCCL_ERROR("[CcuTempReduceScatterVMeshMem2Mem1D] empty queue"),
      56              :         HcclResult::HCCL_E_INTERNAL);
      57            0 :     CHK_PTR_NULL(tempInsQues[0]);
      58            0 :     opMode_ = tempFuncs.opMode;
      59            0 :     buffInfo_ = templateDataParams.buffInfo;
      60            0 :     CcuInstructionReduceScatterVMeshMem2Mem1D ccuIns;
      61            0 :     std::vector<uint64_t> dimSize;
      62            0 :     dimSize.push_back(tempRankSize_);
      63              : 
      64              :     uint64_t inputAddr
      65            0 :         = BufferTypeToAddr(templateDataParams.buffInfo.inBuffType) + templateDataParams.buffInfo.inBuffBaseOff;
      66              :     uint64_t outputAddr
      67            0 :         = BufferTypeToAddr(templateDataParams.buffInfo.outBuffType) + templateDataParams.buffInfo.outBuffBaseOff;
      68              :     uint64_t scratchAddr
      69            0 :         = BufferTypeToAddr(templateDataParams.buffInfo.scratBuffType) + templateDataParams.buffInfo.scratchBuffBaseOff;
      70              : 
      71            0 :     uint64_t mySliceSize = templateDataParams.sliceSize;
      72            0 :     uint64_t mySliceInputOffset = templateDataParams.inputSliceStride;
      73              : 
      74              :     uint64_t token;
      75            0 :     CHK_RET(GetToken(op_, token));
      76              : 
      77            0 :     ccuIns.Init(
      78            0 :         static_cast<uint32_t>(myRank_), inputAddr, outputAddr, scratchAddr, mySliceSize, mySliceSize,
      79            0 :         mySliceInputOffset, token, op_, tempVTopo_);
      80            0 :     HCCL_INFO(
      81              :         "[CcuTempReduceScatterVMeshMem2Mem1D] Run Init: myRank_[%d], dimSize[%llu], inputAddr[%llu],"
      82              :         "outputAddr[%llu], mySliceSize[%llu], mySliceInputOffset[%llu]",
      83              :         myRank_, dimSize[0], inputAddr, outputAddr, mySliceSize, mySliceInputOffset);
      84              : 
      85            0 :     std::vector<LinkData> links;
      86            0 :     for (auto& pair : tempLinks) {
      87            0 :         if (pair.second.empty()) {
      88            0 :             continue;
      89              :         }
      90            0 :         links.push_back(pair.second[0]);
      91              :     }
      92            0 :     HCCL_INFO("[CcuTempReduceScatterVMeshMem2Mem1D] links.size[%zu]", links.size());
      93            0 :     ccuIns.SetLinks(links);
      94              : 
      95            0 :     RankGroup rankGroup;
      96            0 :     for (auto& peer : tempVTopo_[0]) {
      97            0 :         rankGroup.AddRank(peer);
      98              :     }
      99            0 :     ccuIns.SetRankGroup(rankGroup);
     100              : 
     101            0 :     u32 cntCkeNum = 3;
     102            0 :     ccuIns.SetCntCkeNum(cntCkeNum);
     103            0 :     tempInsQues[0]->Append(std::move(std::make_unique<CcuInstructionReduceScatterVMeshMem2Mem1D>(ccuIns)));
     104              : 
     105            0 :     return HcclResult::HCCL_SUCCESS;
     106            0 : }
     107              : 
     108            0 : u32 CcuTempReduceScatterVMeshMem2Mem1D::CalcScratchMultiple(BufferType input, BufferType output)
     109              : {
     110              :     (void)input;
     111              :     (void)output;
     112              :     // one shot 场景,scratch Buffer 需要是 usrIn的rankSize倍
     113            0 :     return tempRankSize_;
     114              : }
     115              : 
     116              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1