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

Generated by: LCOV version 2.0-1