LCOV - code coverage report
Current view: top level - legacy/ascend910/algorithm/impl/coll_executor/coll_all_gather_v - coll_all_gather_v_mesh_graph_executor.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 67 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 6 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_gather_v_mesh_graph_executor.h"
      12              : 
      13              : namespace hccl {
      14            0 : CollAllGatherVMeshGraphExecutor::CollAllGatherVMeshGraphExecutor(const HcclDispatcher dispatcher,
      15            0 :     std::unique_ptr<TopoMatcher> &topoMatcher)
      16            0 :     : CollAllGatherVExecutor(dispatcher, topoMatcher)
      17              : {
      18            0 :     DMAReduceFlag_ = false;
      19            0 : }
      20              : 
      21            0 : HcclResult CollAllGatherVMeshGraphExecutor::CalcStreamNum(u32& streamNum)
      22              : {
      23            0 :     u32 totalStreamNum = topoAttr_.deviceNumPerAggregation > 1U ? topoAttr_.deviceNumPerAggregation - 1U : 1U;
      24            0 :     streamNum = totalStreamNum - 1U;
      25            0 :     HCCL_INFO("[CollAllGatherVMeshGraphExecutor][CalcStreamNum] tag[%s] streamNum[%u]",
      26              :         tag_.c_str(), streamNum);
      27            0 :     return HCCL_SUCCESS;
      28              : }
      29              : 
      30            0 : HcclResult CollAllGatherVMeshGraphExecutor::CalcCommInfo(std::vector<LevelNSubCommTransport>& opTransport)
      31              : {
      32            0 :     TransportMemType inputType = TransportMemType::RESERVED;
      33            0 :     TransportMemType outputType = TransportMemType::RESERVED;
      34            0 :     CHK_RET(CalcTransportMemType(inputType, outputType));
      35            0 :     CHK_RET(CalcLevel0CommInfo(inputType, outputType, opTransport));
      36            0 :     return HCCL_SUCCESS;
      37              : }
      38              : 
      39            0 : HcclResult CollAllGatherVMeshGraphExecutor::CalcTransportMemType(TransportMemType &inputType, TransportMemType &outputType)
      40              : {
      41            0 :     if (workflowMode_ == HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE) {
      42            0 :         inputType = TransportMemType::CCL_INPUT;
      43            0 :         outputType = TransportMemType::CCL_OUTPUT;
      44              :     } else {
      45            0 :         inputType = TransportMemType::PARAM_INPUT;
      46            0 :         outputType = TransportMemType::PARAM_OUTPUT;
      47              :     }
      48            0 :     HCCL_INFO("[CollAllGatherVMeshGraphExecutor][CalcTransportMemType] tag[%s] inputType[%d], outputType[%d]",
      49              :         tag_.c_str(), inputType, outputType);
      50            0 :     return HCCL_SUCCESS;
      51              : }
      52              : 
      53            0 : HcclResult CollAllGatherVMeshGraphExecutor::CalcLevel0CommInfo(TransportMemType inputType, TransportMemType outputType,
      54              :     std::vector<LevelNSubCommTransport>& opTransport)
      55              : {
      56            0 :     CommParaInfo commParaLevel0(COMM_LEVEL0, CommType::COMM_TAG_MESH);
      57            0 :     commParaLevel0.meshSinglePlane = (topoAttr_.deviceType == DevType::DEV_TYPE_910B) &&
      58            0 :         topoMatcher_->GetExternalInputHcclDeterministic() == DETERMINISTIC_DISABLE &&
      59            0 :         (workflowMode_ != HcclWorkflowMode::HCCL_WORKFLOW_MODE_OP_BASE);
      60            0 :     CHK_RET(CalcCommPlaneInfo(tag_, commParaLevel0, opTransport[COMM_LEVEL0], inputType, outputType));
      61            0 :     return HCCL_SUCCESS;
      62            0 : }
      63              : 
      64            0 : HcclResult CollAllGatherVMeshGraphExecutor::KernelRun(const OpParam &param, ExecMem &execMem)
      65              : {
      66            0 :     HCCL_CONFIG_INFO(HCCL_ALG, "[CollAllGatherVMeshGraphExecutor][KernelRun] userRank[%u] starts.", topoAttr_.userRank);
      67            0 :     u32 perDataSize = SIZE_TABLE[param.VDataDes.dataType];
      68              : 
      69              :     // 获取子通信域信息
      70            0 :     CHK_RET(CheckCommSize(COMM_LEVEL0, COMM_INDEX_0 + 1));
      71            0 :     SubCommInfo level0CommInfo = GetSubCommInfo(COMM_LEVEL0, COMM_INDEX_0);
      72            0 :     u32 level0RankSize = level0CommInfo.localRankSize;
      73            0 :     u32 commIndex = level0CommInfo.localRank;
      74              :     // allgatherv 计算slice,数据分成ranksize份,每份的起始偏移和大小
      75            0 :     std::vector<Slice> outputSlices;
      76            0 :     const auto counts = static_cast<u64*>(param.VDataDes.counts);
      77            0 :     const auto displs = static_cast<u64*>(param.VDataDes.displs);
      78            0 :     for (u32 rank = 0; rank < level0RankSize; ++rank) {
      79            0 :         Slice userslice;
      80            0 :         userslice.offset = displs[rank] * perDataSize;
      81            0 :         userslice.size = counts[rank] * perDataSize;
      82            0 :         outputSlices.emplace_back(std::move(userslice));
      83              :     }
      84              : 
      85            0 :     u64 inputMemSize = execMem.inputMem.size();
      86            0 :     u64 level0Offset = outputSlices[commIndex].offset;
      87            0 :     DeviceMem dstMem = execMem.outputMem.range(level0Offset, inputMemSize);// 根据卡序排
      88            0 :     CHK_SMART_PTR_NULL(dstMem);
      89              :     // 将数据从input内存拷贝到output内存的对应位置
      90            0 :     HcclResult ret = HcclD2DMemcpyAsync(dispatcher_, dstMem, execMem.inputMem, const_cast<Stream&>(param.stream));
      91            0 :     CHK_PRT_RET(ret != HCCL_SUCCESS,
      92              :         HCCL_ERROR("[CollAllGatherVMeshGraphExecutor][KernelRun]AllGatherV mesh memcpy Failed, Offset[%llu], Size[%llu].",
      93              :         level0Offset, inputMemSize), ret);
      94              : 
      95            0 :     CHK_RET(ActiveSlaveStreams(param.stream));
      96              : 
      97              :     //  抽取当前用于多环AllGather 的output内存数据
      98            0 :     DeviceMem currentOutputMem = execMem.outputMem;
      99            0 :     CHK_SMART_PTR_NULL(currentOutputMem);
     100              : 
     101            0 :     std::unique_ptr<AlgTemplateBase> level0TempAlg = AlgTemplateRegistry::Instance().GetAlgTemplate(
     102            0 :         TemplateType::TEMPLATE_ALL_GATHER_MESH_ATOMIC, dispatcher_);
     103            0 :     CHK_SMART_PTR_NULL(level0TempAlg);
     104            0 :     CHK_RET(level0TempAlg->Prepare(algResResp_->slaveStreams, algResResp_->notifiesMain, algResResp_->notifiesAux,
     105              :         topoAttr_.userRank, nullptr, commIndex, level0RankSize));
     106            0 :     CHK_RET(level0TempAlg->Prepare(currentOutputMem, currentOutputMem, execMem.inputMem,
     107              :         execMem.count , param.VDataDes.dataType, param.stream, HCCL_REDUCE_RESERVED,
     108              :         LEVEL0_BRIDGE_RANK_ID, outputSlices, 0));
     109            0 :     u32 rankSize = level0RankSize;
     110            0 :     CHK_RET(level0TempAlg->RegisterProfiler((rankSize << PROF_RANKSIZE_OFFSET_OF_PLANEID) + commIndex,
     111              :         PROF_STAGE_1, HCCL_EXEC_STEP_NOT_SET, param.stream));
     112            0 :     CHK_RET(RunTemplate(level0TempAlg, level0CommInfo));
     113            0 :     HCCL_INFO("AllGatherV mesh run success");
     114            0 :     return HCCL_SUCCESS;
     115            0 : }
     116              : 
     117              : REGISTER_EXEC("AllGatherVMeshGraphExecutor", AllGatherVMeshGraph, CollAllGatherVMeshGraphExecutor);
     118              : } // namespace hccl
        

Generated by: LCOV version 2.0-1