LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_all_reduce - coll_all_reduce_smallcount_for_910_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 69 0
Test Date: 2026-08-04 10:52:23 Functions: 0.0 % 6 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_smallcount_for_910_executor.h"
      12              : 
      13              : namespace hccl {
      14            0 : CollAllReduceSmallCountFor910Executor::CollAllReduceSmallCountFor910Executor(const HcclDispatcher dispatcher,
      15            0 :     std::unique_ptr<TopoMatcher> &topoMatcher) : CollAllReduceExecutor(dispatcher, topoMatcher)
      16              : {
      17            0 :     DMAReduceFlag_ = true;
      18            0 : }
      19              : 
      20            0 : HcclResult CollAllReduceSmallCountFor910Executor::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
      21              : {
      22            0 :     TransportMemType inputType = TransportMemType::RESERVED;
      23            0 :     TransportMemType outputType = TransportMemType::RESERVED;
      24              : 
      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 CollAllReduceSmallCountFor910Executor::CalcTransportMemType(TransportMemType &inputType,
      31              :     TransportMemType &outputType)
      32              : {
      33            0 :     if (workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
      34            0 :         inputType = TransportMemType::CCL_INPUT;
      35            0 :         outputType = TransportMemType::CCL_OUTPUT;
      36              :     } else {
      37            0 :         inputType = TransportMemType::PARAM_INPUT;
      38            0 :         outputType = TransportMemType::PARAM_OUTPUT;
      39              :     }
      40            0 :     HCCL_INFO("[CollAllReduceSmallCountFor910Executor][CalcTransportMemType]" \
      41              :         "tag[%s] inputType[%d], outputType[%d]", tag_.c_str(), inputType, outputType);
      42            0 :     return HCCL_SUCCESS;
      43              : }
      44              : 
      45            0 : HcclResult CollAllReduceSmallCountFor910Executor::CalcLevel0CommInfo(TransportMemType inputType,
      46              :     TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
      47              : {
      48            0 :     HCCL_INFO("[CollAllReduceSmallCountFor910Executor][CalcLevel0CommInfo]tag[%s] start", tag_.c_str());
      49              : 
      50            0 :     if (algType_.algoLevel0 == AlgTypeLevel0::ALG_LEVEL0_NP_HD) {
      51            0 :         CommParaInfo commParaInfo(COMM_LEVEL0, CommType::COMM_TAG_HALVING_DOUBLING);
      52            0 :         CHK_RET(CalcCommPlaneInfo(tag_, commParaInfo, opTransport[COMM_LEVEL0], inputType, outputType));
      53            0 :     } else {
      54            0 :         HCCL_ERROR("unsupported algType %d plus %d", algType_.algoLevel0, algType_.algoLevel1);
      55            0 :         return HCCL_E_INTERNAL;
      56              :     }
      57              : 
      58            0 :     HCCL_INFO("[CollAllReduceSmallCountFor910Executor][CalcLevel0CommInfo]tag[%s] Calc RingComm finish",
      59              :         tag_.c_str());
      60            0 :     return HCCL_SUCCESS;
      61              : }
      62              : 
      63            0 : HcclResult CollAllReduceSmallCountFor910Executor::Orchestrate(OpParam& param, AlgResourceResponse& algRes)
      64              : {
      65            0 :     HcclUs startut = TIME_NOW();
      66            0 :     CHK_PRT_RET(workflowMode_ != HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE,
      67              :         HCCL_ERROR("[CollAllReduceSmallCountFor910Executor][Orchestrate] only support op base mode."),
      68              :         HCCL_E_NOT_SUPPORT);
      69            0 :     ParseParam(param);
      70            0 :     algResResp_ = &algRes;
      71            0 :     ExecMem execMem;
      72            0 :     execMem.count = param.DataDes.count;
      73            0 :     execMem.inputPtr = param.inputPtr;
      74            0 :     execMem.outputPtr = param.outputPtr;
      75            0 :     execMem.inputMem = algRes.cclInputMem;
      76            0 :     execMem.outputMem = algRes.cclOutputMem;
      77            0 :     execMem.scratchMem = algRes.scratchMem;
      78              : 
      79            0 :     u32 unitSize = SIZE_TABLE[param.DataDes.dataType];
      80            0 :     u64 totalSize = execMem.count * unitSize; // 单位:字节
      81              : 
      82            0 :     DeviceMem inMem(execMem.inputPtr, totalSize);
      83            0 :     DeviceMem inCommMem = execMem.inputMem.range(0, totalSize);
      84            0 :     CHK_RET(HcclD2DMemcpyAsync(dispatcher_, inCommMem, inMem, param.stream));
      85            0 :     HCCL_DEBUG("[CollAllReduceSmallCountFor910Executor][RunLoop]copy from user in to ccl out.");
      86            0 :     HcclResult ret = KernelRun(param, execMem);
      87            0 :     CHK_PRT_RET(ret != HCCL_SUCCESS,
      88              :         HCCL_ERROR("[CollAllReduceSmallCountFor910Executor][Orchestrate]errNo[0x%016llx]executor kernel run failed",
      89              :             HCCL_ERROR_CODE(ret)), ret);
      90            0 :     DeviceMem outMem(execMem.outputPtr, totalSize);
      91            0 :     CHK_RET(HcclD2DMemcpyAsync(dispatcher_, outMem, inCommMem, param.stream));
      92            0 :     HCCL_DEBUG("[CollAllReduceSmallCountFor910Executor][RunLoop]copy from ccl out to usr out.");
      93              : 
      94            0 :     HCCL_INFO("tag[%s], AllReduce executor orchestrate success, take time [%lld]us",
      95              :         param.tag.c_str(), DURATION_US(TIME_NOW() - startut));
      96            0 :     return HCCL_SUCCESS;
      97            0 : }
      98              : 
      99            0 : HcclResult CollAllReduceSmallCountFor910Executor::KernelRun(const OpParam &param, ExecMem &execMem)
     100              : {
     101            0 :     HCCL_CONFIG_INFO(HCCL_ALG,
     102              :         "[CollAllReduceSmallCountFor910Executor][KernelRun] userRank[%u] starts", topoAttr_.userRank);
     103              : 
     104            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
     105            0 :     SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
     106              : 
     107            0 :     u64 reduceAttr = 0;
     108            0 :     std::unique_ptr<AlgTemplateBase> tempAlg;
     109            0 :     tempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(TemplateType::TEMPLATE_ALL_REDUCE_DOUBLING_LOCAL_REDUCE,
     110            0 :         dispatcher_);
     111            0 :     CHK_SMART_PTR_NULL(tempAlg);
     112            0 :     CHK_RET(tempAlg->Prepare(reduceAttr));
     113              : 
     114            0 :     CHK_RET(tempAlg->Prepare(execMem.inputMem, execMem.outputMem, execMem.outputMem, execMem.count,
     115              :         param.DataDes.dataType, param.stream, param.reduceType,
     116              :         LEVEL0_BRIDGE_RANK_ID, std::vector<Slice>(0), 0));
     117              : 
     118            0 :     CHK_RET(tempAlg->RegisterProfiler(
     119              :         (level0CommInfo.localRankSize << PROF_RANKSIZE_OFFSET_OF_PLANEID) + level0CommInfo.localRank,
     120              :         PROF_STAGE_0, HCCL_EXEC_STEP_NOT_SET, param.stream));
     121              : 
     122            0 :     CHK_RET(RunTemplate(tempAlg, level0CommInfo));
     123            0 :     return HCCL_SUCCESS;
     124            0 : }
     125              : 
     126              : REGISTER_EXEC("AllReduceSmallCountFor910", AllReduceSmallCountFor910, CollAllReduceSmallCountFor910Executor);
     127              : } // namespace hccl
        

Generated by: LCOV version 2.0-1