LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_template/ccu_alg_template - ccu_temp_broadcast_mesh_1D.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 62 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 <ios>
      12              : #include <iostream>
      13              : 
      14              : #include "log.h"
      15              : 
      16              : #include "ccu_temp_broadcast_mesh_1D.h"
      17              : #include "alg_data_trans_wrapper.h"
      18              : #include "ccu_instruction_broadcast_mesh1d.h"
      19              : #include "ccu_rank_group.h"
      20              : #include "ccu_ctx_creator_registry.h"
      21              : #include "ccu_context_broadcast_mesh1d.h"
      22              : 
      23              : namespace Hccl {
      24              : 
      25              : static CcuInstRegister<CcuContextBroadcastMesh1D> registrarBroadcast(CcuInstType::CCU_BROADCAST_MESH_1D_DIRECT);
      26              : 
      27            0 : CcuTempBroadcastMesh1D::CcuTempBroadcastMesh1D(
      28              :     const RankId virtualRank, const u32 tempRankSize, const std::vector<std::vector<RankId>>& tempVTopo,
      29            0 :     const std::map<RankId, u32>& tempVirtRankMap)
      30            0 :     : CcuAlgTemplateBase(virtualRank, tempRankSize, tempVTopo, tempVirtRankMap)
      31            0 : {}
      32              : 
      33            0 : CcuTempBroadcastMesh1D::~CcuTempBroadcastMesh1D() {}
      34              : 
      35            0 : void CcuTempBroadcastMesh1D::GetInAndOutAddr(const TempFuncs& tempFuncs, uint64_t& inputAddr, uint64_t& outputAddr)
      36              : {
      37            0 :     if (tempFuncs.isForepart) {
      38              :         // 从 UserIn 获取数据
      39            0 :         inputAddr = BufferTypeToAddr(tempFuncs.usrData.usrInSlices[0].GetType())
      40            0 :                     + tempFuncs.usrData.usrInSlices[0].GetOffset();
      41            0 :         HCCL_INFO(
      42              :             "[CcuTempBroadcastMesh1D] BufferTypeToAddr(tempFuncs.usrData.usrInSlices[0].GetType()) is [%llu], "
      43              :             "offset is [%llu]",
      44              :             BufferTypeToAddr(tempFuncs.usrData.usrInSlices[0].GetType()), tempFuncs.usrData.usrInSlices[0].GetOffset());
      45              :     } else {
      46              :         // 从 inBuff 获取数据
      47            0 :         inputAddr = BufferTypeToAddr(buffInfo_.inBuffType) + buffInfo_.inBuffBaseOff;
      48            0 :         HCCL_INFO(
      49              :             "[CcuTempBroadcastMesh1D] BufferTypeToAddr(tempFuncs.usrData.usrInSlices[0].GetType()) is [%llu], "
      50              :             "offset is [%llu]",
      51              :             BufferTypeToAddr(tempFuncs.usrData.usrInSlices[0].GetType()), tempFuncs.usrData.usrInSlices[0].GetOffset());
      52              :     }
      53            0 :     if (tempFuncs.isBottom) {
      54              :         // 把数据写入 UserOut
      55            0 :         outputAddr = BufferTypeToAddr(tempFuncs.usrData.usrOutSlices[0].GetType())
      56            0 :                      + tempFuncs.usrData.usrOutSlices[0].GetOffset();
      57            0 :         HCCL_INFO(
      58              :             "[CcuTempBroadcastMesh1D] BufferTypeToAddr(tempFuncs.usrData.usrInSlices[0].GetType()) is [%llu], "
      59              :             "offset is [%llu]",
      60              :             BufferTypeToAddr(tempFuncs.usrData.usrOutSlices[0].GetType()),
      61              :             tempFuncs.usrData.usrOutSlices[0].GetOffset());
      62              :     } else {
      63              :         // 把数据写入 outBuff
      64            0 :         outputAddr = BufferTypeToAddr(buffInfo_.outBuffType) + buffInfo_.outBuffBaseOff;
      65            0 :         HCCL_INFO(
      66              :             "[CcuTempBroadcastMesh1D] BufferTypeToAddr(tempFuncs.usrData.usrInSlices[0].GetType()) is [%llu], "
      67              :             "offset is [%llu]",
      68              :             BufferTypeToAddr(tempFuncs.usrData.usrOutSlices[0].GetType()),
      69              :             tempFuncs.usrData.usrOutSlices[0].GetOffset());
      70              :     }
      71            0 :     HCCL_INFO("[CcuTempBroadcastMesh1D] inputAddr[%llu], outputAddr[%llu]", inputAddr, outputAddr);
      72            0 :     return;
      73              : }
      74              : 
      75            0 : HcclResult CcuTempBroadcastMesh1D::CalcRes(AlgTempResReq& tempResReq)
      76              : {
      77            0 :     tempResReq.queNum = 1;
      78            0 :     tempResReq.streamNum = tempResReq.queNum;
      79            0 :     HCCL_INFO("[CalcRes] tempResReq.queNum[%u]", tempResReq.queNum);
      80            0 :     CHK_RET(CalcResLinksMesh(myRank_, tempRankSize_, tempVTopo_, linkNumBtwPeers_, tempResReq));
      81            0 :     return HcclResult::HCCL_SUCCESS;
      82              : }
      83              : 
      84            0 : HcclResult CcuTempBroadcastMesh1D::Run(
      85              :     const TempFuncs& tempFuncs, const RankSliceInfo& sliceInfoVec, const BuffInfo& buffInfo, const ResLinks& tempLinks,
      86              :     std::vector<InsQuePtr>& tempInsQues)
      87              : {
      88              :     (void)sliceInfoVec;
      89            0 :     CHK_PRT_RET(tempInsQues.empty(), HCCL_ERROR("[CcuTempBroadcastMesh1D] empty queue"), HcclResult::HCCL_E_INTERNAL);
      90            0 :     CHK_PTR_NULL(tempInsQues[0]);
      91            0 :     buffInfo_ = buffInfo;
      92            0 :     opMode_ = tempFuncs.opMode;
      93            0 :     CcuInstructionBroadcastMesh1D ccuInsBroadcastMesh1D;
      94            0 :     rootId_ = op_.root;
      95            0 :     std::vector<uint64_t> dimSize;
      96            0 :     dimSize.push_back(tempRankSize_);
      97              : 
      98              :     // 只传userIn的起始位置,不带偏移,偏移已在offset中包含
      99              :     uint64_t inputAddr;
     100              :     // userOut 的位置,需要带上偏移
     101              :     uint64_t outputAddr;
     102            0 :     GetInAndOutAddr(tempFuncs, inputAddr, outputAddr);
     103            0 :     uint64_t sliceSize = tempFuncs.usrData.usrInSlices[0].GetSize(); //
     104              : 
     105            0 :     uint64_t offset = 0;
     106              : 
     107              :     uint64_t token;
     108            0 :     CHK_RET(GetToken(op_, token));
     109              : 
     110            0 :     ccuInsBroadcastMesh1D.Init(
     111            0 :         static_cast<uint32_t>(myRank_), static_cast<uint32_t>(rootId_), inputAddr, outputAddr, sliceSize, offset, token,
     112            0 :         op_, tempVTopo_);
     113              : 
     114            0 :     std::vector<LinkData> links;
     115            0 :     for (auto& pair : tempLinks) {
     116            0 :         if (pair.second.empty()) {
     117            0 :             continue;
     118              :         }
     119            0 :         links.push_back(pair.second[0]);
     120              :     }
     121            0 :     HCCL_INFO("[CcuTempBroadcastMesh1D] links.size[%zu]", links.size());
     122            0 :     ccuInsBroadcastMesh1D.SetLinks(links);
     123            0 :     if (tempVTopo_[0].size() == 0) {
     124            0 :         HCCL_ERROR("[CcuTempBroadcastMesh1D] Invalid tempVTopo[0] size [%zu].", tempVTopo_[0].size());
     125            0 :         return HcclResult::HCCL_E_PARA;
     126              :     }
     127            0 :     RankGroup rankGroup;
     128            0 :     for (auto& peer : tempVTopo_[0]) {
     129            0 :         rankGroup.AddRank(peer);
     130              :     }
     131            0 :     u32 cntCkeNum = 3;
     132            0 :     ccuInsBroadcastMesh1D.SetCntCkeNum(cntCkeNum);
     133            0 :     ccuInsBroadcastMesh1D.SetRankGroup(rankGroup);
     134            0 :     ccuInsBroadcastMesh1D.Describe();
     135            0 :     tempInsQues[0]->Append(std::move(std::make_unique<CcuInstructionBroadcastMesh1D>(ccuInsBroadcastMesh1D)));
     136              : 
     137            0 :     return HcclResult::HCCL_SUCCESS;
     138            0 : }
     139              : 
     140              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1