LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_template/ccu_alg_template - ccu_temp_reduce_mesh_1D.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 60 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 "log.h"
      15              : 
      16              : #include "ccu_temp_reduce_mesh_1D.h"
      17              : #include "alg_data_trans_wrapper.h"
      18              : #include "ccu_instruction_reduce_mesh1d.h"
      19              : #include "ccu_rank_group.h"
      20              : #include "ccu_ctx_creator_registry.h"
      21              : #include "ccu_context_reduce_mesh1d.h"
      22              : 
      23              : namespace Hccl {
      24              : 
      25              : static CcuInstRegister<CcuContextReduceMesh1D> registrarReduce(CcuInstType::CCU_REDUCE_MESH_1D_DIRECT);
      26              : 
      27            0 : CcuTempReduceMesh1D::CcuTempReduceMesh1D(
      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 : CcuTempReduceMesh1D::~CcuTempReduceMesh1D() {}
      34              : 
      35            0 : void CcuTempReduceMesh1D::InitReduceInfo(const ReduceOp& reduceOp, const DataType& dataType)
      36              : {
      37            0 :     reduceOp_ = reduceOp;
      38            0 :     dataType_ = dataType;
      39            0 : }
      40              : 
      41            0 : HcclResult CcuTempReduceMesh1D::CalcRes(AlgTempResReq& tempResReq)
      42              : {
      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 : HcclResult CcuTempReduceMesh1D::GenExtIns(
      51              :     const TempFuncs& tempFuncs, const TemplateDataParams& templateDataParams, const ResLinks& tempLinks,
      52              :     std::vector<InsQuePtr>& tempInsQues)
      53              : {
      54            0 :     CHK_PRT_RET(tempInsQues.empty(), HCCL_ERROR("[CcuTempReduceMesh1D] empty queue"), HcclResult::HCCL_E_INTERNAL);
      55            0 :     CHK_PTR_NULL(tempInsQues[0]);
      56            0 :     buffInfo_ = templateDataParams.buffInfo;
      57            0 :     opMode_ = tempFuncs.opMode;
      58            0 :     CcuInstructionReduceMesh1D ccuIns;
      59            0 :     rootId_ = op_.root;
      60            0 :     std::vector<uint64_t> dimSize;
      61            0 :     dimSize.push_back(tempRankSize_);
      62              : 
      63            0 :     uint32_t rankId = myRank_;
      64            0 :     uint32_t rootId = rootId_;
      65            0 :     const CollAlgOperator& op = op_;
      66            0 :     const std::vector<std::vector<RankId>>& tempVTopo = tempVTopo_;
      67            0 :     uint64_t inputAddr = BufferTypeToAddr(buffInfo_.inBuffType) + buffInfo_.inBuffBaseOff;
      68            0 :     uint64_t outputAddr = BufferTypeToAddr(buffInfo_.outBuffType) + buffInfo_.outBuffBaseOff;
      69              :     uint64_t token;
      70            0 :     CHK_RET(GetToken(op_, token));
      71            0 :     uint64_t inputSliceStride = templateDataParams.inputSliceStride;
      72            0 :     uint64_t outputSliceStride = templateDataParams.outputSliceStride;
      73            0 :     uint64_t inputRepeatStride = templateDataParams.inputRepeatStride;
      74            0 :     uint64_t outputRepeatStride = templateDataParams.outputRepeatStride;
      75            0 :     uint64_t repeatNum = templateDataParams.repeatNum;
      76            0 :     uint64_t normalSliceSize = templateDataParams.sliceSize;
      77            0 :     uint64_t lastSliceSize = templateDataParams.tailSize;
      78            0 :     uint64_t repeatNumVar = UINT64_MAX - repeatNum;
      79              : 
      80            0 :     ccuIns.Init(
      81              :         rankId, rootId, op, tempVTopo, inputAddr, outputAddr, token, inputSliceStride, outputSliceStride, repeatNum,
      82              :         inputRepeatStride, outputRepeatStride, normalSliceSize, lastSliceSize, repeatNumVar);
      83              : 
      84            0 :     HCCL_DEBUG(
      85              :         "[CcuTempReduceMesh1D] Run Init: rankId[%u], inputAddr[%llu], "
      86              :         "outputAddr[%llu], inputSliceStride[%llu], outputSliceStride[%llu], repeatNum[%llu], "
      87              :         "inputRepeatStride[%llu], outputRepeatStride[%llu], normalSliceSize[%llu], lastSliceSize[%llu], "
      88              :         "repeatNumVar[%llu]",
      89              :         rankId, inputAddr, outputAddr, inputSliceStride, outputSliceStride, repeatNum, inputRepeatStride,
      90              :         outputRepeatStride, normalSliceSize, lastSliceSize, repeatNumVar);
      91              : 
      92            0 :     std::vector<LinkData> links;
      93            0 :     for (auto& pair : tempLinks) {
      94            0 :         if (pair.second.empty()) {
      95            0 :             continue;
      96              :         }
      97            0 :         links.push_back(pair.second[0]);
      98              :     }
      99            0 :     HCCL_DEBUG("[CcuTempReduceMesh1D] links.size[%zu]", links.size());
     100            0 :     ccuIns.SetLinks(links);
     101              : 
     102            0 :     RankGroup rankGroup;
     103            0 :     for (auto& peer : tempVTopo_[0]) {
     104            0 :         rankGroup.AddRank(peer);
     105              :     }
     106            0 :     u32 cntCkeNum = 4;
     107            0 :     ccuIns.SetCntCkeNum(cntCkeNum);
     108            0 :     ccuIns.SetRankGroup(rankGroup);
     109            0 :     HCCL_DEBUG("CcuInstructionReduceMesh1D is [%s]", ccuIns.Describe().c_str());
     110            0 :     tempInsQues[0]->Append(std::move(std::make_unique<CcuInstructionReduceMesh1D>(ccuIns)));
     111              : 
     112            0 :     return HcclResult::HCCL_SUCCESS;
     113            0 : }
     114              : 
     115            0 : HcclResult CcuTempReduceMesh1D::GenExtIns(
     116              :     const RankGraph* rankGraph, const TemplateInfo& tmpInfo, const std::vector<InsQuePtr>& tempInsQues) const
     117              : {
     118              :     (void)rankGraph;
     119              :     (void)tmpInfo;
     120              :     (void)tempInsQues;
     121              :     // 框架解析aicpuIns,算法的algCompnnetLite在device侧直接调用Run()
     122            0 :     return HcclResult::HCCL_SUCCESS;
     123              : }
     124              : 
     125              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1