LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_all_gather - coll_all_gather_small_count_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 70 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 8 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_gather_small_count_executor.h"
      12              : 
      13              : namespace hccl {
      14            0 : CollAllGatherSmallCountExecutor::CollAllGatherSmallCountExecutor(const HcclDispatcher dispatcher,
      15            0 :                                                      std::unique_ptr<TopoMatcher> &topoMatcher)
      16            0 :     : CollAllGatherExecutor(dispatcher, topoMatcher)
      17              : {
      18            0 :     DMAReduceFlag_ = true;
      19            0 : }
      20              : 
      21            0 : HcclResult CollAllGatherSmallCountExecutor::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(CalcCombinedCommInfo(inputType, outputType, opTransport));
      27            0 :     return HCCL_SUCCESS;
      28              : }
      29              : 
      30            0 : HcclResult CollAllGatherSmallCountExecutor::CalcStreamNum(u32 &streamNum)
      31              : {
      32            0 :     constexpr u64 streamForSmallCount = 3;
      33            0 :     streamNum = streamForSmallCount;
      34            0 :     HCCL_INFO("[CollAllGatherSmallCountExecutor][CalcStreamNum] tag[%s] streamNum[%u]", tag_.c_str(), streamNum);
      35            0 :     return HCCL_SUCCESS;
      36              : }
      37              : 
      38            0 : bool CollAllGatherSmallCountExecutor::IsSmallData(const u64 size)
      39              : {
      40            0 :     return true;
      41              : }
      42              : 
      43            0 : u64 CollAllGatherSmallCountExecutor::CalcLoopMaxCount(const u64 cclBuffSize, const u32 unitSize)
      44              : {
      45              :     // 中转内存单次最多能够接受的output count
      46            0 :     u64 maxCountPerLoop = cclBuffSize / (unitSize * topoAttr_.userRankSize);
      47            0 :     if (topoAttr_.userRankSize % HCCL_DEVICE_NUM_FOUR == 0) {
      48            0 :         maxCountPerLoop = maxCountPerLoop * HCCL_DEVICE_NUM_FOUR;
      49            0 :     } else if (topoAttr_.userRankSize % HCCL_DEVICE_NUM_TWO == 0){
      50            0 :         maxCountPerLoop = maxCountPerLoop * HCCL_DEVICE_NUM_TWO;
      51              :     }
      52            0 :     HCCL_INFO("[CollAllGatherSmallCountExecutor][CalcLoopMaxCount]" \
      53              :         "maxCountPerLoop[%llu]", maxCountPerLoop);
      54            0 :     return maxCountPerLoop;
      55              : }
      56              : 
      57            0 : HcclResult CollAllGatherSmallCountExecutor::CalcTransportMemType(TransportMemType &inputType, TransportMemType &outputType)
      58              : {
      59            0 :     if (workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
      60            0 :         inputType = TransportMemType::CCL_INPUT;
      61            0 :         outputType = TransportMemType::CCL_OUTPUT;
      62              :     } else {
      63            0 :         inputType = TransportMemType::PARAM_INPUT;
      64            0 :         outputType = TransportMemType::PARAM_OUTPUT;
      65              :     }
      66            0 :     HCCL_INFO("[CollAllGatherSmallCountExecutor][CalcTransportMemType] tag[%s] inputType[%d], outputType[%d]",
      67              :         tag_.c_str(), inputType, outputType);
      68            0 :     return HCCL_SUCCESS;
      69              : }
      70              : 
      71            0 : HcclResult CollAllGatherSmallCountExecutor::CalcCombinedCommInfo(TransportMemType inputType, TransportMemType outputType,
      72              :     std::vector<LevelNSubCommTransport>& opTransport)
      73              : {
      74            0 :     CommPlane commPlane = COMM_COMBINE;
      75            0 :     if (topoAttr_.deviceType == DevType::DEV_TYPE_910_93) {
      76            0 :         commPlane = COMM_COMBINE_ORDER;
      77              :     }
      78              : 
      79            0 :     CommParaInfo commParaInfo(commPlane, CommType::COMM_TAG_MESH);
      80            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaInfo, opTransport[commPlane], inputType, outputType));
      81              : 
      82            0 :     return HCCL_SUCCESS;
      83            0 : }
      84              : 
      85            0 : HcclResult CollAllGatherSmallCountExecutor::KernelRun(const OpParam &param, ExecMem &execMem)
      86              : {
      87            0 :     HCCL_CONFIG_INFO(HCCL_ALG, "[%s] starts.", __func__);
      88            0 :     CommPlane commPlane = COMM_COMBINE_ORDER;
      89              : 
      90            0 :     CHK_RET(CheckCommSize(commPlane, COMM_INDEX_0 + 1));
      91            0 :     SubCommInfo combinedCommInfo = GetSubCommInfo(commPlane, COMM_INDEX_0);
      92              : 
      93              :     // 构造ring algorithm对应的all_gather实例
      94            0 :     std::unique_ptr<AlgTemplateBase> algTemplate = AlgTemplateRegistry::Instance().GetAlgTemplate(
      95            0 :         TemplateType::TEMPLATE_ALL_GATHER_HD_STAGE, dispatcher_);
      96            0 :     HCCL_CONFIG_INFO(HCCL_ALG, "[%s] Run TEMPLATE_ALL_GATHER_HD_STAGE in COMM_COMBINE_ORDER", __func__);
      97            0 :     CHK_RET(ActiveSlaveStreams(param.stream));
      98            0 :     HcomCollOpInfo opInfo = {"", execMem.inputPtr, execMem.outputPtr, param.DataDes.count, param.DataDes.dataType,
      99            0 :         param.root, param.reduceType};
     100            0 :     CHK_SMART_PTR_NULL(algTemplate);
     101              : 
     102            0 :     PrepareData prepareData;
     103            0 :     prepareData.userRank = topoAttr_.userRank;
     104            0 :     prepareData.opInfo = &opInfo;
     105            0 :     prepareData.inputMem = execMem.inputMem;
     106            0 :     prepareData.outputMem = execMem.outputMem;
     107            0 :     prepareData.scratchMem = execMem.outputMem;
     108            0 :     prepareData.count = execMem.count;
     109            0 :     prepareData.dataType = param.DataDes.dataType;
     110            0 :     prepareData.stream = param.stream;
     111            0 :     prepareData.subStreamsPtr = &algResResp_->slaveStreams;
     112            0 :     prepareData.signalPtr = &algResResp_->notifiesMain;
     113            0 :     prepareData.signalAuxPtr = &algResResp_->notifiesAux;
     114              : 
     115            0 :     CHK_RET(algTemplate->Prepare(prepareData));
     116              : 
     117            0 :     CHK_RET(RunTemplate(algTemplate, combinedCommInfo));
     118              : 
     119            0 :     return HCCL_SUCCESS;
     120            0 : }
     121              : 
     122              : REGISTER_EXEC("AllGatherSmallCount", AllGatherSmallCount, CollAllGatherSmallCountExecutor);
     123              : 
     124              : } // namespace hccl
        

Generated by: LCOV version 2.0-1