LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_all_reduce - coll_all_reduce_mesh_opbase_pipeline_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 77 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 12 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_reduce_mesh_opbase_pipeline_executor.h"
      12              : 
      13              : namespace hccl {
      14              : // 准入条件: pipeLine && 910B && 单算子 && sdmaReduce && rdmaReduce && 多Mesh && MeshTopo && 非确定性
      15            0 : CollAllReduceMeshOpbasePipelineExecutor::CollAllReduceMeshOpbasePipelineExecutor(const HcclDispatcher dispatcher,
      16            0 :     std::unique_ptr<TopoMatcher> &topoMatcher): CollAllReduceExecutor(dispatcher, topoMatcher)
      17              : {
      18            0 :     DMAReduceFlag_ = true;
      19            0 : }
      20              : 
      21            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::CalcStreamNum(u32& streamNum)
      22              : {
      23            0 :     u32 totalStreamNum = topoAttr_.deviceNumPerAggregation + 1U;
      24            0 :     streamNum = totalStreamNum - 1U;
      25            0 :     HCCL_INFO("[CollAllReduceMeshOpbasePipelineExecutor][CalcStreamNum] tag[%s] streamNum[%u]",
      26              :         tag_.c_str(), streamNum);
      27            0 :     return HCCL_SUCCESS;
      28              : }
      29              : 
      30            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::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            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::CalcTransportMemType(TransportMemType &inputType,
      41              :     TransportMemType &outputType)
      42              : {
      43            0 :     inputType = TransportMemType::CCL_INPUT;
      44            0 :     outputType = TransportMemType::CCL_OUTPUT;
      45            0 :     HCCL_INFO("[CollAllReduceMeshOpbasePipelineExecutor][CalcTransportMemType]" \
      46              :         "tag[%s] inputType[%d], outputType[%d]",
      47              :         tag_.c_str(), inputType, outputType);
      48            0 :     return HCCL_SUCCESS;
      49              : }
      50              : 
      51            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::CalcLevel0CommInfo(TransportMemType inputType,
      52              :     TransportMemType outputType,
      53              :     std::vector<LevelNSubCommTransport>& opTransport)
      54              : {
      55            0 :     CommParaInfo commParaInfo(COMM_LEVEL0, CommType::COMM_TAG_MESH);
      56            0 :     commParaInfo.meshSinglePlane = true;
      57            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaInfo, opTransport[COMM_LEVEL0], inputType, outputType));
      58            0 :     return HCCL_SUCCESS;
      59            0 : }
      60              : 
      61              : // PipeLine模式下使用Ring算法
      62            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::CalcLevel1CommInfo(TransportMemType inputType,
      63              :     TransportMemType outputType,
      64              :     std::vector<LevelNSubCommTransport>& opTransport)
      65              : {
      66            0 :     CommParaInfo commParaInfo(COMM_LEVEL1, CommType::COMM_TAG_RING_INNER);
      67            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaInfo, opTransport[COMM_LEVEL1], inputType, outputType));
      68            0 :     return HCCL_SUCCESS;
      69            0 : }
      70              : 
      71            0 : u64 CollAllReduceMeshOpbasePipelineExecutor::CalcLoopMaxCount(const u64 cclBuffSize, const u32 unitSize)
      72              : {
      73            0 :     if (cclBuffSize <= HCCL_MIN_SLICE_ALIGN_910B) {
      74            0 :         return 0;
      75              :     }
      76            0 :     u64 maxCountPerLoop = (cclBuffSize - HCCL_MIN_SLICE_ALIGN_910B) /
      77            0 :         unitSize * topoAttr_.userRankSize;
      78            0 :     return maxCountPerLoop;
      79              : }
      80              : 
      81            0 : bool CollAllReduceMeshOpbasePipelineExecutor::IsHugeData(const u64 curSize)
      82              : {
      83            0 :     bool hugeData = curSize / topoAttr_.deviceNumPerAggregation / HCCL_INTERNODE_MAX_DATA_RATE > RDMA_SEND_MAX_SIZE ||
      84              :         curSize > SDMA_SEND_MAX_SIZE;
      85            0 :     return hugeData;
      86              : }
      87              : 
      88            0 : bool CollAllReduceMeshOpbasePipelineExecutor::IsSmallData(const u64 totalSize, const u64 curSize)
      89              : {
      90            0 :     return false;
      91              : }
      92              : 
      93            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::KernelRun(const OpParam &param, ExecMem &execMem)
      94              : {
      95            0 :     HCCL_CONFIG_INFO(HCCL_ALG,
      96              :         "[CollAllReduceMeshOpbasePipelineExecutor][Run]CollAllReduceMeshOpbasePipelineExecutor begins.");
      97              : 
      98            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
      99            0 :     SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
     100            0 :     u32 commIndex = level0CommInfo.localRank;
     101            0 :     CHK_RET(CheckCommSize(COMM_LEVEL1, commIndex + 1));
     102            0 :     SubCommInfo level1CommInfo = GetSubCommInfo(COMM_LEVEL1, commIndex);
     103              : 
     104            0 :     u64 reduceAttr = GetReduceAttr(execMem.inputMem, execMem.outputMem, param.DataDes.dataType, param.reduceType);
     105              : 
     106            0 :     HcomCollOpInfo opInfo = {
     107            0 :         "", execMem.inputPtr, execMem.outputPtr, execMem.count, param.DataDes.dataType, param.root, param.reduceType
     108            0 :     };
     109              : 
     110            0 :     std::unique_ptr<AlgTemplateBase> tempAlg;
     111            0 :     tempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(TemplateType::TEMPLATE_ALL_REDUCE_OPBASE_PIPELINE, dispatcher_);
     112            0 :     CHK_SMART_PTR_NULL(tempAlg);
     113            0 :     CHK_RET(tempAlg->Prepare(reduceAttr));
     114            0 :     CHK_RET(tempAlg->Prepare(&opInfo, execMem.inputMem, execMem.outputMem, execMem.count,
     115              :         level1CommInfo, level0CommInfo, const_cast<Stream&>(param.stream),
     116              :         algResResp_->slaveStreams, algResResp_->notifiesMain, algResResp_->notifiesAux));
     117            0 :     CHK_RET(tempAlg->RunAsync());
     118            0 :     return HCCL_SUCCESS;
     119            0 : }
     120            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::Getlevel1CommRank(SubCommInfo& level1CommInfo)
     121              : {
     122            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
     123            0 :     SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
     124            0 :     u32 ringNum = (topoType_ == TopoType::TOPO_TYPE_8P_RING) ? LEVEL0_PLANE_NUM_IN_8PRING :
     125              :         LEVEL0_PLANE_NUM_IN_NPRING_SINGLE;
     126            0 :     u32 commIndex = (ringNum == LEVEL0_PLANE_NUM_IN_8PRING) ? topoAttr_.devicePhyId : level0CommInfo.localRank;
     127              : 
     128            0 :     CHK_RET(CheckCommSize(COMM_LEVEL1, commIndex + 1));
     129            0 :     level1CommInfo = GetSubCommInfo(COMM_LEVEL1, commIndex);
     130              : 
     131            0 :     return HCCL_SUCCESS;
     132            0 : }
     133              : 
     134            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::SelectTempAlg(std::unique_ptr<AlgTemplateBase> &level1TempAlg, u32 level1RankSize)
     135              : {
     136            0 :     if (level1RankSize > 1) {
     137            0 :         level1TempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(TemplateType::TEMPLATE_ALL_REDUCE_OPBASE_PIPELINE, dispatcher_);
     138            0 :         CHK_SMART_PTR_NULL(level1TempAlg);
     139            0 :         return HCCL_SUCCESS;
     140              :     }
     141            0 :     return HCCL_E_UNAVAIL;
     142              : }
     143              : REGISTER_EXEC("AllReduceMeshOpbasePipelineExecutor",
     144              :     AllReduceMeshOpbasePipeline, CollAllReduceMeshOpbasePipelineExecutor);
     145              : 
     146              : } // namespace hccl
        

Generated by: LCOV version 2.0-1