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

Generated by: LCOV version 2.0-1