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

Generated by: LCOV version 2.0-1