LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_reduce_scatter_v - coll_reduce_scatter_v_mesh_aiv_smallcount_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 85 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_v_mesh_aiv_smallcount_executor.h"
      12              : 
      13              : namespace hccl {
      14            0 : CollReduceScatterVMeshAivSmallCountExecutor::CollReduceScatterVMeshAivSmallCountExecutor(
      15            0 :     const HcclDispatcher dispatcher, std::unique_ptr<TopoMatcher>& topoMatcher)
      16            0 :     : CollReduceScatterVExecutor(dispatcher, topoMatcher)
      17              : {
      18            0 :     DMAReduceFlag_ = false;
      19            0 :     desc_.isAivMode = true;
      20            0 : }
      21              : 
      22            0 : HcclResult CollReduceScatterVMeshAivSmallCountExecutor::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
      23              : {
      24            0 :     TransportMemType inputType = TransportMemType::RESERVED;
      25            0 :     TransportMemType outputType = TransportMemType::RESERVED;
      26            0 :     CHK_RET(CalcTransportMemType(inputType, outputType));
      27            0 :     CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
      28            0 :     return HCCL_SUCCESS;
      29              : }
      30              : 
      31            0 : HcclResult CollReduceScatterVMeshAivSmallCountExecutor::CalcTransportMemType(
      32              :     TransportMemType& inputType, TransportMemType& outputType)
      33              : {
      34            0 :     inputType = TransportMemType::AIV_INPUT;
      35            0 :     outputType = TransportMemType::AIV_OUTPUT;
      36            0 :     HCCL_INFO(
      37              :         "[CollReduceScatterVMeshAivSmallCountExecutor][CalcTransportMemType] tag[%s] inputType[%d],"
      38              :         " outputType[%d].",
      39              :         tag_.c_str(), inputType, outputType);
      40            0 :     return HCCL_SUCCESS;
      41              : }
      42              : 
      43            0 : HcclResult CollReduceScatterVMeshAivSmallCountExecutor::CalcLevel0CommInfo(
      44              :     TransportMemType inputType, TransportMemType outputType, std::vector<LevelNSubCommTransport>& opTransport)
      45              : {
      46            0 :     CommParaInfo commParaLevel0(COMM_LEVEL0, CommType::COMM_TAG_MESH);
      47            0 :     commParaLevel0.meshSinglePlane = true;
      48            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaLevel0, opTransport[COMM_LEVEL0], inputType, outputType));
      49            0 :     return HCCL_SUCCESS;
      50            0 : }
      51              : 
      52            0 : HcclResult CollReduceScatterVMeshAivSmallCountExecutor::CalNumBlocks(
      53              :     u32& numBlocks, u32 rankSize, [[maybe_unused]] u64 dataSize, [[maybe_unused]] HcclCMDType cmdType)
      54              : {
      55            0 :     numBlocks = rankSize; // 默认情况使用rankSize个AIV
      56            0 :     u32 bestNumBlocks = numBlocks;
      57              : 
      58            0 :     CHK_PRT_RET(
      59              :         numBlocks_ < numBlocks,
      60              :         HCCL_WARNING(
      61              :             "[CollReduceScatterVMeshAivSmallCountExecutor][CalNumBlocks]aivCore[%u] is invalid, at least need [%u].",
      62              :             numBlocks_, numBlocks),
      63              :         HCCL_E_PARA);
      64              : 
      65            0 :     HCCL_INFO(
      66              :         "[CollReduceScatterVMeshAivSmallCountExecutor][CalNumBlocks] numBlocks is set to [%u], limit[%u], "
      67              :         "recommanded[%u]",
      68              :         numBlocks, numBlocks_, bestNumBlocks);
      69            0 :     return HCCL_SUCCESS;
      70              : }
      71              : 
      72            0 : HcclResult CollReduceScatterVMeshAivSmallCountExecutor::Orchestrate(OpParam& param, AlgResourceResponse& algRes)
      73              : {
      74            0 :     HcclUs startut = TIME_NOW();
      75            0 :     algResResp_ = &algRes;
      76              : 
      77            0 :     HcclResult ret = HCCL_SUCCESS;
      78            0 :     ExecMem execMem;
      79            0 :     execMem.inputPtr = param.inputPtr;
      80            0 :     execMem.outputPtr = param.outputPtr;
      81              : 
      82              :     // 单算子中/小数据量
      83            0 :     execMem.inputMem = algRes.aivInputMem;
      84            0 :     execMem.outputMem = algRes.aivOutputMem;
      85            0 :     ret = KernelRun(param, execMem);
      86              : 
      87            0 :     CHK_PRT_RET(
      88              :         ret != HCCL_SUCCESS,
      89              :         HCCL_ERROR(
      90              :             "[CollReduceScatterVMeshAivSmallCountExecutor][Orchestrate]errNo[0x%016llx] tag[%s] executor kernel "
      91              :             "run failed.",
      92              :             HCCL_ERROR_CODE(ret), param.tag.c_str()),
      93              :         ret);
      94              : 
      95            0 :     HCCL_INFO(
      96              :         "tag[%s], ReduceScatterV executor orchestrate success, take time [%lld]us.", param.tag.c_str(),
      97              :         DURATION_US(TIME_NOW() - startut));
      98            0 :     return HCCL_SUCCESS;
      99            0 : }
     100              : 
     101            0 : HcclResult CollReduceScatterVMeshAivSmallCountExecutor::KernelRun(const OpParam& param, ExecMem& execMem)
     102              : {
     103            0 :     HCCL_CONFIG_INFO(HCCL_ALG, "[CollReduceScatterVMeshAivSmallCountExecutor][KernelRun]ReduceScatterV aiv enter.");
     104              : 
     105            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
     106            0 :     SubCommInfo outerCommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
     107              : 
     108              :     void* buffersIn[MAX_RANK_SIZE];
     109              :     void* buffersOut[MAX_RANK_SIZE];
     110              : 
     111            0 :     u32 localRank = outerCommInfo.localRank;
     112            0 :     u32 localRankSize = outerCommInfo.localRankSize;
     113            0 :     HCCL_DEBUG(
     114              :         "[CollReduceScatterVMeshAivSmallCountExecutor][KernelRun] userRank [%d] localRank [%d]", topoAttr_.userRank,
     115              :         localRank);
     116              : 
     117            0 :     ExtraArgs extraArgs;
     118            0 :     for (u32 i = 0; i < localRankSize; i++) {
     119            0 :         if (i != localRank) {
     120            0 :             CHK_RET(outerCommInfo.links[i]->GetRemoteMem(UserMemType::INPUT_MEM, &(buffersIn[i])));
     121            0 :             CHK_RET(outerCommInfo.links[i]->GetRemoteMem(UserMemType::OUTPUT_MEM, &(buffersOut[i])));
     122              :         } else {
     123            0 :             buffersIn[i] = execMem.inputMem.ptr();
     124            0 :             buffersOut[i] = execMem.outputMem.ptr();
     125              :         }
     126            0 :         extraArgs.sendCounts[i] = *(static_cast<const u64*>(param.VDataDes.counts) + i);
     127            0 :         extraArgs.sendDispls[i] = *(static_cast<const u64*>(param.VDataDes.displs) + i);
     128            0 :         extraArgs.maxCount = std::max(extraArgs.maxCount, extraArgs.sendCounts[i]);
     129            0 :         HCCL_INFO(
     130              :             "[CollReduceScatterVMeshAivSmallCountExecutor][KernelRun]rank[%u], sendCount[%llu], sendDispl[%llu]", i,
     131              :             extraArgs.sendCounts[i], extraArgs.sendDispls[i]);
     132              :     }
     133              : 
     134            0 :     bool isOpbase = (GetWorkflowMode() == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE);
     135              : 
     136            0 :     AivOpArgs opArgs{
     137              :         HcclCMDType::HCCL_CMD_REDUCE_SCATTER_V,
     138            0 :         execMem.inputPtr,
     139            0 :         execMem.outputPtr,
     140            0 :         extraArgs.maxCount,
     141            0 :         param.VDataDes.dataType,
     142            0 :         param.reduceType,
     143              :         0,
     144            0 :         isOpbase};
     145            0 :     AivTopoArgs topoArgs{localRank, localRankSize};
     146            0 :     topoArgs.identify = algoAttr_.identifier;
     147              :     u32 numBlocks;
     148            0 :     CHK_PRT_RET(
     149              :         CalNumBlocks(numBlocks, localRankSize) != HCCL_SUCCESS, HCCL_ERROR("[%s] CalNumBlocks failed", __func__),
     150              :         HCCL_E_PARA);
     151            0 :     numBlocks_ = numBlocks;
     152            0 :     AivResourceArgs resourceArgs{param.tag,  param.stream.ptr(), buffersIn, buffersOut, execMem.inputMem.size(),
     153            0 :                                  numBlocks_, param.aivTag};
     154            0 :     AivAlgArgs algArgs{};
     155            0 :     algArgs.execTimeOut = topoMatcher_->GetExecTimeOutConfig();
     156            0 :     algArgs.execTimeOutSet = true;
     157            0 :     struct AivProfilingInfo aivProfilingInfo;
     158            0 :     aivProfilingInfo.counter = opCounter_;
     159              : 
     160            0 :     HcclResult ret = ExecuteKernelLaunch(opArgs, topoArgs, resourceArgs, algArgs, extraArgs, aivProfilingInfo);
     161            0 :     CHK_PRT_RET(
     162              :         ret != HCCL_SUCCESS,
     163              :         HCCL_ERROR(
     164              :             "[CollReduceScatterVMeshAivSmallCountExecutor][KernelRun]ReduceScatterV aiv failed, return[%d].", ret),
     165              :         ret);
     166              : 
     167            0 :     HCCL_INFO("[CollReduceScatterVMeshAivSmallCountExecutor][KernelRun]ReduceScatterV aiv run success.");
     168            0 :     return HCCL_SUCCESS;
     169            0 : }
     170              : 
     171              : REGISTER_EXEC(
     172              :     "ReduceScatterVMeshAivSmallCountExecutor", ReduceScatterVMeshAivSmallCount,
     173              :     CollReduceScatterVMeshAivSmallCountExecutor);
     174              : 
     175              : } // namespace hccl
        

Generated by: LCOV version 2.0-1