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.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 47 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 6 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.h"
      15              : #include "ccu_instruction_reduce_scatter_v_mesh1d.h"
      16              : #include "ccu_context_reduce_scatter_v_mesh1d.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<CcuContextReduceScatterVMesh1D>
      25              :     g_registrarReduceScatterV(CcuInstType::CCU_REDUCE_SCATTER_V_MESH_1D_DIRECT);
      26              : 
      27            0 : CcuTempReduceScatterVMesh1D::CcuTempReduceScatterVMesh1D(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 : CcuTempReduceScatterVMesh1D::~CcuTempReduceScatterVMesh1D()
      35              : {
      36            0 : }
      37              : 
      38            0 : void CcuTempReduceScatterVMesh1D::InitReduceInfo(const ReduceOp &reduceOp, const DataType &dataType)
      39              : {
      40            0 :     reduceOp_ = reduceOp;
      41            0 :     dataType_ = dataType;
      42            0 : }
      43              : 
      44            0 : HcclResult CcuTempReduceScatterVMesh1D::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 CcuTempReduceScatterVMesh1D::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("[CcuTempReduceScatterVMesh1D] 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 :     CcuInstructionReduceScatterVMesh1D 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              : 
      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(static_cast<uint32_t>(myRank_), inputAddr, outputAddr, mySliceSize, mySliceInputOffset, token, op_, tempVTopo_);
      78            0 :     HCCL_INFO("[CcuTempReduceScatterVMesh1D] Run Init: myRank_[%d], dimSize[%llu], inputAddr[%llu],"
      79              :               "outputAddr[%llu], mySliceSize[%llu], mySliceInputOffset[%llu]",
      80              :               myRank_, dimSize[0], inputAddr, outputAddr, mySliceSize, mySliceInputOffset);
      81              : 
      82            0 :     std::vector<LinkData> links;
      83            0 :     for (auto &pair : tempLinks) {
      84            0 :         if (pair.second.empty()) {
      85            0 :             continue;
      86              :         }
      87            0 :         links.push_back(pair.second[0]);
      88              :     }
      89            0 :     HCCL_INFO("[CcuTempReduceScatterVMesh1D] links.size[%zu]", links.size());
      90            0 :     ccuIns.SetLinks(links);
      91              : 
      92            0 :     RankGroup rankGroup;
      93            0 :     for (auto &peer : tempVTopo_[0]) {
      94            0 :         rankGroup.AddRank(peer);
      95              :     }
      96            0 :     ccuIns.SetRankGroup(rankGroup);
      97              : 
      98            0 :     u32 cntCkeNum = 3;
      99            0 :     ccuIns.SetCntCkeNum(cntCkeNum);
     100            0 :     tempInsQues[0]->Append(std::move(std::make_unique<CcuInstructionReduceScatterVMesh1D>(ccuIns)));
     101              : 
     102            0 :     return HcclResult::HCCL_SUCCESS;
     103            0 : }
     104              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1