LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_template/ccu_alg_template - ccu_temp_all_gather_mesh_1D_mem2mem.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 66 0
Test Date: 2026-07-28 12:11:00 Functions: 0.0 % 8 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 <ios>
      12              : #include <iostream>
      13              : 
      14              : #include "log.h"
      15              : 
      16              : #include "ccu_instruction_all_gather_mesh1d_mem2mem.h"
      17              : #include "ccu_rank_group.h"
      18              : #include "ccu_ctx_creator_registry.h"
      19              : #include "ccu_context_all_gather_mesh1d_mem2mem.h"
      20              : #include "ccu_temp_all_gather_mesh_1D_mem2mem.h"
      21              : 
      22              : namespace Hccl {
      23              : 
      24              : static CcuInstRegister<CcuContextAllGatherMeshMem2Mem1D> g_registrarAllGather(
      25              :     CcuInstType::CCU_ALLGATHER_MESH_1D_MEM2MEM);
      26              : 
      27            0 : CcuTempAllGatherMeshMem2Mem1D::CcuTempAllGatherMeshMem2Mem1D(const RankId virtualRank, const u32 tempRankSize,
      28              :                                    const std::vector<std::vector<RankId>> &tempVTopo,
      29            0 :                                    const std::map<RankId, u32>            &tempVirtRankMap)
      30            0 :     : CcuAlgTemplateBase(virtualRank, tempRankSize, tempVTopo, tempVirtRankMap)
      31              : {
      32            0 : }
      33              : 
      34            0 : CcuTempAllGatherMeshMem2Mem1D::~CcuTempAllGatherMeshMem2Mem1D()
      35              : {
      36            0 : }
      37              : 
      38            0 : HcclResult CcuTempAllGatherMeshMem2Mem1D::CalcRes(AlgTempResReq &tempResReq)
      39              : {
      40            0 :     tempResReq.queNum = 1;
      41            0 :     tempResReq.streamNum = tempResReq.queNum;
      42            0 :     HCCL_INFO("[CalcRes] tempResReq.queNum[%u]", tempResReq.queNum);
      43            0 :     CHK_RET(CalcResLinksMesh(myRank_, tempRankSize_, tempVTopo_, linkNumBtwPeers_, tempResReq));
      44            0 :     return HcclResult::HCCL_SUCCESS;
      45              : }
      46              : 
      47            0 : HcclResult CcuTempAllGatherMeshMem2Mem1D::CalcSliceInfo(const AllignInfo &allignInfo, const u64 dataSize,
      48              :                                             RankSliceInfo &sliceInfoVec)
      49              : {
      50            0 :     std::vector<SliceInfo> tmp(tempVTopo_.size());
      51            0 :     sliceInfoVec.resize(tempRankSize_, tmp);
      52              : 
      53            0 :     CHK_RET(CalcRsAgSliceInfoMesh(myRank_, tempRankSize_, allignInfo, dataSize, sliceInfoVec));
      54              : 
      55            0 :     return HcclResult::HCCL_SUCCESS;
      56            0 : }
      57              : 
      58            0 : uint64_t CcuTempAllGatherMeshMem2Mem1D::GetMaxSliceSize() const
      59              : {
      60            0 :     return UB_MAX_DATA_SIZE;
      61              : }
      62              : 
      63            0 : void CcuTempAllGatherMeshMem2Mem1D::GetAddrsAndOffset(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec,
      64              :         uint64_t &inputAddr, uint64_t &outputAddr, uint64_t &offset)
      65              : {
      66            0 :     if (opMode_ == OpMode::OPBASE) {
      67            0 :         if (tempFuncs.isForepart) {
      68            0 :             inputAddr = BufferTypeToAddr(tempFuncs.usrData.usrInSlices[0].GetType())
      69            0 :                 + tempFuncs.usrData.usrInSlices[0].GetOffset();
      70              :         } else {
      71            0 :             inputAddr = BufferTypeToAddr(buffInfo_.inBuffType) + buffInfo_.inBuffBaseOff;
      72              :         }
      73            0 :         if (tempFuncs.isBottom) {
      74            0 :             outputAddr = BufferTypeToAddr(tempFuncs.usrData.usrOutSlices[0].GetType());
      75              :             // 需要加上 UserOUt 的偏移,包含了 loop 偏移和 rank 偏移
      76            0 :             offset = tempFuncs.usrData.usrOutSlices[myRank_].GetOffset();
      77              :         } else {
      78            0 :             outputAddr = BufferTypeToAddr(buffInfo_.outBuffType) + buffInfo_.outBuffBaseOff;
      79              :             // 从 inBuff 获取数据,只需要加上 rank 偏移
      80            0 :             offset = sliceInfoVec[myRank_][0].offset;
      81              :         }
      82              :     } else {
      83              :         // 图模式没有 tempFuncs.usrData,直接通过 buffInfo_ 获取输入输出地址
      84            0 :         inputAddr = BufferTypeToAddr(buffInfo_.inBuffType) + buffInfo_.inBuffBaseOff + tempFuncs.usrData.usrInSlices[0].GetOffset();
      85            0 :         outputAddr = BufferTypeToAddr(buffInfo_.outBuffType) + buffInfo_.outBuffBaseOff;
      86            0 :         offset = tempFuncs.usrData.usrOutSlices[myRank_].GetOffset();
      87              :     }
      88              : 
      89            0 :     return;
      90              : }
      91              : 
      92            0 : HcclResult CcuTempAllGatherMeshMem2Mem1D::Run(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec,
      93              :                                               const BuffInfo &buffInfo, const ResLinks &tempLinks,
      94              :                                               std::vector<InsQuePtr> &tempInsQues)
      95              : {
      96            0 :     CHK_PRT_RET(tempInsQues.empty(),
      97              :         HCCL_ERROR("[CcuTempAllGatherMeshMem2Mem1D] empty queue"), HcclResult::HCCL_E_INTERNAL);
      98            0 :     CHK_PTR_NULL(tempInsQues[0]);
      99            0 :     opMode_ = tempFuncs.opMode;
     100            0 :     buffInfo_ = buffInfo;
     101              : 
     102            0 :     CcuInstructionAllGatherMeshMem2Mem1D ccuInsAllGatherMeshMem2Mem1D;
     103              : 
     104            0 :     std::vector<uint64_t> dimSize;
     105            0 :     dimSize.push_back(tempRankSize_);
     106              : 
     107              :     uint64_t inputAddr;
     108              :     uint64_t outputAddr;
     109              :     uint64_t offset;
     110            0 :     GetAddrsAndOffset(tempFuncs, sliceInfoVec, inputAddr, outputAddr, offset);
     111              : 
     112            0 :     uint64_t sliceSize = sliceInfoVec[myRank_][0].size;  // 获取本rank需要处理的数据量
     113              :     uint64_t token;
     114            0 :     CHK_RET(GetToken(op_, token));
     115            0 :     ccuInsAllGatherMeshMem2Mem1D.Init(static_cast<uint32_t>(myRank_), inputAddr, outputAddr, sliceSize, offset, token, op_, tempVTopo_);
     116            0 :     HCCL_INFO("[CcuTempAllGatherMeshMem2Mem1D] Run Init: myRank_[%d], dimSize[%llu], inputAddr[%llu],"\
     117              :         "outputAddr[%llu], sliceSize[%llu], offset[%llu]",
     118              :         myRank_, dimSize[0], inputAddr, outputAddr, sliceSize, offset);
     119              : 
     120            0 :     std::vector<LinkData> links;
     121            0 :     for (auto &pair : tempLinks) {
     122            0 :         if (pair.second.empty()) {
     123            0 :             continue;
     124              :         }
     125            0 :         links.push_back(pair.second[0]);
     126              :     }
     127            0 :     HCCL_INFO("[CcuTempAllGatherMeshMem2Mem1D] links.size[%zu]", links.size());
     128            0 :     ccuInsAllGatherMeshMem2Mem1D.SetLinks(links);
     129              : 
     130            0 :     RankGroup rankGroup;
     131            0 :     for (auto &peer : tempVTopo_[0]) {
     132            0 :         rankGroup.AddRank(peer);
     133              :     }
     134            0 :     u32 cntCkeNum = 3;
     135            0 :     ccuInsAllGatherMeshMem2Mem1D.SetCntCkeNum(cntCkeNum);
     136            0 :     ccuInsAllGatherMeshMem2Mem1D.SetRankGroup(rankGroup);
     137            0 :     HCCL_INFO("CcuTempAllGatherMeshMem2Mem1D is [%s]", ccuInsAllGatherMeshMem2Mem1D.Describe().c_str());
     138            0 :     ccuInsAllGatherMeshMem2Mem1D.Describe();
     139            0 :     tempInsQues[0]->Append(std::move(std::make_unique<CcuInstructionAllGatherMeshMem2Mem1D>(ccuInsAllGatherMeshMem2Mem1D)));
     140              : 
     141            0 :     return HcclResult::HCCL_SUCCESS;
     142            0 : }
     143              : 
     144              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1