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_2die.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 53 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 6 0

            Line data    Source code
       1              : /**
       2              :  * Copyright (c) 2026 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_rank_group.h"
      17              : #include "ccu_ctx_creator_registry.h"
      18              : #include "ccu_context_all_gather_mesh1d_2die.h"
      19              : #include "ccu_temp_all_gather_mesh_1D_2die.h"
      20              : #include "ccu_ins_group.h"
      21              : 
      22              : namespace Hccl {
      23              : 
      24              : static CcuInstRegister<CcuContextAllGatherMesh1D2Die> g_registrarAllGather(CcuInstType::CCU_ALLGATHER_MESH_1D_2DIE);
      25              : 
      26            0 : CcuTempAllGatherMesh1D2Die::CcuTempAllGatherMesh1D2Die(
      27              :     const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
      28            0 :     const std::map<RankId, u32>& tempVirtRankMap)
      29            0 :     : CcuAlgTemplateBase(virtualRank, tempRankSize, tempVTopo, tempVirtRankMap)
      30            0 : {}
      31              : 
      32            0 : CcuTempAllGatherMesh1D2Die::~CcuTempAllGatherMesh1D2Die() {}
      33              : 
      34            0 : HcclResult CcuTempAllGatherMesh1D2Die::CalcRes(AlgTempResReq& tempResReq)
      35              : {
      36            0 :     tempResReq.queNum = 1;
      37            0 :     tempResReq.streamNum = tempResReq.queNum + 1;
      38            0 :     HCCL_DEBUG("[CalcRes] tempResReq.queNum[%u]", tempResReq.queNum);
      39              : 
      40            0 :     CHK_RET(CalcResLinksMesh(myRank_, tempRankSize_, tempVTopo_, linkNumBtwPeers_, tempResReq));
      41            0 :     return HcclResult::HCCL_SUCCESS;
      42              : }
      43              : 
      44            0 : uint64_t CcuTempAllGatherMesh1D2Die::GetMaxSliceSize() const { return UB_MAX_DATA_SIZE; }
      45              : 
      46            0 : HcclResult CcuTempAllGatherMesh1D2Die::GenExtIns(
      47              :     const TempFuncs& tempFuncs, TemplateDataParams& tempAlgParams, const ResLinks& tempLinks,
      48              :     std::vector<InsQuePtr>& tempInsQues)
      49              : {
      50            0 :     CHK_PRT_RET(
      51              :         tempInsQues.empty(), HCCL_ERROR("[CcuTempAllGatherMesh1D2Die] empty queue"), HcclResult::HCCL_E_INTERNAL);
      52            0 :     CHK_PTR_NULL(tempInsQues[0]);
      53            0 :     opMode_ = tempFuncs.opMode;
      54            0 :     CcuInstructionAllGatherMesh1D2Die ccuInsAllGatherMesh1D2Die;
      55            0 :     std::vector<uint64_t> dimSize;
      56            0 :     dimSize.push_back(tempRankSize_);
      57              : 
      58            0 :     uint64_t sliceSize = tempAlgParams.sliceSize;
      59            0 :     uint64_t inputAddr = BufferTypeToAddr(tempAlgParams.buffInfo.inBuffType) + tempAlgParams.buffInfo.inBuffBaseOff;
      60            0 :     uint64_t outputAddr = BufferTypeToAddr(tempAlgParams.buffInfo.outBuffType) + tempAlgParams.buffInfo.outBuffBaseOff;
      61            0 :     uint64_t outputSliceStride = tempAlgParams.outputSliceStride;
      62              :     uint64_t token;
      63            0 :     CHK_RET(GetToken(op_, token));
      64            0 :     HCCL_INFO(
      65              :         "[CcuTempAllGatherMesh1D2Die] dimSize[%llu], sliceSize[%llu], inputAddr[%llu],"
      66              :         "outputAddr[%llu], outputSliceStride[%llu]",
      67              :         dimSize[0], sliceSize, inputAddr, outputAddr, outputSliceStride);
      68              : 
      69              :     // key表示为dieId
      70            0 :     std::map<uint32_t, std::vector<LinkData>> linksDie;
      71            0 :     std::map<uint32_t, RankGroup> rankGroup;
      72              : 
      73            0 :     for (auto link : tempLinks) {
      74            0 :         std::vector<LinkData> linkData = link.second;
      75            0 :         RankId peerRankId = link.first;
      76            0 :         if (linkData.size() == 0) {
      77            0 :             continue;
      78              :         }
      79              : 
      80            0 :         linksDie[linkData[0].GetLocalDieId()].push_back(linkData[0]);
      81            0 :         rankGroup[linkData[0].GetLocalDieId()].AddRank(peerRankId);
      82            0 :     }
      83              : 
      84            0 :     HCCL_INFO(
      85              :         "[CcuTempAllGatherMesh1D2Die] linksDie0Size[%zu], linksDie1Size[%zu]", linksDie[0].size(), linksDie[1].size());
      86              : 
      87            0 :     rankGroup[0].AddRank(myRank_);
      88            0 :     rankGroup[1].AddRank(myRank_);
      89              : 
      90            0 :     std::unique_ptr<CcuInsGroup> insGroupPtr = std::make_unique<CcuInsGroup>();
      91            0 :     for (uint32_t dieId = 0; dieId < 2; dieId++) { // 2Die算法,需要下发 2 条通信指令
      92            0 :         CcuInstructionAllGatherMesh1D2Die ccuInstruction;
      93            0 :         bool withMyRank = linksDie[dieId].size() > linksDie[1 - dieId].size() ? false : true;
      94            0 :         ccuInstruction.Init(
      95            0 :             myRank_, inputAddr, outputAddr, sliceSize, outputSliceStride, token, withMyRank, op_, tempVTopo_);
      96            0 :         ccuInstruction.SetLinks(linksDie[dieId]);
      97            0 :         ccuInstruction.SetRankGroup(rankGroup[dieId]);
      98            0 :         ccuInstruction.SetCntCkeNum(5); // 每个transport用5个CKE
      99            0 :         insGroupPtr->Append(std::move(std::make_unique<CcuInstructionAllGatherMesh1D2Die>(ccuInstruction)));
     100            0 :     }
     101            0 :     tempInsQues[0]->Append(std::move(insGroupPtr)); // 只有一条que
     102            0 :     HCCL_INFO("[CcuTempAllGatherMesh1D2Die] Template Run for all steps Ends.");
     103            0 :     return HcclResult::HCCL_SUCCESS;
     104            0 : }
     105              : 
     106              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1