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

Generated by: LCOV version 2.0-1