LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_reduce_scatter_v - coll_reduce_scatter_v_mesh_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 66 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 7 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_reduce_scatter_v_mesh_executor.h"
      12              : #include "alg_template_register.h"
      13              : 
      14              : namespace hccl {
      15              : 
      16            0 : CollReduceScatterVMeshExecutor::CollReduceScatterVMeshExecutor(
      17              :     const HcclDispatcher dispatcher,
      18            0 :     std::unique_ptr<TopoMatcher> &topoMatcher)
      19            0 :     : CollReduceScatterVExecutor(dispatcher, topoMatcher)
      20              : {
      21            0 :     DMAReduceFlag_ = false;
      22            0 : }
      23              : 
      24            0 : void CollReduceScatterVMeshExecutor::ParseParam(const OpParam& param)
      25              : {
      26              :     // 910B 图模式非确定计算,inlineReduce使能,MESH拓扑场景下,创建一个mesh平面
      27            0 :     bool isInlineReduce = IsSupportSDMAReduce(param.inputPtr, param.outputPtr, param.VDataDes.dataType,
      28            0 :         param.reduceType);
      29            0 :     meshSinglePlane_ = (topoAttr_.deviceType == DevType::DEV_TYPE_910B) &&
      30            0 :         topoMatcher_->GetExternalInputHcclDeterministic() == DETERMINISTIC_DISABLE &&
      31            0 :         isInlineReduce && (workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OPS_KERNEL_INFO_LIB);
      32              : 
      33              :     // 记录图模式总数据量
      34            0 :     u64 totalSize = 0;
      35            0 :     const u64* counts = static_cast<const u64*>(param.VDataDes.counts);
      36            0 :     for (u32 i = 0; i < topoAttr_.userRankSize; i++) {
      37            0 :         totalSize += counts[i] * SIZE_TABLE[param.VDataDes.dataType];
      38              :     }
      39            0 :     totalSize_ = totalSize;
      40            0 :     scratchMemFlag_ = false; // mesh算法不需要使用scrachMem
      41            0 :     aicpuUnfoldMode_ = param.aicpuUnfoldMode;
      42            0 : }
      43              : 
      44            0 : HcclResult CollReduceScatterVMeshExecutor::CalcStreamNum(u32& streamNum)
      45              : {
      46            0 :     u32 totalStreamNum = topoAttr_.deviceNumPerAggregation > 1U ? topoAttr_.deviceNumPerAggregation - 1U : 1U;
      47            0 :     streamNum = totalStreamNum - 1U;
      48            0 :     HCCL_INFO("[CollReduceScatterVMeshExecutor][CalcStreamNum] tag[%s] streamNum[%u]",
      49              :         tag_.c_str(), streamNum);
      50            0 :     return HCCL_SUCCESS;
      51              : }
      52              : 
      53            0 : HcclResult CollReduceScatterVMeshExecutor::CalcCommInfo(
      54              :     std::vector<LevelNSubCommTransport>& opTransport)
      55              : {
      56            0 :     TransportMemType inputType = TransportMemType::RESERVED;
      57            0 :     TransportMemType outputType = TransportMemType::RESERVED;
      58            0 :     CHK_RET(CalcTransportMemType(inputType, outputType));
      59            0 :     CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
      60            0 :     return HCCL_SUCCESS;
      61              : }
      62              : 
      63            0 : HcclResult CollReduceScatterVMeshExecutor::CalcTransportMemType(TransportMemType &inputType,
      64              :     TransportMemType &outputType)
      65              : {
      66            0 :     inputType = TransportMemType::PARAM_INPUT;
      67            0 :     outputType = TransportMemType::PARAM_OUTPUT;
      68              : 
      69            0 :     HCCL_INFO("[CollReduceScatterVMeshExecutor][CalcTransportMemType] tag[%s] inputType[%d],"
      70              :         " outputType[%d]", tag_.c_str(), inputType, outputType);
      71            0 :     return HCCL_SUCCESS;
      72              : }
      73              : 
      74            0 : HcclResult CollReduceScatterVMeshExecutor::CalcLevel0CommInfo(TransportMemType inputType,
      75              :     TransportMemType outputType,
      76              :     std::vector<LevelNSubCommTransport>& opTransport)
      77              : {
      78            0 :     CommParaInfo commParaLevel0(COMM_LEVEL0, CommType::COMM_TAG_MESH);
      79            0 :     commParaLevel0.meshSinglePlane = meshSinglePlane_;
      80            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaLevel0, opTransport[COMM_LEVEL0], inputType, outputType));
      81            0 :     return HCCL_SUCCESS;
      82            0 : }
      83              : 
      84            0 : HcclResult CollReduceScatterVMeshExecutor::KernelRun(const OpParam &param, ExecMem &execMem)
      85              : {
      86            0 :     HCCL_CONFIG_INFO(HCCL_ALG, "[CollReduceScatterVMeshExecutor] ReduceScatterV mesh run");
      87            0 :     HcclDataType dataType = param.VDataDes.dataType;
      88            0 :     const u32 unitSize = SIZE_TABLE[dataType];
      89              : 
      90            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
      91            0 :     SubCommInfo subCommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
      92            0 :     u32 rankSize = subCommInfo.localRankSize;
      93              : 
      94            0 :     CHK_RET(ActiveSlaveStreams(param.stream));
      95              : 
      96              :     /* *******************节点内reducescatter ******************************************/
      97              :     // reduce_scatter_v 计算slice,数据分成ranksize份,每份的起始偏移和大小
      98            0 :     std::vector<Slice> inputSlices;
      99            0 :     const auto counts = static_cast<u64*>(param.VDataDes.counts);
     100            0 :     const auto displs = static_cast<u64*>(param.VDataDes.displs);
     101            0 :     for (u32 rank = 0; rank < rankSize; ++rank) {
     102            0 :         Slice userslice;
     103            0 :         userslice.offset = displs[rank] * unitSize;
     104            0 :         userslice.size = counts[rank] * unitSize;
     105            0 :         inputSlices.emplace_back(std::move(userslice));
     106              :     }
     107              : 
     108            0 :     u64 reduceAttr = GetReduceAttr(execMem.inputMem, execMem.outputMem, dataType, param.reduceType);
     109            0 :     std::unique_ptr<AlgTemplateBase> tempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(
     110            0 :         TemplateType::TEMPLATE_REDUCESCATTER_MESH_ATOMIC, dispatcher_);
     111            0 :     CHK_SMART_PTR_NULL(tempAlg);
     112              : 
     113            0 :     CHK_RET(tempAlg->Prepare(execMem.inputMem, execMem.outputMem, execMem.scratchMem, execMem.count, dataType,
     114              :         param.stream, param.reduceType, LEVEL0_BRIDGE_RANK_ID, inputSlices, 0, reduceAttr,
     115              :         algResResp_->slaveStreams, algResResp_->notifiesMain, algResResp_->notifiesAux,
     116              :         topoAttr_.userRank));
     117              : 
     118            0 :     CHK_RET(tempAlg->RegisterProfiler(
     119              :         (subCommInfo.localRankSize << PROF_RANKSIZE_OFFSET_OF_PLANEID) + subCommInfo.localRank,
     120              :         PROF_STAGE_0, HCCL_EXEC_STEP_NOT_SET, param.stream));
     121              : 
     122            0 :     CHK_RET(RunTemplate(tempAlg, subCommInfo));
     123              : 
     124            0 :     return HCCL_SUCCESS;
     125            0 : }
     126              : 
     127              : REGISTER_EXEC("ReduceScatterVMeshExecutor",
     128              :     ReduceScatterVMesh, CollReduceScatterVMeshExecutor);
     129              : }
        

Generated by: LCOV version 2.0-1