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

Generated by: LCOV version 2.0-1