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 % 84 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_executor.h"
      12              : 
      13              : namespace hccl {
      14              : 
      15            0 : AllGatherVMeshAivExecutor::AllGatherVMeshAivExecutor(
      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 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(
      36              :         "[AllGatherVMeshAivExecutor][CalcTransportMemType] tag[%s] inputType[%d], outputType[%d].", tag_.c_str(),
      37              :         inputType, outputType);
      38            0 :     return HCCL_SUCCESS;
      39              : }
      40              : 
      41            0 : HcclResult AllGatherVMeshAivExecutor::CalcLevel0CommInfo(
      42              :     TransportMemType inputType, TransportMemType outputType, 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(
      51              :     u32& numBlocks, u32 rankSize, [[maybe_unused]] u64 dataSize, [[maybe_unused]] HcclCMDType cmdType)
      52              : {
      53            0 :     numBlocks = rankSize + 1; // 单机场景,单算子AllGather大数据使用(rankSize + 1)个aiv
      54            0 :     u32 bestNumBlocks = numBlocks;
      55              : 
      56            0 :     CHK_PRT_RET(
      57              :         numBlocks_ < numBlocks,
      58              :         HCCL_WARNING(
      59              :             "[AllGatherVMeshAivExecutor][CalNumBlocks]aivCore[%u] is invalid, at least need [%u].", numBlocks_,
      60              :             numBlocks),
      61              :         HCCL_E_PARA);
      62              : 
      63            0 :     HCCL_INFO(
      64              :         "[AllGatherVMeshAivExecutor][CalNumBlocks] numBlocks is set to [%u], limit[%u], recommanded[%u]", numBlocks,
      65              :         numBlocks_, bestNumBlocks);
      66            0 :     return HCCL_SUCCESS;
      67              : }
      68              : 
      69            0 : HcclResult AllGatherVMeshAivExecutor::Orchestrate(OpParam& param, AlgResourceResponse& algRes)
      70              : {
      71            0 :     HcclUs startut = TIME_NOW();
      72            0 :     tag_ = param.tag;
      73            0 :     algResResp_ = &algRes;
      74              : 
      75            0 :     HcclResult ret = HCCL_SUCCESS;
      76            0 :     ExecMem execMem;
      77              : 
      78            0 :     execMem.inputPtr = param.inputPtr;
      79            0 :     execMem.outputPtr = param.outputPtr;
      80            0 :     execMem.count = (static_cast<const u64*>(param.VDataDes.counts))[topoAttr_.userRank];
      81              : 
      82            0 :     execMem.inputMem = algRes.cclInputMem;
      83            0 :     execMem.outputMem = algRes.aivOutputMem;
      84            0 :     ret = KernelRun(param, execMem);
      85              : 
      86            0 :     CHK_PRT_RET(
      87              :         ret != HCCL_SUCCESS,
      88              :         HCCL_ERROR(
      89              :             "[AllGatherVMeshAivExecutor][Orchestrate]errNo[0x%016llx] tag[%s] executor kernel run failed",
      90              :             HCCL_ERROR_CODE(ret), param.tag.c_str()),
      91              :         ret);
      92              : 
      93            0 :     HCCL_INFO(
      94              :         "tag[%s], AllGatherVMeshAivExecutor orchestrate success, take time [%lld]us", param.tag.c_str(),
      95              :         DURATION_US(TIME_NOW() - startut));
      96            0 :     return HCCL_SUCCESS;
      97            0 : }
      98              : 
      99            0 : HcclResult AllGatherVMeshAivExecutor::KernelRun(const OpParam& param, ExecMem& execMem)
     100              : {
     101            0 :     HCCL_INFO("[AllGatherVMeshAivExecutor][KernelRun]AllGatherV aiv enter.");
     102              : 
     103            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
     104            0 :     SubCommInfo outerCommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
     105              : 
     106              :     void* buffersIn[MAX_RANK_SIZE];
     107              :     void* buffersOut[MAX_RANK_SIZE];
     108              : 
     109            0 :     u32 localRank = outerCommInfo.localRank;
     110            0 :     u32 localRankSize = outerCommInfo.localRankSize;
     111            0 :     HCCL_DEBUG("[AllGatherVMeshAivExecutor][KernelRun] userRank [%u] localRank [%u]", topoAttr_.userRank, localRank);
     112              : 
     113            0 :     ExtraArgs extraArgs;
     114            0 :     for (u32 i = 0; i < localRankSize; i++) {
     115            0 :         extraArgs.recvCounts[i] = *(static_cast<const u64*>(param.VDataDes.counts) + i);
     116            0 :         extraArgs.recvDispls[i] = *(static_cast<const u64*>(param.VDataDes.displs) + i);
     117            0 :         if (i != localRank) {
     118            0 :             CHK_RET(outerCommInfo.links[i]->GetRemoteMem(UserMemType::INPUT_MEM, &(buffersIn[i])));
     119            0 :             CHK_RET(outerCommInfo.links[i]->GetRemoteMem(UserMemType::OUTPUT_MEM, &(buffersOut[i])));
     120            0 :             HCCL_DEBUG("[AllGatherVMeshAivExecutor][KernelRun] localRank [%u]", localRank);
     121              :         } else {
     122            0 :             buffersIn[i] = execMem.inputMem.ptr();
     123            0 :             buffersOut[i] = execMem.outputMem.ptr();
     124              :         }
     125            0 :         if (extraArgs.recvCounts[i] > extraArgs.maxCount) {
     126            0 :             extraArgs.maxCount = extraArgs.recvCounts[i];
     127              :         }
     128              :     }
     129              : 
     130            0 :     bool isOpbase = (workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE);
     131            0 :     HCCL_DEBUG("[AllGatherVMeshAivExecutor][KernelRun] isOpbase [%d]", isOpbase);
     132            0 :     AivOpArgs opArgs{HcclCMDType::HCCL_CMD_ALLGATHER_V, execMem.inputPtr, execMem.outputPtr, extraArgs.maxCount,
     133            0 :                      param.VDataDes.dataType,           param.reduceType, param.root,        isOpbase};
     134            0 :     AivTopoArgs topoArgs{localRank, localRankSize};
     135              :     u32 numBlocks;
     136            0 :     CHK_PRT_RET(
     137              :         CalNumBlocks(numBlocks, localRankSize) != HCCL_SUCCESS, HCCL_ERROR("[%s] CalNumBlocks failed", __func__),
     138              :         HCCL_E_PARA);
     139            0 :     numBlocks_ = numBlocks;
     140            0 :     topoArgs.identify = algoAttr_.identifier;
     141            0 :     HCCL_DEBUG("[AllGatherVMeshAivExecutor][KernelRun] numBlocks_ [%u]", numBlocks_);
     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, HCCL_ERROR("[AllGatherVMeshAivExecutor][KernelRun]AllGatherV aiv failed, return[%d]", ret),
     153              :         ret);
     154              : 
     155            0 :     HCCL_INFO("[AllGatherVMeshAivExecutor][KernelRun]AllGatherV aiv run success.");
     156            0 :     return HCCL_SUCCESS;
     157            0 : }
     158              : 
     159              : REGISTER_EXEC("AllGatherVMeshAivExecutor", AllGatherVAiv, AllGatherVMeshAivExecutor);
     160              : 
     161              : } // namespace hccl
        

Generated by: LCOV version 2.0-1