LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_all_gather - coll_all_gather_mesh_opbase_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 65 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 9 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_mesh_opbase_executor.h"
      12              : 
      13              : namespace hccl {
      14            0 : CollAllGatherMeshOpbaseExecutor::CollAllGatherMeshOpbaseExecutor(
      15            0 :     const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher)
      16            0 :     : CollAllGatherExecutor(dispatcher, topoMatcher)
      17              : {
      18            0 :     DMAReduceFlag_ = true;
      19            0 : }
      20              : 
      21            0 : HcclResult CollAllGatherMeshOpbaseExecutor::CalcStreamNum(u32& streamNum)
      22              : {
      23            0 :     u32 totalStreamNum = topoAttr_.deviceNumPerAggregation;
      24            0 :     streamNum = totalStreamNum - 1U;
      25            0 :     HCCL_INFO("[CollAllGatherMeshOpbaseExecutor][CalcStreamNum] tag[%s] streamNum[%u]", tag_.c_str(), streamNum);
      26            0 :     return HCCL_SUCCESS;
      27              : }
      28              : 
      29            0 : HcclResult CollAllGatherMeshOpbaseExecutor::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
      30              : {
      31            0 :     TransportMemType inputType = TransportMemType::RESERVED;
      32            0 :     TransportMemType outputType = TransportMemType::RESERVED;
      33            0 :     CHK_RET(CalcTransportMemType(inputType, outputType));
      34            0 :     CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
      35            0 :     return HCCL_SUCCESS;
      36              : }
      37              : 
      38              : HcclResult
      39            0 : CollAllGatherMeshOpbaseExecutor::CalcTransportMemType(TransportMemType& inputType, TransportMemType& outputType)
      40              : {
      41            0 :     if (workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
      42            0 :         inputType = TransportMemType::CCL_INPUT;
      43            0 :         outputType = TransportMemType::CCL_OUTPUT;
      44              :     } else {
      45            0 :         inputType = TransportMemType::PARAM_INPUT;
      46            0 :         outputType = TransportMemType::PARAM_OUTPUT;
      47              :     }
      48            0 :     HCCL_INFO(
      49              :         "[CollAllGatherMeshOpbaseExecutor][CalcTransportMemType] tag[%s] inputType[%d], outputType[%d]", tag_.c_str(),
      50              :         inputType, outputType);
      51            0 :     return HCCL_SUCCESS;
      52              : }
      53              : 
      54            0 : HcclResult CollAllGatherMeshOpbaseExecutor::CalcLevel0CommInfo(
      55              :     TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
      56              : {
      57            0 :     CommParaInfo commParaLevel0(COMM_LEVEL0, CommType::COMM_TAG_MESH);
      58            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaLevel0, opTransport[COMM_LEVEL0], inputType, outputType));
      59            0 :     return HCCL_SUCCESS;
      60            0 : }
      61              : 
      62            0 : u64 CollAllGatherMeshOpbaseExecutor::CalcLoopMaxCount(const u64 cclBuffSize, const u32 unitSize)
      63              : {
      64            0 :     u64 maxCountPerLoop
      65            0 :         = (cclBuffSize - HCCL_MIN_SLICE_ALIGN_910B) / HCCL_MIN_SLICE_ALIGN * HCCL_MIN_SLICE_ALIGN / unitSize;
      66            0 :     return maxCountPerLoop;
      67              : }
      68              : 
      69            0 : bool CollAllGatherMeshOpbaseExecutor::IsHugeData(const u64 curSize)
      70              : {
      71              :     // 该算法只涉及mesh内,不对RDMA多qp做强制刷新
      72            0 :     bool hugeData = curSize > SDMA_SEND_MAX_SIZE;
      73            0 :     return hugeData;
      74              : }
      75              : 
      76            0 : bool CollAllGatherMeshOpbaseExecutor::IsSmallData([[maybe_unused]] const u64 size)
      77              : {
      78            0 :     return topoAttr_.deviceType == DevType::DEV_TYPE_910_93;
      79              : }
      80              : 
      81            0 : HcclResult CollAllGatherMeshOpbaseExecutor::KernelRun(const OpParam& param, ExecMem& execMem)
      82              : {
      83            0 :     HCCL_CONFIG_INFO(HCCL_ALG, "[CollAllGatherMeshOpbaseExecutor] AllGather KernelRun");
      84            0 :     u8* curInputPtr = static_cast<u8*>(execMem.inputPtr);
      85            0 :     u8* curOutputPtr = static_cast<u8*>(execMem.outputPtr);
      86            0 :     CHK_PTR_NULL(curInputPtr);
      87            0 :     CHK_PTR_NULL(curOutputPtr);
      88              : 
      89              :     // 获取子通信域信息
      90            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
      91            0 :     SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
      92              : 
      93            0 :     u64 inputMemSize = execMem.inputMem.size();
      94            0 :     u64 baseOffset = 0;
      95            0 :     std::vector<Slice> dataSegsSlice; // 数据分成ranksize份,每份的起始偏移和大小
      96              : 
      97            0 :     CHK_RET(ActiveSlaveStreams(param.stream));
      98              : 
      99              :     //  抽取当前用于多环AllGather 的output内存数据
     100            0 :     DeviceMem currentOutputMem = execMem.outputMem.range(baseOffset, inputMemSize); // 减少dma out大小
     101            0 :     CHK_SMART_PTR_NULL(currentOutputMem);
     102              : 
     103              :     // DMA消减场景,打包opInfo
     104            0 :     HcomCollOpInfo opInfo = {
     105            0 :         "", execMem.inputPtr, execMem.outputPtr, param.DataDes.count, param.DataDes.dataType, 0, HCCL_REDUCE_RESERVED,
     106            0 :         0};
     107              : 
     108              :     std::unique_ptr<AlgTemplateBase> level0TempAlg
     109            0 :         = AlgTemplateRegistry::Instance().GetAlgTemplate(TemplateType::TEMPLATE_ALL_GATHER_MESH_DIRECT, dispatcher_);
     110            0 :     CHK_SMART_PTR_NULL(level0TempAlg);
     111            0 :     CHK_RET(level0TempAlg->Prepare(
     112              :         algResResp_->slaveStreams, algResResp_->notifiesMain, algResResp_->notifiesAux, topoAttr_.userRank, &opInfo,
     113              :         level0CommInfo.localRank, level0CommInfo.localRankSize));
     114            0 :     CHK_RET(level0TempAlg->Prepare(
     115              :         currentOutputMem, currentOutputMem, execMem.inputMem, execMem.count, param.DataDes.dataType, param.stream,
     116              :         HCCL_REDUCE_RESERVED, LEVEL0_BRIDGE_RANK_ID, dataSegsSlice, baseOffset));
     117              : 
     118            0 :     u32 rankSize = level0CommInfo.localRankSize;
     119            0 :     CHK_RET(level0TempAlg->RegisterProfiler(
     120              :         (rankSize << PROF_RANKSIZE_OFFSET_OF_PLANEID) + level0CommInfo.localRank, PROF_STAGE_1, HCCL_EXEC_STEP_NOT_SET,
     121              :         param.stream));
     122              : 
     123            0 :     CHK_RET(RunTemplate(level0TempAlg, level0CommInfo));
     124              : 
     125            0 :     HCCL_INFO("AllGather mesh level0 run success");
     126            0 :     return HCCL_SUCCESS;
     127            0 : }
     128              : 
     129              : REGISTER_EXEC("AllGatherMeshOpbaseExecutor", AllGatherOpbase, CollAllGatherMeshOpbaseExecutor);
     130              : } // namespace hccl
        

Generated by: LCOV version 2.0-1