LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/alg/coll_alg_factory/alg_executor/ins_alg_executor/send_recv - ins_v2_batchSendRecv_executor.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 0.0 % 1 0
Test Date: 2026-08-18 17:47:01 Functions: 0.0 % 1 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              : #ifndef HCCLV2_INS_V2_BATCH_SEND_RECV_EXECUTOR_H
      12              : #define HCCLV2_INS_V2_BATCH_SEND_RECV_EXECUTOR_H
      13              : 
      14              : #include <unordered_set>
      15              : #include <algorithm>
      16              : 
      17              : #include "ins_coll_alg_base.h"
      18              : #include "ins_temp_all_gather_mesh.h"
      19              : #include "topo_match_partial_mesh.h"
      20              : #include "instruction.h"
      21              : #include "data_buffer.h"
      22              : #include "rmt_data_buffer_mgr.h"
      23              : 
      24              : namespace Hccl {
      25              : constexpr u32 MULTIPLY_TWO = 2;
      26              : constexpr u64 HCCL_CHUNK_SIZE = 1024 * 1024 * 1024; // 1024*1024*1024的size
      27              : 
      28              : template <typename AlgTopoMatch>
      29              : class InsV2BatchSendRecvExecutor : public InsCollAlgBase {
      30              : public:
      31              :     explicit InsV2BatchSendRecvExecutor();
      32              :     ~InsV2BatchSendRecvExecutor() override;
      33              : 
      34            0 :     std::string Describe() const override { return "Instruction based Send Executor."; }
      35              : 
      36              :     HcclResult Orchestrate(
      37              :         const RankGraph* rankGraph, const CollAlgOperator& op, const CollAlgParams& params, InsQuePtr insQue) override;
      38              : 
      39              :     HcclResult CalcResOffload(const RankGraph* rankGraph, const u64& dataSize, CollOffloadOpResReq& resReq) override;
      40              : 
      41              :     HcclResult CalcRes(const RankGraph* rankGraph, CollAlgResReq& algResReq) override;
      42              : 
      43              :     HcclResult Orchestrate(
      44              :         const AlgTopoInfo& topoInfo, const CollAlgOperator& op, const CollAlgParams& params, ConnectedLinkMgr* linkMgr,
      45              :         InsQuePtr insQue) override;
      46              : 
      47              :     void SetRmaDataBufferMgr(const RmtDataBufferMgr* rmaDataBufferMgr) override;
      48              :     HcclResult CalNumBlocks(u32& blockDim, u64 dataSize, u32 blockDimLimit) override;
      49              : 
      50              : protected:
      51              :     struct SendRecvSlice {
      52              :         uintptr_t addr_;
      53              :         u64 size_;
      54              :         u32 remoteRank_;
      55              :         SendRecvSlice(uintptr_t addr, u64 size, u32 remoteRank) : addr_(addr), size_(size), remoteRank_(remoteRank) {}
      56              :     };
      57              : 
      58              :     u32 remoteUserRank_ = 0;
      59              :     const u32 MAX_LOOP_IN_ONCE_LAUNCH = 200;
      60              :     std::deque<SendRecvSlice> sendDataSilces_;
      61              :     std::deque<SendRecvSlice> recvDataSilces_;
      62              : 
      63              : private:
      64              :     bool SortSendItems(HcclSendRecvItem* a, HcclSendRecvItem* b) const;
      65              :     bool SortRecvItems(HcclSendRecvItem* a, HcclSendRecvItem* b) const;
      66              :     HcclResult InitParams(const CollAlgOperator& op, const CollAlgParams& params) override;
      67              :     HcclResult GetPairWiseList();
      68              : 
      69              :     // 收发数据准备
      70              :     HcclResult CalcSendSlices(u64 maxRoundTransferSize);
      71              :     HcclResult CalcRecvSlices(u64 maxRoundTransferSize);
      72              :     HcclResult GenSendSlicesMapRank();
      73              :     HcclResult GenRecvSlicesMapRank();
      74              : 
      75              :     // 实现自发自收
      76              :     HcclResult ProcessSelfSendRecvTasks(InsQuePtr& queue);
      77              : 
      78              :     // 实现数据发送&接收
      79              :     HcclResult ProcessSendRecv(
      80              :         const CollAlgOperator& op, InsQuePtr& queue, u32 remoteRank, std::vector<SendRecvSlice>& sendRemoteSlices,
      81              :         std::vector<SendRecvSlice>& recvRemoteSlices, LinkData& link) const;
      82              :     HcclResult ProcessSendDataSlice(
      83              :         InsQuePtr& queue, SendRecvSlice& sendRemoteSlice, u32 remoteRank, uint64_t scratchBufferAddr,
      84              :         LinkData& link) const;
      85              :     HcclResult SendRun(DataBuffer& execBufferSlice, u32 remoteUserRank, InsQuePtr& queue, LinkData& link) const;
      86              :     HcclResult
      87              :     CopyRecvDataSliceToUsrOut(InsQuePtr& queue, SendRecvSlice& slice, u32 remoteRank, uint64_t scratchBufferAddr) const;
      88              : 
      89              :     HcclResult
      90              :     RunLoopSendRecv(const CollAlgOperator& op, std::vector<InsQuePtr>& queues, InsTempAllGatherMesh1D& tempAlg);
      91              :     HcclResult CalcResLinksPartialMesh(
      92              :         const RankId myRank, const std::vector<std::vector<RankId>>& tempVTopo, const u32 linkNumBtwPeers,
      93              :         AlgTempResReq& tempResReq);
      94              :     HcclResult CalcRes(AlgTempResReq& tempResReq);
      95              :     HcclResult ExecAiv();
      96              : 
      97              :     HcclResult InitCommInfo(const RankGraph* rankGraph);
      98              :     HcclResult InitCommInfo(const AlgTopoInfo& topoInfo);
      99              : 
     100              :     std::set<u32> commTargetUserRankSet_;
     101              :     std::deque<HcclSendRecvItem*> sendToSelfDeque_;
     102              :     std::deque<HcclSendRecvItem*> recvFromSelfDeque_;
     103              :     std::deque<HcclSendRecvItem*> sendDeque_;
     104              :     std::deque<HcclSendRecvItem*> recvDeque_;
     105              :     BuffInfo buffInfo_;
     106              : 
     107              :     std::vector<RankId> virtRanks_;
     108              :     std::map<RankId, u32> virtRankMap_; // map<virtRank, virtRankOrder>
     109              :     std::vector<std::vector<RankId>> vTopo_;
     110              : 
     111              :     std::vector<InsQuePtr> requiredQue_;
     112              :     ResLinks tempResLinks_;
     113              : 
     114              :     std::map<u32, std::vector<SendRecvSlice>> SendSliceMapByRemoteRank_;
     115              :     std::map<u32, std::vector<SendRecvSlice>> RecvSliceMapByRemoteRank_;
     116              :     u64 maxRoundTransferSize_ = 0; // 单轮最多能够传输的size
     117              :     u32 sliceId_{0};               // 用于组装aivTag
     118              : };
     119              : } // namespace Hccl
     120              : #endif // !HCCLV2_INS_V2_BATCH_SEND_RECV_EXECUTOR_H
        

Generated by: LCOV version 2.0-1