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

Generated by: LCOV version 2.0-1