LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_reduce_scatter - coll_reduce_scatter_hccs_sio_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 66 0
Test Date: 2026-08-18 17:47:01 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_hccs_sio_executor.h"
      12              : #include "alg_template_register.h"
      13              : 
      14              : namespace hccl {
      15              : 
      16            0 : CollReduceScatterHccsSioExecutor::CollReduceScatterHccsSioExecutor(
      17            0 :     const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher)
      18            0 :     : CollReduceScatterExecutor(dispatcher, topoMatcher)
      19              : {
      20            0 :     desc_.isZeroCopy = false;
      21            0 :     desc_.deterministic = 1;
      22            0 :     DMAReduceFlag_ = true;
      23            0 :     CCLMemSlice_ = false;
      24            0 : }
      25              : 
      26            0 : u64 CollReduceScatterHccsSioExecutor::CalcLoopMaxCount(const u32 unitSize)
      27              : {
      28              :     // 中转内存单次最多能够接受的output count
      29            0 :     u64 maxCountPerLoop = inCCLbufferSize_ / HCCL_MIN_SLICE_ALIGN * HCCL_MIN_SLICE_ALIGN / unitSize;
      30            0 :     HCCL_INFO(
      31              :         "[CollReduceScatterHccsSioExecutor][CalcLoopMaxCount]"
      32              :         "using default maxCountPerLoop[%llu] as CCLBuffSize / (userRankSize * unitSize).",
      33              :         maxCountPerLoop);
      34            0 :     return maxCountPerLoop;
      35              : }
      36              : 
      37            0 : HcclResult CollReduceScatterHccsSioExecutor::CalcStreamNum(u32& streamNum)
      38              : {
      39            0 :     u32 totalStreamNum = topoAttr_.deviceNumPerAggregation + 1U;
      40            0 :     streamNum = totalStreamNum - 1U;
      41            0 :     HCCL_INFO("[CollReduceScatterHccsSioExecutor][CalcStreamNum] tag[%s] streamNum[%u]", tag_.c_str(), streamNum);
      42            0 :     return HCCL_SUCCESS;
      43              : }
      44              : 
      45            0 : HcclResult CollReduceScatterHccsSioExecutor::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
      46              : {
      47            0 :     TransportMemType inputType = TransportMemType::RESERVED;
      48            0 :     TransportMemType outputType = TransportMemType::RESERVED;
      49            0 :     CHK_RET(CalcTransportMemType(inputType, outputType));
      50            0 :     CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
      51            0 :     return HCCL_SUCCESS;
      52              : }
      53              : 
      54              : HcclResult
      55            0 : CollReduceScatterHccsSioExecutor::CalcTransportMemType(TransportMemType& inputType, TransportMemType& outputType)
      56              : {
      57            0 :     if (workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
      58            0 :         inputType = TransportMemType::CCL_INPUT;
      59            0 :         outputType = TransportMemType::CCL_OUTPUT;
      60              :     } else {
      61            0 :         inputType = TransportMemType::PARAM_INPUT;
      62            0 :         outputType = TransportMemType::PARAM_OUTPUT;
      63              :     }
      64            0 :     HCCL_INFO(
      65              :         "[CollReduceScatterHccsSioExecutor][CalcTransportMemType] tag[%s] inputType[%d],"
      66              :         " outputType[%d]",
      67              :         tag_.c_str(), inputType, outputType);
      68            0 :     return HCCL_SUCCESS;
      69              : }
      70              : 
      71            0 : HcclResult CollReduceScatterHccsSioExecutor::CalcLevel0CommInfo(
      72              :     TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
      73              : {
      74            0 :     CommParaInfo commParaLevel0(COMM_LEVEL0, CommType::COMM_TAG_HCCS_PLUS_SIO);
      75            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaLevel0, opTransport[COMM_LEVEL0], inputType, outputType));
      76            0 :     LevelNSubCommTransport& commTransportLevel0 = opTransport[COMM_LEVEL0];
      77            0 :     for (u32 subCommIndex = 0; subCommIndex < commTransportLevel0.size(); subCommIndex++) {
      78            0 :         for (auto& transportRequest :
      79            0 :              commTransportLevel0[subCommIndex].transportRequests) { // 两个transport分别设置ishccs为false、true
      80              :             // 根据子通信索引设置isHccs的值
      81            0 :             transportRequest.linkType = (subCommIndex == 0) ? TransportLinkType::SIO : TransportLinkType::HCCS;
      82            0 :             HCCL_INFO(
      83              :                 "[CollReduceScatterHccsSioExecutor][CalcLevel0CommInfo] set extral notifyNum[%u]",
      84              :                 transportRequest.notifyNum);
      85              :         }
      86              :     }
      87            0 :     return HCCL_SUCCESS;
      88            0 : }
      89              : 
      90            0 : HcclResult CollReduceScatterHccsSioExecutor::KernelRun(const OpParam& param, ExecMem& execMem)
      91              : {
      92            0 :     HCCL_CONFIG_INFO(HCCL_ALG, "[%s] userRank[%u] starts.", __func__, topoAttr_.userRank);
      93            0 :     HcclDataType dataType = param.DataDes.dataType;
      94            0 :     HcomCollOpInfo opInfo = {"",
      95            0 :                              execMem.inputPtr,
      96            0 :                              execMem.outputPtr,
      97            0 :                              param.DataDes.count,
      98            0 :                              param.DataDes.dataType,
      99            0 :                              param.root,
     100            0 :                              param.reduceType,
     101            0 :                              0};
     102              : 
     103            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
     104            0 :     SubCommInfo subCommInfoHccs = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
     105            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_1 + 1));
     106            0 :     SubCommInfo subCommInfoSio = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_1);
     107              : 
     108            0 :     u64 reduceAttr = GetReduceAttr(execMem.inputMem, execMem.outputMem, dataType, param.reduceType);
     109              :     std::unique_ptr<AlgTemplateBase> TempAlg
     110            0 :         = AlgTemplateRegistry::Instance().GetAlgTemplate(TemplateType::TEMPLATE_REDUCESCATTER_HCCS_SIO, dispatcher_);
     111            0 :     HCCL_CONFIG_INFO(HCCL_ALG, "[%s] Run TEMPLATE_REDUCESCATTER_HCCS_SIO in COMM_LEVEL0", __func__);
     112            0 :     CHK_SMART_PTR_NULL(TempAlg);
     113              : 
     114            0 :     CHK_RET(TempAlg->Prepare(
     115              :         execMem.inputMem, execMem.outputMem, execMem.scratchMem, execMem.count, dataType, param.stream,
     116              :         param.reduceType, LEVEL0_BRIDGE_RANK_ID, 0, reduceAttr, algResResp_->slaveStreams, algResResp_->notifiesMain,
     117              :         algResResp_->notifiesAux, topoAttr_.userRank, subCommInfoHccs, subCommInfoSio, &opInfo));
     118              : 
     119            0 :     CHK_RET(TempAlg->RegisterProfiler(
     120              :         (subCommInfoHccs.localRankSize << PROF_RANKSIZE_OFFSET_OF_PLANEID) + subCommInfoHccs.localRank, PROF_STAGE_0,
     121              :         HCCL_EXEC_STEP_NOT_SET, param.stream));
     122              : 
     123            0 :     CHK_RET(RunTemplate(TempAlg, subCommInfoHccs));
     124              : 
     125            0 :     return HCCL_SUCCESS;
     126            0 : }
     127              : 
     128              : REGISTER_EXEC("ReduceScatterHccsSioExecutor", ReduceScatterHccsSio, CollReduceScatterHccsSioExecutor);
     129              : } // namespace hccl
        

Generated by: LCOV version 2.0-1