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 % 81 0
Test Date: 2026-08-18 17:47:01 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(
      16            0 :     const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher)
      17            0 :     : CollAllReduceExecutor(dispatcher, topoMatcher)
      18              : {
      19            0 :     DMAReduceFlag_ = true;
      20            0 : }
      21              : 
      22            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::CalcStreamNum(u32& streamNum)
      23              : {
      24            0 :     u32 totalStreamNum = topoAttr_.deviceNumPerAggregation + 1U;
      25            0 :     streamNum = totalStreamNum - 1U;
      26            0 :     HCCL_INFO(
      27              :         "[CollAllReduceMeshOpbasePipelineExecutor][CalcStreamNum] tag[%s] streamNum[%u]", tag_.c_str(), streamNum);
      28            0 :     return HCCL_SUCCESS;
      29              : }
      30              : 
      31            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
      32              : {
      33            0 :     TransportMemType inputType = TransportMemType::RESERVED;
      34            0 :     TransportMemType outputType = TransportMemType::RESERVED;
      35            0 :     CHK_RET(CalcTransportMemType(inputType, outputType));
      36            0 :     CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
      37            0 :     CHK_RET(CalcLevel1CommInfo(inputType, outputType, opTransport));
      38            0 :     return HCCL_SUCCESS;
      39              : }
      40              : 
      41              : HcclResult
      42            0 : CollAllReduceMeshOpbasePipelineExecutor::CalcTransportMemType(TransportMemType& inputType, TransportMemType& outputType)
      43              : {
      44            0 :     inputType = TransportMemType::CCL_INPUT;
      45            0 :     outputType = TransportMemType::CCL_OUTPUT;
      46            0 :     HCCL_INFO(
      47              :         "[CollAllReduceMeshOpbasePipelineExecutor][CalcTransportMemType]"
      48              :         "tag[%s] inputType[%d], outputType[%d]",
      49              :         tag_.c_str(), inputType, outputType);
      50            0 :     return HCCL_SUCCESS;
      51              : }
      52              : 
      53            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::CalcLevel0CommInfo(
      54              :     TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
      55              : {
      56            0 :     CommParaInfo commParaInfo(COMM_LEVEL0, CommType::COMM_TAG_MESH);
      57            0 :     commParaInfo.meshSinglePlane = true;
      58            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaInfo, opTransport[COMM_LEVEL0], inputType, outputType));
      59            0 :     return HCCL_SUCCESS;
      60            0 : }
      61              : 
      62              : // PipeLine模式下使用Ring算法
      63            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::CalcLevel1CommInfo(
      64              :     TransportMemType inputType, TransportMemType outputType, 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) / unitSize * topoAttr_.userRankSize;
      77            0 :     return maxCountPerLoop;
      78              : }
      79              : 
      80            0 : bool CollAllReduceMeshOpbasePipelineExecutor::IsHugeData(const u64 curSize)
      81              : {
      82            0 :     bool hugeData = curSize / topoAttr_.deviceNumPerAggregation / HCCL_INTERNODE_MAX_DATA_RATE > RDMA_SEND_MAX_SIZE
      83            0 :                     || curSize > SDMA_SEND_MAX_SIZE;
      84            0 :     return hugeData;
      85              : }
      86              : 
      87            0 : bool CollAllReduceMeshOpbasePipelineExecutor::IsSmallData(
      88              :     [[maybe_unused]] const u64 totalSize, [[maybe_unused]] 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(
      96              :         HCCL_ALG, "[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 :            0};
     109              : 
     110            0 :     std::unique_ptr<AlgTemplateBase> tempAlg;
     111            0 :     tempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(
     112            0 :         TemplateType::TEMPLATE_ALL_REDUCE_OPBASE_PIPELINE, dispatcher_);
     113            0 :     CHK_SMART_PTR_NULL(tempAlg);
     114            0 :     CHK_RET(tempAlg->Prepare(reduceAttr));
     115            0 :     CHK_RET(tempAlg->Prepare(
     116              :         &opInfo, execMem.inputMem, execMem.outputMem, execMem.count, level1CommInfo, level0CommInfo,
     117              :         const_cast<Stream&>(param.stream), algResResp_->slaveStreams, algResResp_->notifiesMain,
     118              :         algResResp_->notifiesAux));
     119            0 :     CHK_RET(tempAlg->RunAsync());
     120            0 :     return HCCL_SUCCESS;
     121            0 : }
     122            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::Getlevel1CommRank(SubCommInfo& level1CommInfo)
     123              : {
     124            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
     125            0 :     SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
     126            0 :     u32 ringNum
     127            0 :         = (topoType_ == TopoType::TOPO_TYPE_8P_RING) ? LEVEL0_PLANE_NUM_IN_8PRING : LEVEL0_PLANE_NUM_IN_NPRING_SINGLE;
     128            0 :     u32 commIndex = (ringNum == LEVEL0_PLANE_NUM_IN_8PRING) ? topoAttr_.devicePhyId : level0CommInfo.localRank;
     129              : 
     130            0 :     CHK_RET(CheckCommSize(COMM_LEVEL1, commIndex + 1));
     131            0 :     level1CommInfo = GetSubCommInfo(COMM_LEVEL1, commIndex);
     132              : 
     133            0 :     return HCCL_SUCCESS;
     134            0 : }
     135              : 
     136            0 : HcclResult CollAllReduceMeshOpbasePipelineExecutor::SelectTempAlg(
     137              :     std::unique_ptr<AlgTemplateBase>& level1TempAlg, u32 level1RankSize)
     138              : {
     139            0 :     if (level1RankSize > 1) {
     140            0 :         level1TempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(
     141            0 :             TemplateType::TEMPLATE_ALL_REDUCE_OPBASE_PIPELINE, dispatcher_);
     142            0 :         CHK_SMART_PTR_NULL(level1TempAlg);
     143            0 :         return HCCL_SUCCESS;
     144              :     }
     145            0 :     return HCCL_E_UNAVAIL;
     146              : }
     147              : REGISTER_EXEC(
     148              :     "AllReduceMeshOpbasePipelineExecutor", AllReduceMeshOpbasePipeline, CollAllReduceMeshOpbasePipelineExecutor);
     149              : 
     150              : } // namespace hccl
        

Generated by: LCOV version 2.0-1