LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_broadcast - coll_broadcast_smallcount_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 57 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_broadcast_smallcount_executor.h"
      12              : #include <cmath>
      13              : 
      14              : namespace hccl {
      15              : 
      16            0 : CollBroadcastSmallCountExecutor::CollBroadcastSmallCountExecutor(
      17            0 :     const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher)
      18            0 :     : CollBroadcastExecutor(dispatcher, topoMatcher)
      19              : {
      20            0 :     DMAReduceFlag_ = true;
      21            0 :     if (workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OPS_KERNEL_INFO_LIB) {
      22            0 :         scratchMemFlag_ = true;
      23              :     }
      24            0 : }
      25              : 
      26            0 : void CollBroadcastSmallCountExecutor::ParseParam(const OpParam& param)
      27              : {
      28            0 :     tag_ = param.tag;
      29            0 :     root_ = param.root;
      30            0 :     aicpuUnfoldMode_ = param.aicpuUnfoldMode;
      31            0 :     totalSize_ = param.DataDes.count * SIZE_TABLE[param.DataDes.dataType];
      32            0 : }
      33              : 
      34            0 : HcclResult CollBroadcastSmallCountExecutor::CalcScratchMemSize(u64& scratchMemSize)
      35              : {
      36            0 :     const u32 base = 2;
      37            0 :     scratchMemSize = 0U;
      38            0 :     if (scratchMemFlag_) {
      39            0 :         scratchMemSize = static_cast<u64>(log2(base * topoAttr_.userRankSize - 1)) - 1;
      40            0 :         scratchMemSize *= totalSize_;
      41              :     }
      42            0 :     HCCL_INFO(
      43              :         "[CollBroadcastSmallCountExecutor][CalcScratchMemSize] tag[%s] scratchMemSize[%llu]", tag_.c_str(),
      44              :         scratchMemSize);
      45            0 :     return HCCL_SUCCESS;
      46              : }
      47              : 
      48            0 : HcclResult CollBroadcastSmallCountExecutor::CalcStreamNum(u32& streamNum)
      49              : {
      50            0 :     streamNum = 1;
      51            0 :     HCCL_INFO("[CollBroadcastSmallCountExecutor][CalcStreamNum] tag[%s] streamNum[%u]", tag_.c_str(), streamNum);
      52            0 :     return HCCL_SUCCESS;
      53              : }
      54              : 
      55            0 : HcclResult CollBroadcastSmallCountExecutor::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
      56              : {
      57            0 :     TransportMemType inputType = TransportMemType::RESERVED;
      58            0 :     TransportMemType outputType = TransportMemType::RESERVED;
      59            0 :     CHK_RET(CalcTransportMemType(inputType, outputType));
      60            0 :     CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
      61            0 :     return HCCL_SUCCESS;
      62              : }
      63              : 
      64            0 : HcclResult CollBroadcastSmallCountExecutor::CalcLevel0CommInfo(
      65              :     TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
      66              : {
      67            0 :     CommParaInfo commParaLevel0(COMM_LEVEL0, CommType::COMM_TAG_MESH);
      68            0 :     commParaLevel0.meshSinglePlane = true;
      69            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaLevel0, opTransport[COMM_LEVEL0], inputType, outputType));
      70            0 :     return HCCL_SUCCESS;
      71            0 : }
      72              : 
      73            0 : HcclResult CollBroadcastSmallCountExecutor::KernelRun(const OpParam& param, ExecMem& execMem)
      74              : {
      75            0 :     HCCL_CONFIG_INFO(HCCL_ALG, "[CollBroadcastSmallCountExecutor][KernelRun] userRank[%u] starts.", topoAttr_.userRank);
      76            0 :     std::vector<Slice> dataSegsSlice;
      77              : 
      78            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
      79            0 :     SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
      80            0 :     CHK_RET(ActiveSlaveStreams(param.stream));
      81            0 :     HcomCollOpInfo opInfoPtr
      82            0 :         = {"", execMem.inputPtr, nullptr, param.DataDes.count, param.DataDes.dataType, param.root, param.reduceType, 0};
      83              : 
      84              :     std::unique_ptr<AlgTemplateBase> level0TempAlg
      85            0 :         = AlgTemplateRegistry::Instance().GetAlgTemplate(TemplateType::TEMPLATE_BROADCAST_HD, dispatcher_);
      86            0 :     HCCL_CONFIG_INFO(HCCL_ALG, "[%s] Run TEMPLATE_BROADCAST_HD in COMM_LEVEL0", __func__);
      87            0 :     CHK_SMART_PTR_NULL(level0TempAlg);
      88              : 
      89            0 :     u32 rootRank = 0;
      90            0 :     HcclResult ret = GetRankByUserRank(COMM_LEVEL0, COMM_INDEX_0, param.root, rootRank);
      91            0 :     CHK_PRT_RET(
      92              :         ret != HCCL_SUCCESS,
      93              :         HCCL_ERROR("[CollBroadcastSmallCountExecutor][KernelRun]invalid root [%u] to get userrank", param.root), ret);
      94              : 
      95            0 :     CHK_RET(level0TempAlg->Prepare(
      96              :         execMem.inputMem, execMem.outputMem, execMem.outputMem, execMem.count, param.DataDes.dataType, param.stream,
      97              :         HCCL_REDUCE_RESERVED, rootRank, algResResp_->slaveStreams, algResResp_->notifiesMain, algResResp_->notifiesAux,
      98              :         level0CommInfo.localRank, &opInfoPtr));
      99              : 
     100            0 :     CHK_RET(level0TempAlg->RegisterProfiler(
     101              :         (level0CommInfo.localRankSize << PROF_RANKSIZE_OFFSET_OF_PLANEID) + level0CommInfo.localRank, PROF_STAGE_1,
     102              :         HCCL_EXEC_STEP_NOT_SET, param.stream));
     103            0 :     CHK_RET(RunTemplate(level0TempAlg, level0CommInfo));
     104            0 :     HCCL_INFO("broadcast small count executor run success.");
     105            0 :     return HCCL_SUCCESS;
     106            0 : }
     107              : 
     108              : REGISTER_EXEC("BroadCastSmallCountExecutor", BroadcastSmallCount, CollBroadcastSmallCountExecutor);
     109              : 
     110              : } // namespace hccl
        

Generated by: LCOV version 2.0-1