LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_template/ccu_alg_template - ccu_temp_scatter_mesh_1D.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 59 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_scatter_mesh1d.h"
      17              : #include "ccu_rank_group.h"
      18              : #include "ccu_ctx_creator_registry.h"
      19              : #include "ccu_context_scatter_mesh1d.h"
      20              : #include "ccu_temp_scatter_mesh_1D.h"
      21              : #include "dev_mode.h"
      22              : 
      23              : namespace Hccl {
      24              : 
      25              : static CcuInstRegister<CcuContextScatterMesh1D> g_registrarScatter(CcuInstType::CCU_SCATTER_MESH_1D_DIRECT);
      26              : 
      27            0 : CcuTempScatterMesh1D::CcuTempScatterMesh1D(
      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 : CcuTempScatterMesh1D::~CcuTempScatterMesh1D() {}
      34              : 
      35            0 : uint64_t CcuTempScatterMesh1D::GetExpandedMode() const { return DeviceMode::CCU; }
      36              : 
      37            0 : uint64_t CcuTempScatterMesh1D::GetMaxSliceSize() const { return UB_MAX_DATA_SIZE; }
      38              : 
      39            0 : HcclResult CcuTempScatterMesh1D::CalcRes(AlgTempResReq& tempResReq)
      40              : {
      41            0 :     tempResReq.queNum = 1;
      42            0 :     tempResReq.streamNum = tempResReq.queNum;
      43            0 :     HCCL_INFO("[CalcRes] tempResReq.queNum[%u]", tempResReq.queNum);
      44            0 :     CHK_RET(CalcResLinksMesh(myRank_, tempRankSize_, tempVTopo_, linkNumBtwPeers_, tempResReq));
      45            0 :     return HcclResult::HCCL_SUCCESS;
      46              : }
      47              : 
      48            0 : HcclResult CcuTempScatterMesh1D::GenExtIns(
      49              :     const TempFuncs& tempFuncs, const TemplateDataParams& templateDataParams, const ResLinks& tempLinks,
      50              :     std::vector<InsQuePtr>& tempInsQues)
      51              : {
      52            0 :     CHK_PRT_RET(tempInsQues.empty(), HCCL_ERROR("[CcuTempScatterMesh1D] empty queue"), HcclResult::HCCL_E_INTERNAL);
      53            0 :     CHK_PTR_NULL(tempInsQues[0]);
      54            0 :     HCCL_INFO("[CcuTempScatterMesh1D] Run.");
      55            0 :     opMode_ = tempFuncs.opMode;
      56            0 :     buffInfo_ = templateDataParams.buffInfo;
      57            0 :     CcuInstructionScatterMesh1D ccuIns;
      58            0 :     uint32_t virtRankId = tempVirtRankMap_[myRank_];
      59              : 
      60            0 :     const CollAlgOperator& op = op_;
      61            0 :     const std::vector<std::vector<RankId>>& tempVTopo = tempVTopo_;
      62            0 :     uint64_t rootId = tempVirtRankMap_[rootId_];
      63              :     uint64_t inputAddr
      64            0 :         = BufferTypeToAddr(templateDataParams.buffInfo.inBuffType) + templateDataParams.buffInfo.inBuffBaseOff;
      65              :     uint64_t outputAddr
      66            0 :         = BufferTypeToAddr(templateDataParams.buffInfo.outBuffType) + templateDataParams.buffInfo.outBuffBaseOff;
      67              :     uint64_t token;
      68            0 :     CHK_RET(GetToken(op_, token));
      69            0 :     uint64_t inputSliceStride = templateDataParams.inputSliceStride;
      70            0 :     uint64_t outputSliceStride = templateDataParams.outputSliceStride;
      71            0 :     uint64_t inputRepeatStride = templateDataParams.inputRepeatStride;
      72            0 :     uint64_t outputRepeatStride = templateDataParams.outputRepeatStride;
      73            0 :     uint64_t normalSliceSize = templateDataParams.sliceSize;
      74            0 :     uint64_t lastSliceSize = templateDataParams.tailSize;
      75            0 :     uint64_t repeatNum = templateDataParams.repeatNum;
      76            0 :     uint64_t repeatNumVar = UINT64_MAX - repeatNum; // 在context中让repeatNumVar累加到UINT64_MAX结束ccu while循环
      77              : 
      78            0 :     ccuIns.Init(
      79              :         virtRankId, rootId, op, tempVTopo, inputAddr, outputAddr, token, inputSliceStride, outputSliceStride,
      80              :         inputRepeatStride, outputRepeatStride, normalSliceSize, lastSliceSize, repeatNumVar);
      81            0 :     HCCL_INFO(
      82              :         "[CcuTempScatterMesh1D] Run Init: virtRankId[%u], rankId[%d], inputAddr[%llu], "
      83              :         "outputAddr[%llu], inputSliceStride[%llu], outputSliceStride[%llu], "
      84              :         "inputRepeatStride[%llu], outputRepeatStride[%llu], normalSliceSize[%llu], lastSliceSize[%llu], "
      85              :         "repeatNumVar[%llu]",
      86              :         virtRankId, myRank_, inputAddr, outputAddr, inputSliceStride, outputSliceStride, inputRepeatStride,
      87              :         outputRepeatStride, normalSliceSize, lastSliceSize, repeatNumVar);
      88              : 
      89            0 :     if (normalSliceSize == 0) {
      90            0 :         HCCL_INFO("[CcuTempScatterMesh1D] DataCount == 0, Template Run Ends.");
      91            0 :         return HCCL_SUCCESS;
      92              :     }
      93              : 
      94            0 :     std::vector<LinkData> links;
      95            0 :     for (auto& pair : tempLinks) {
      96            0 :         if (pair.second.empty()) {
      97            0 :             continue;
      98              :         }
      99            0 :         links.push_back(pair.second[0]);
     100              :     }
     101            0 :     HCCL_INFO("[CcuTempScatterMesh1D] links.size[%zu]", links.size());
     102            0 :     ccuIns.SetLinks(links);
     103              : 
     104            0 :     RankGroup rankGroup;
     105            0 :     for (auto& peer : tempVTopo_[0]) {
     106            0 :         rankGroup.AddRank(peer);
     107              :     }
     108            0 :     u32 cntCkeNum = 3;
     109            0 :     ccuIns.SetCntCkeNum(cntCkeNum);
     110            0 :     ccuIns.SetRankGroup(rankGroup);
     111            0 :     HCCL_INFO("CcuInstructionScatterMesh1D is [%s]", ccuIns.Describe().c_str());
     112            0 :     tempInsQues[0]->Append(std::move(std::make_unique<CcuInstructionScatterMesh1D>(ccuIns)));
     113              : 
     114            0 :     return HcclResult::HCCL_SUCCESS;
     115            0 : }
     116              : 
     117            0 : HcclResult CcuTempScatterMesh1D::GenExtIns(
     118              :     const RankGraph* rankGraph, const TemplateInfo& tmpInfo, const std::vector<InsQuePtr>& tempInsQues) const
     119              : {
     120              :     (void)rankGraph;
     121              :     (void)tmpInfo;
     122              :     (void)tempInsQues;
     123            0 :     return HcclResult::HCCL_SUCCESS;
     124              : }
     125              : 
     126              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1