LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_all_reduce/310P - coll_all_reduce_for_310p_doubling_direct_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 53 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 5 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_for_310p_doubling_direct_executor.h"
      12              : 
      13              : namespace hccl {
      14            0 : CollAllReduceFor310PDoublingDirectExecutor::CollAllReduceFor310PDoublingDirectExecutor(
      15            0 :     const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher)
      16            0 :     : CollAllReduceExecutor(dispatcher, topoMatcher)
      17              : {
      18            0 :     DMAReduceFlag_ = true;
      19            0 : }
      20              : 
      21            0 : HcclResult CollAllReduceFor310PDoublingDirectExecutor::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
      22              : {
      23            0 :     TransportMemType inputType = TransportMemType::RESERVED;
      24            0 :     TransportMemType outputType = TransportMemType::RESERVED;
      25            0 :     CHK_RET(CalcTransportMemType(inputType, outputType));
      26            0 :     CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
      27            0 :     return HCCL_SUCCESS;
      28              : }
      29              : 
      30            0 : HcclResult CollAllReduceFor310PDoublingDirectExecutor::CalcTransportMemType(
      31              :     TransportMemType& inputType, TransportMemType& outputType)
      32              : {
      33            0 :     inputType = TransportMemType::CCL_INPUT;
      34            0 :     outputType = TransportMemType::CCL_OUTPUT;
      35            0 :     HCCL_INFO(
      36              :         "[CollAllReduceFor310PDoublingDirectExecutor][CalcTransportMemType]"
      37              :         "tag[%s] inputType[%d], outputType[%d]",
      38              :         tag_.c_str(), inputType, outputType);
      39            0 :     return HCCL_SUCCESS;
      40              : }
      41              : 
      42            0 : HcclResult CollAllReduceFor310PDoublingDirectExecutor::KernelRun(const OpParam& param, ExecMem& execMem)
      43              : {
      44            0 :     bool isInlineReduce = IsSupportSDMAReduce(
      45            0 :         execMem.inputMem.ptr(), execMem.outputMem.ptr(), param.DataDes.dataType, param.reduceType);
      46            0 :     HCCL_CONFIG_INFO(
      47              :         HCCL_ALG, "[CollAllReduceFor310PDoublingDirectExecutor][KernelRun] userRank[%u] starts with isInlineReduce[%d]",
      48              :         topoAttr_.userRank, isInlineReduce);
      49            0 :     u64 reduceAttr = 0;
      50            0 :     if (isInlineReduce) {
      51            0 :         SalSetBitOne(reduceAttr, ATTR_POS_INLINE_REDUCE);
      52              :     }
      53              : 
      54            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
      55            0 :     SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
      56              : 
      57            0 :     HcomCollOpInfo opInfo
      58            0 :         = {"", execMem.inputPtr, execMem.outputPtr, execMem.count, param.DataDes.dataType, param.root, param.reduceType,
      59            0 :            0};
      60              : 
      61            0 :     std::unique_ptr<AlgTemplateBase> tempAlg;
      62            0 :     tempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(
      63            0 :         TemplateType::TEMPLATE_ALL_REDUCE_DOUBLING_DIRECT, dispatcher_);
      64            0 :     CHK_SMART_PTR_NULL(tempAlg);
      65            0 :     CHK_RET(tempAlg->Prepare(reduceAttr, &opInfo));
      66              : 
      67            0 :     CHK_RET(tempAlg->Prepare(
      68              :         execMem.inputMem, execMem.outputMem, execMem.outputMem, execMem.count, param.DataDes.dataType, param.stream,
      69              :         param.reduceType, LEVEL0_BRIDGE_RANK_ID, std::vector<Slice>(0), 0));
      70              : 
      71            0 :     CHK_RET(tempAlg->RegisterProfiler(
      72              :         (level0CommInfo.localRankSize << PROF_RANKSIZE_OFFSET_OF_PLANEID) + level0CommInfo.localRank, PROF_STAGE_0,
      73              :         HCCL_EXEC_STEP_NOT_SET, param.stream));
      74              : 
      75            0 :     CHK_RET(RunTemplate(tempAlg, level0CommInfo));
      76            0 :     return HCCL_SUCCESS;
      77            0 : }
      78              : 
      79            0 : HcclResult CollAllReduceFor310PDoublingDirectExecutor::CalcLevel0CommInfo(
      80              :     TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
      81              : {
      82            0 :     HCCL_INFO("[CollAllReduceFor310PDoublingDirectExecutor][CalcLevel0CommInfo]tag[%s] start", tag_.c_str());
      83              : 
      84            0 :     if (algType_.algoLevel0 == AlgTypeLevel0::ALG_LEVEL0_NP_HD) {
      85            0 :         CommParaInfo commParaInfo(COMM_LEVEL0, CommType::COMM_TAG_HALVING_DOUBLING);
      86            0 :         CHK_RET(CalcCommPlaneInfo(tag_, commParaInfo, opTransport[COMM_LEVEL0], inputType, outputType));
      87            0 :     } else if (
      88            0 :         algType_.algoLevel0 == AlgTypeLevel0::ALG_LEVEL0_WHOLE_RING
      89            0 :         && algType_.algoLevel1 == AlgTypeLevel1::ALG_LEVEL1_WHOLE_RING) {
      90            0 :         CommParaInfo commParaInfo(COMM_LEVEL0, CommType::COMM_TAG_RING_INNER);
      91            0 :         CHK_RET(CalcCommPlaneInfo(tag_, commParaInfo, opTransport[COMM_LEVEL0], inputType, outputType));
      92            0 :     } else {
      93            0 :         HCCL_ERROR("unsupported algType %d plus %d", algType_.algoLevel0, algType_.algoLevel1);
      94            0 :         return HCCL_E_INTERNAL;
      95              :     }
      96              : 
      97            0 :     HCCL_INFO(
      98              :         "[CollAllReduceFor310PDoublingDirectExecutor][CalcLevel0CommInfo]tag[%s] Calc RingComm finish", tag_.c_str());
      99            0 :     return HCCL_SUCCESS;
     100              : }
     101              : 
     102              : REGISTER_EXEC("AllReduceDoublingDirect", AllReduceFor310PDoublingDirect, CollAllReduceFor310PDoublingDirectExecutor);
     103              : } // namespace hccl
        

Generated by: LCOV version 2.0-1