LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_template/ccu_alg_template - ccu_temp_half_alltoallv_mesh_1D.cc (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 50 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 <ios>
      12              : #include <iostream>
      13              : #include <algorithm>
      14              : 
      15              : #include "log.h"
      16              : #include "template_utils.h"
      17              : 
      18              : #include "ccu_temp_half_alltoallv_mesh_1D.h"
      19              : #include "alg_data_trans_wrapper.h"
      20              : #include "ccu_instruction_half_alltoallv_mesh1d.h"
      21              : #include "ccu_rank_group.h"
      22              : #include "ccu_ctx_creator_registry.h"
      23              : #include "ccu_context_half_alltoallv_mesh1d.h"
      24              : 
      25              : namespace Hccl {
      26              : 
      27              : static CcuInstRegister<CcuContextHalfAllToAllVMesh1D> registrarAllToAll(CcuInstType::CCU_HALF_ALLTOALLV_MESH_1D);
      28              : 
      29            0 : CcuTempHalfAllToAllVMesh1D::CcuTempHalfAllToAllVMesh1D(const RankId virtualRank, const u32 tempRankSize,
      30              :                                    const std::vector<std::vector<RankId>> &tempVTopo,
      31            0 :                                    const std::map<RankId, u32>            &tempVirtRankMap)
      32            0 :     : CcuAlgTemplateBase(virtualRank, tempRankSize, tempVTopo, tempVirtRankMap)
      33              : {
      34            0 :     if (tempVTopo_.size() != 1 || tempVTopo_[0].size() == 0) {
      35            0 :         THROW<InvalidParamsException>(StringFormat("[CcuTempHalfAllToAllVMesh1D] Invalid tempVTopo "
      36              :                                                    "Size[%u] or Invalid tempVTopo[0] size [%u].",
      37            0 :                                                    tempVTopo_.size(), tempVTopo_[0].size()));
      38              :     }
      39            0 : }
      40              : 
      41            0 : CcuTempHalfAllToAllVMesh1D::~CcuTempHalfAllToAllVMesh1D()
      42              : {
      43            0 : }
      44              : 
      45            0 : HcclResult CcuTempHalfAllToAllVMesh1D::CalcRes(AlgTempResReq &tempResReq)
      46              : {
      47            0 :     tempResReq.queNum = 1;
      48            0 :     tempResReq.streamNum = tempResReq.queNum;
      49            0 :     HCCL_INFO("[CalcRes] tempResReq.queNum[%u]", tempResReq.queNum);
      50            0 :     CHK_RET(CalcResLinksMesh(myRank_, tempRankSize_, tempVTopo_, linkNumBtwPeers_, tempResReq));
      51            0 :     return HcclResult::HCCL_SUCCESS;
      52              : }
      53              : 
      54            0 : void CcuTempHalfAllToAllVMesh1D::SetA2ASendRecvInfo(const A2ASendRecvInfo &sendRecvInfo) const
      55              : {
      56              :     (void)sendRecvInfo;
      57            0 :     return;
      58              : }
      59              : 
      60            0 : HcclResult CcuTempHalfAllToAllVMesh1D::Run(const TempFuncs &tempFuncs, const RankSliceInfo &sliceInfoVec,
      61              :                                           const BuffInfo &buffInfo, const ResLinks &tempLinks,
      62              :                                           std::vector<InsQuePtr> &tempInsQues)
      63              : {
      64            0 :     HCCL_INFO("[CcuTempHalfAllToAllVMesh1D] Run");
      65              :     (void)sliceInfoVec;
      66              :     (void)tempFuncs;
      67              :     (void)buffInfo;
      68              : 
      69            0 :     if (!op_.scratchMem) {
      70            0 :         HCCL_ERROR("[CcuTempHalfAllToAllVMesh1D][Run] Rank[%d] op_.scratchMem is null", myRank_);
      71            0 :         return HcclResult::HCCL_E_PTR;
      72              :     }
      73              : 
      74            0 :     uint64_t scratchAddr =  static_cast<uint64_t>(op_.scratchMem->GetAddr());
      75              : 
      76              :     // 暂只支持在1D Fullmesh场景下使用两个context,故使用的link相同
      77            0 :     std::vector<LinkData> links;
      78            0 :     for (auto &pair : tempLinks) {
      79            0 :         if (pair.second.empty()) {
      80            0 :             continue;
      81              :         }
      82            0 :         links.push_back(pair.second[0]);
      83              :     }
      84            0 :     RankGroup rankGroup;
      85            0 :     for (auto &peer : tempVTopo_[0]) {
      86            0 :         rankGroup.AddRank(peer);
      87              :     }
      88            0 :     HCCL_INFO("[CcuTempHalfAllToAllVMesh1D] links.size[%zu]", links.size());
      89            0 :     int32_t signalNum = (tempRankSize_ + 16 - 1) / 16;  // 每个CKE有16个bit
      90              : 
      91            0 :     std::unique_ptr<CcuInsGroup> insGroupPtr = std::make_unique<CcuInsGroup>();
      92            0 :     for (uint32_t mId = 0; mId < 2; mId++) {  // 2个mission并发
      93            0 :         HCCL_INFO("[CcuTempHalfAllToAllVMesh1D][Run] MissionId[%u], Rank[%d], SignalNum[%d].",
      94              :             mId, myRank_, signalNum);
      95            0 :         CcuInstructionHalfAllToAllVMesh1D ins = CcuInstructionHalfAllToAllVMesh1D();
      96            0 :         ins.Init(mId, myRank_, scratchAddr, op_, tempVTopo_);
      97            0 :         ins.SetLinks(links);
      98            0 :         ins.SetRankGroup(rankGroup);
      99            0 :         ins.SetCntCkeNum(std::max(3, signalNum));  // 每个transport默认用3个CKE
     100            0 :         insGroupPtr->Append(std::move(std::make_unique<CcuInstructionHalfAllToAllVMesh1D>(ins)));
     101            0 :     }
     102            0 :     if (tempInsQues.size() == 0) {
     103            0 :         HCCL_ERROR("[CcuTempHalfAllToAllVMesh1D][Run] tempInsQues is empty!");
     104            0 :         return HcclResult::HCCL_E_INTERNAL;
     105              :     }
     106            0 :     CHK_PTR_NULL(tempInsQues[0]);
     107            0 :     tempInsQues[0]->Append(std::move(insGroupPtr));  // 只有一条流
     108            0 :     return HcclResult::HCCL_SUCCESS;
     109            0 : }
     110              : } // namespace Hccl
        

Generated by: LCOV version 2.0-1