LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_all_gather - coll_all_gather_mesh_opbase_pipeline_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 71 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 11 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 "coll_all_gather_mesh_opbase_pipeline_executor.h"
      12              : 
      13              : namespace hccl {
      14            0 : CollAllGatherMeshOpbasePipelineExecutor::CollAllGatherMeshOpbasePipelineExecutor(
      15            0 :     const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher)
      16            0 :     : CollAllGatherExecutor(dispatcher, topoMatcher)
      17              : {
      18            0 :     DMAReduceFlag_ = true;
      19            0 : }
      20              : 
      21            0 : HcclResult CollAllGatherMeshOpbasePipelineExecutor::CalcStreamNum(u32& streamNum)
      22              : {
      23            0 :     u32 totalStreamNum = topoAttr_.deviceNumPerAggregation + 1U;
      24            0 :     streamNum = totalStreamNum - 1U;
      25            0 :     HCCL_INFO(
      26              :         "[CollAllGatherMeshOpbasePipelineExecutor][CalcStreamNum] tag[%s] streamNum[%u]", tag_.c_str(), streamNum);
      27            0 :     return HCCL_SUCCESS;
      28              : }
      29              : 
      30            0 : HcclResult CollAllGatherMeshOpbasePipelineExecutor::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
      31              : {
      32            0 :     TransportMemType inputType = TransportMemType::RESERVED;
      33            0 :     TransportMemType outputType = TransportMemType::RESERVED;
      34            0 :     CHK_RET(CalcTransportMemType(inputType, outputType));
      35            0 :     CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
      36            0 :     CHK_RET(CalcLevel1CommInfo(inputType, outputType, opTransport));
      37            0 :     return HCCL_SUCCESS;
      38              : }
      39              : 
      40              : HcclResult
      41            0 : CollAllGatherMeshOpbasePipelineExecutor::CalcTransportMemType(TransportMemType& inputType, TransportMemType& outputType)
      42              : {
      43            0 :     inputType = TransportMemType::CCL_INPUT;
      44            0 :     outputType = TransportMemType::CCL_OUTPUT;
      45            0 :     HCCL_INFO(
      46              :         "[CollAllGatherMeshOpbasePipelineExecutor][CalcTransportMemType]"
      47              :         "tag[%s] inputType[%d], outputType[%d]",
      48              :         tag_.c_str(), inputType, outputType);
      49            0 :     return HCCL_SUCCESS;
      50              : }
      51              : 
      52            0 : HcclResult CollAllGatherMeshOpbasePipelineExecutor::CalcLevel0CommInfo(
      53              :     TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
      54              : {
      55            0 :     CommParaInfo commParaInfo(COMM_LEVEL0, CommType::COMM_TAG_MESH);
      56            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaInfo, opTransport[COMM_LEVEL0], inputType, outputType));
      57            0 :     return HCCL_SUCCESS;
      58            0 : }
      59              : 
      60              : // PipeLine模式下使用Ring算法
      61            0 : HcclResult CollAllGatherMeshOpbasePipelineExecutor::CalcLevel1CommInfo(
      62              :     TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
      63              : {
      64            0 :     CommParaInfo commParaInfo(COMM_LEVEL1, CommType::COMM_TAG_RING_INNER);
      65            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaInfo, opTransport[COMM_LEVEL1], inputType, outputType));
      66            0 :     return HCCL_SUCCESS;
      67            0 : }
      68              : 
      69            0 : u64 CollAllGatherMeshOpbasePipelineExecutor::CalcLoopMaxCount(const u64 cclBuffSize, const u32 unitSize)
      70              : {
      71            0 :     u64 maxCountPerLoop = (cclBuffSize - HCCL_MIN_SLICE_ALIGN_910B) / unitSize;
      72            0 :     return maxCountPerLoop;
      73              : }
      74              : 
      75            0 : bool CollAllGatherMeshOpbasePipelineExecutor::IsHugeData(const u64 curSize)
      76              : {
      77            0 :     bool hugeData = curSize > RDMA_SEND_MAX_SIZE || curSize > SDMA_SEND_MAX_SIZE;
      78            0 :     return hugeData;
      79              : }
      80              : 
      81            0 : HcclResult CollAllGatherMeshOpbasePipelineExecutor::KernelRun(const OpParam& param, ExecMem& execMem)
      82              : {
      83            0 :     HCCL_CONFIG_INFO(
      84              :         HCCL_ALG, "[CollAllGatherMeshOpbasePipelineExecutor][KernelRun]AllGatherMeshOpbasePipelineExecutor begins.");
      85              : 
      86              :     // step 1 先获取 comm level0 \ comm level1 的value
      87            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
      88            0 :     SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
      89            0 :     u32 commIndex = level0CommInfo.localRank;
      90            0 :     CHK_RET(CheckCommSize(COMM_LEVEL1, commIndex + 1));
      91            0 :     SubCommInfo level1CommInfo = GetSubCommInfo(COMM_LEVEL1, commIndex);
      92              : 
      93              :     // DMA消减场景,打包opInfo
      94            0 :     HcomCollOpInfo opInfo = {
      95            0 :         "", execMem.inputPtr, execMem.outputPtr, param.DataDes.count, param.DataDes.dataType, 0, HCCL_REDUCE_RESERVED,
      96            0 :         0};
      97              : 
      98              :     std::unique_ptr<AlgTemplateBase> tempAlg
      99            0 :         = AlgTemplateRegistry::Instance().GetAlgTemplate(TemplateType::TEMPLATE_ALL_GATHER_PIPELINE, dispatcher_);
     100            0 :     CHK_SMART_PTR_NULL(tempAlg);
     101            0 :     CHK_RET(tempAlg->Prepare(
     102              :         &opInfo, topoAttr_.userRank, execMem.count, execMem.inputMem, execMem.outputMem, level0CommInfo, level1CommInfo,
     103              :         const_cast<Stream&>(param.stream), algResResp_->slaveStreams, algResResp_->notifiesMain,
     104              :         algResResp_->notifiesAux));
     105            0 :     CHK_RET(tempAlg->RunAsync());
     106            0 :     return HCCL_SUCCESS;
     107            0 : }
     108              : 
     109            0 : HcclResult CollAllGatherMeshOpbasePipelineExecutor::Getlevel1CommRank(SubCommInfo& level1CommInfo)
     110              : {
     111            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
     112            0 :     SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
     113            0 :     u32 ringNum
     114            0 :         = (topoType_ == TopoType::TOPO_TYPE_8P_RING) ? LEVEL0_PLANE_NUM_IN_8PRING : LEVEL0_PLANE_NUM_IN_NPRING_SINGLE;
     115            0 :     u32 commIndex = (ringNum == LEVEL0_PLANE_NUM_IN_8PRING) ? topoAttr_.devicePhyId : level0CommInfo.localRank;
     116              : 
     117            0 :     CHK_RET(CheckCommSize(COMM_LEVEL1, commIndex + 1));
     118              : 
     119            0 :     level1CommInfo = GetSubCommInfo(COMM_LEVEL1, commIndex);
     120            0 :     HCCL_DEBUG("[CollAllGatherMeshOpbasePipelineExecutor]Getlevel1CommRank for level1CommInfo");
     121            0 :     return HCCL_SUCCESS;
     122            0 : }
     123              : 
     124            0 : HcclResult CollAllGatherMeshOpbasePipelineExecutor::SelectTempAlg(
     125              :     std::unique_ptr<AlgTemplateBase>& level1TempAlg, u32 level1RankSize)
     126              : {
     127            0 :     if (level1RankSize > 1) {
     128              :         level1TempAlg
     129            0 :             = AlgTemplateRegistry::Instance().GetAlgTemplate(TemplateType::TEMPLATE_ALL_GATHER_PIPELINE, dispatcher_);
     130            0 :         CHK_SMART_PTR_NULL(level1TempAlg);
     131            0 :         return HCCL_SUCCESS;
     132              :     }
     133            0 :     return HCCL_E_UNAVAIL;
     134              : }
     135              : REGISTER_EXEC("AllGatherMeshOpbasePipelineExecutor", AllGatherOpbasePipeline, CollAllGatherMeshOpbasePipelineExecutor);
     136              : 
     137              : } // namespace hccl
        

Generated by: LCOV version 2.0-1