LCOV - code coverage report
Current view: top level - legacy/ascend950/service/collective/instruction - instruction.h (source / functions) Coverage Total Hit
Test: coverage.info Lines: 99.5 % 218 217
Test Date: 2026-08-18 17:47:01 Functions: 94.2 % 52 49

            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_INSTRUCTION_H
      12              : #define HCCLV2_INSTRUCTION_H
      13              : 
      14              : #include <string>
      15              : #include <map>
      16              : #include <memory>
      17              : #include <list>
      18              : #include "coll_operator.h"
      19              : #include "types.h"
      20              : #include "data_slice.h"
      21              : #include "virtual_topo.h"
      22              : #include "notify_type.h"
      23              : #include "data_buffer.h"
      24              : #include "rmt_rma_buf_slice_lite.h"
      25              : #include "rma_buf_slice_lite.h"
      26              : 
      27              : namespace Hccl {
      28              : 
      29         4223 : MAKE_ENUM(
      30              :     InstructionType, LOCAL_COPY, LOCAL_REDUCE, LOCAL_POST_TO, LOCAL_WAIT_FROM, LOCAL_WAIT_GROUP, LOCAL_BCAST_POST,
      31              :     POST_READY, WAIT_READY, POST_FIN, WAIT_FIN, WAIT_GROUP_FIN, POST_FIN_ACK, WAIT_FIN_ACK, READ, READ_REDUCE,
      32              :     BATCH_READ, WRITE, WRITE_REDUCE, BATCH_WRITE, WRITE_WITH_FIN, WRITE_REDUCE_WITH_FIN, CCU_INS, AICPU_INS,
      33              :     LOCAL_COPY_EXTEND, WRITE_EXTEND, WRITE_REDUCE_EXTEND, WRITE_REDUCE_WITH_FIN_EXTEND, READ_EXTEND, READ_REDUCE_EXTEND,
      34              :     WRITE_WITH_FIN_EXTEND, BATCH_ONE_SIDED_WRITE, BATCH_ONE_SIDED_READ, AIV_INS, STREAM_SYNC, AICPU_REDUCE,
      35              :     PRE_STREAM_SYNC)
      36              : 
      37              : constexpr u32 INVALID_TOPICID = 0xFFFFFFFF;
      38              : constexpr uint32_t NOTIFY_INDEX_READY = 0;
      39              : constexpr uint32_t NOTIFY_INDEX_FIN = 1;
      40              : constexpr uint32_t NOTIFY_INDEX_FIN_ACK = 2;
      41              : class Instruction {
      42              : public:
      43         1231 :     explicit Instruction(InstructionType type) : type_(type) {}
      44         1235 :     virtual ~Instruction() = default;
      45              :     virtual string Describe() const = 0;
      46              : 
      47              :     const InstructionType GetType() const;
      48            0 :     virtual const LinkData* GetLink() const { return nullptr; }
      49              : 
      50              : protected:
      51              :     InstructionType type_;
      52              : };
      53              : 
      54              : class InsLocalCopy : public Instruction {
      55              : public:
      56           67 :     InsLocalCopy(const DataSlice& srcSlice, const DataSlice& dstSlice)
      57           67 :         : Instruction(InstructionType::LOCAL_COPY),
      58           67 :           srcSlice_(srcSlice),
      59           67 :           dstSlice_(dstSlice)
      60           67 :     {}
      61              :     string Describe() const override;
      62              : 
      63              :     const DataSlice& GetSrcSlice() const;
      64              :     const DataSlice& GetDstSlice() const;
      65              : 
      66              : private:
      67              :     DataSlice srcSlice_;
      68              :     DataSlice dstSlice_;
      69              : };
      70              : 
      71              : class InsLocalCopyExtend : public Instruction {
      72              : public:
      73            2 :     InsLocalCopyExtend(const DataBuffer& srcBuffer, const DataBuffer& dstBuffer)
      74            2 :         : Instruction(InstructionType::LOCAL_COPY_EXTEND),
      75            2 :           srcBuffer_(srcBuffer),
      76            2 :           dstBuffer_(dstBuffer)
      77            2 :     {}
      78              :     string Describe() const override;
      79              : 
      80              :     const DataBuffer& GetSrcBuffer() const;
      81              :     const DataBuffer& GetDstBuffer() const;
      82              : 
      83              : private:
      84              :     DataBuffer srcBuffer_;
      85              :     DataBuffer dstBuffer_;
      86              : };
      87              : 
      88              : class InsLocalReduce : public Instruction {
      89              : public:
      90           39 :     InsLocalReduce(const DataSlice& srcSlice, const DataSlice& dstSlice, DataType dataType, ReduceOp reduceOp)
      91           39 :         : Instruction(InstructionType::LOCAL_REDUCE),
      92           39 :           srcSlice_(srcSlice),
      93           39 :           dstSlice_(dstSlice),
      94           39 :           dataType_(dataType),
      95           39 :           reduceOp_(reduceOp)
      96           39 :     {}
      97              :     string Describe() const override;
      98              : 
      99              :     const DataSlice& GetSrcSlice() const;
     100              :     const DataSlice& GetDstSlice() const;
     101              :     const DataType GetDataType() const;
     102              :     const ReduceOp GetReduceOp() const;
     103              : 
     104              : private:
     105              :     DataSlice srcSlice_;
     106              :     DataSlice dstSlice_;
     107              :     DataType dataType_;
     108              :     ReduceOp reduceOp_;
     109              : };
     110              : constexpr u32 INVALID_INSTRUCTION_QID = 0xffffff; // 无效的指令队列
     111              : class InsLocalPostTo : public Instruction {
     112              : public:
     113            1 :     explicit InsLocalPostTo(QId waitQid, NotifyType notifyType = NotifyType::NORMAL, u32 topicId = 0)
     114           37 :         : Instruction(InstructionType::LOCAL_POST_TO),
     115           37 :           waitQid_(waitQid),
     116           37 :           notifyType_(notifyType),
     117           37 :           topicId_(topicId)
     118           37 :     {}
     119              :     string Describe() const override;
     120              : 
     121              :     void SetPostQid(QId qid);
     122              : 
     123              :     QId GetPostQid() const;
     124              :     QId GetWaitQid() const;
     125              :     u32 GetTopicId() const;
     126              :     NotifyType GetNotifyType() const;
     127              : 
     128              : private:
     129              :     QId postQid_{INVALID_INSTRUCTION_QID};
     130              :     QId waitQid_;
     131              :     NotifyType notifyType_;
     132              :     u32 topicId_;
     133              : };
     134              : 
     135              : class InsLocalWaitFrom : public Instruction {
     136              : public:
     137            1 :     explicit InsLocalWaitFrom(QId postQid, NotifyType notifyType = NotifyType::NORMAL, u32 topicId = 0)
     138           37 :         : Instruction(InstructionType::LOCAL_WAIT_FROM),
     139           37 :           postQid_(postQid),
     140           37 :           notifyType_(notifyType),
     141           37 :           topicId_(topicId)
     142           37 :     {}
     143              :     string Describe() const override;
     144              : 
     145              :     void SetWaitQid(QId qid);
     146              : 
     147              :     QId GetPostQid() const;
     148              :     QId GetWaitQid() const;
     149              :     u32 GetTopicId() const;
     150              :     NotifyType GetNotifyType() const;
     151              : 
     152              : private:
     153              :     QId postQid_;
     154              :     QId waitQid_{INVALID_INSTRUCTION_QID};
     155              :     NotifyType notifyType_;
     156              :     u32 topicId_;
     157              : };
     158              : 
     159              : class InsLocalWaitGroup : public Instruction {
     160              : public:
     161           35 :     explicit InsLocalWaitGroup(u32 topicId = 0) : Instruction(InstructionType::LOCAL_WAIT_GROUP), topicId_(topicId) {}
     162              : 
     163              :     using Iterator = BaseConstIterator<vector, QId>;
     164              : 
     165              :     void Append(QId postQid);
     166              :     string Describe() const override;
     167              :     QId GetWaitQid() const;
     168              :     u32 GetTopicId() const;
     169              :     void SetWaitQid(QId qId);
     170              : 
     171            7 :     Iterator Iter() const { return Iterator(postQids_); }
     172              : 
     173              : private:
     174              :     vector<QId> postQids_;
     175              :     QId waitQid_;
     176              :     u32 topicId_;
     177              : };
     178              : 
     179              : class InsLocalBcastPost : public Instruction {
     180              : public:
     181            3 :     explicit InsLocalBcastPost(u32 topicId = 0) : Instruction(InstructionType::LOCAL_BCAST_POST), topicId_(topicId) {}
     182              : 
     183              :     using Iterator = BaseConstIterator<vector, QId>;
     184              : 
     185              :     void Append(QId waitQid);
     186              :     string Describe() const override;
     187              :     u32 GetPostQid() const;
     188              :     QId GetTopicId() const;
     189              :     void SetPostQid(QId qId);
     190              : 
     191            3 :     Iterator Iter() const { return Iterator(waitQids_); }
     192              : 
     193              : private:
     194              :     vector<QId> waitQids_;
     195              :     QId postQid_{0};
     196              :     u32 topicId_;
     197              : };
     198              : 
     199              : class InsPostReady : public Instruction {
     200              : public:
     201           49 :     InsPostReady(RankId remoteRank, const LinkData& link)
     202           49 :         : Instruction(InstructionType::POST_READY),
     203           49 :           remoteRank_(remoteRank),
     204           49 :           link_(link)
     205           49 :     {}
     206              :     string Describe() const override;
     207              : 
     208              :     RankId GetRemoteRank() const;
     209              :     const LinkData* GetLink() const override;
     210              : 
     211              : private:
     212              :     RankId remoteRank_;
     213              :     LinkData link_;
     214              : };
     215              : 
     216              : class InsWaitReady : public Instruction {
     217              : public:
     218           49 :     InsWaitReady(RankId remoteRank, const LinkData& link)
     219           49 :         : Instruction(InstructionType::WAIT_READY),
     220           49 :           remoteRank_(remoteRank),
     221           49 :           link_(link)
     222           49 :     {}
     223              :     string Describe() const override;
     224              : 
     225              :     RankId GetRemoteRank() const;
     226              :     const LinkData* GetLink() const override;
     227              : 
     228              : private:
     229              :     RankId remoteRank_;
     230              :     LinkData link_;
     231              : };
     232              : 
     233              : class InsPostFin : public Instruction {
     234              : public:
     235           45 :     InsPostFin(RankId remoteRank, const LinkData& link)
     236           45 :         : Instruction(InstructionType::POST_FIN),
     237           45 :           remoteRank_(remoteRank),
     238           45 :           link_(link)
     239           45 :     {}
     240              :     string Describe() const override;
     241              : 
     242              :     RankId GetRemoteRank() const;
     243              :     const LinkData* GetLink() const override;
     244              : 
     245              : private:
     246              :     RankId remoteRank_;
     247              :     LinkData link_;
     248              : };
     249              : 
     250              : class InsWaitFin : public Instruction {
     251              : public:
     252           49 :     InsWaitFin(RankId remoteRank, const LinkData& link)
     253           49 :         : Instruction(InstructionType::WAIT_FIN),
     254           49 :           remoteRank_(remoteRank),
     255           49 :           link_(link)
     256           49 :     {}
     257              :     string Describe() const override;
     258              : 
     259              :     RankId GetRemoteRank() const;
     260              :     const LinkData* GetLink() const override;
     261              : 
     262              : private:
     263              :     RankId remoteRank_;
     264              :     LinkData link_;
     265              : };
     266              : 
     267              : class InsPostFinAck : public Instruction {
     268              : public:
     269           33 :     InsPostFinAck(RankId remoteRank, const LinkData& link)
     270           33 :         : Instruction(InstructionType::POST_FIN_ACK),
     271           33 :           remoteRank_(remoteRank),
     272           33 :           link_(link)
     273           33 :     {}
     274              :     string Describe() const override;
     275              : 
     276              :     RankId GetRemoteRank() const;
     277              :     const LinkData* GetLink() const override;
     278              : 
     279              : private:
     280              :     RankId remoteRank_;
     281              :     LinkData link_;
     282              : };
     283              : 
     284              : class InsWaitGroupFin : public Instruction {
     285              : public:
     286           32 :     explicit InsWaitGroupFin(u32 topicId = 0)
     287           32 :         : Instruction(InstructionType::WAIT_GROUP_FIN),
     288           32 :           value_(0),
     289           32 :           topicId_(topicId)
     290           32 :     {}
     291              :     using Iterator = BaseConstIterator<vector, LinkData>;
     292              : 
     293              :     string Describe() const override;
     294              :     u32 GetTopicId() const;
     295              :     void Append(LinkData link);
     296              : 
     297           31 :     void SetValue(u32 givenValue) { value_ = givenValue; }
     298              : 
     299              :     u32 GetValue() const;
     300              : 
     301            1 :     Iterator Iter() const { return Iterator(links_); }
     302              : 
     303              : private:
     304              :     u32 value_;
     305              :     u32 topicId_;
     306              :     vector<LinkData> links_;
     307              : };
     308              : 
     309              : class InsWaitFinAck : public Instruction {
     310              : public:
     311           33 :     InsWaitFinAck(RankId remoteRank, const LinkData& link)
     312           33 :         : Instruction(InstructionType::WAIT_FIN_ACK),
     313           33 :           remoteRank_(remoteRank),
     314           33 :           link_(link)
     315           33 :     {}
     316              :     string Describe() const override;
     317              : 
     318              :     RankId GetRemoteRank() const;
     319              :     const LinkData* GetLink() const override;
     320              : 
     321              : private:
     322              :     RankId remoteRank_;
     323              :     LinkData link_;
     324              : };
     325              : 
     326              : class InsRead : public Instruction {
     327              : public:
     328           52 :     InsRead(RankId remoteRank, const LinkData& link, const DataSlice& localSlice, const DataSlice& remoteSlice)
     329           52 :         : Instruction(InstructionType::READ),
     330           52 :           remoteRank_(remoteRank),
     331           52 :           link_(link),
     332           52 :           localSlice_(localSlice),
     333           52 :           remoteSlice_(remoteSlice)
     334           52 :     {}
     335              :     string Describe() const override;
     336              : 
     337              :     RankId GetRemoteRank() const;
     338              :     const LinkData* GetLink() const override;
     339              :     const DataSlice& GetLocalSlice() const;
     340              :     const DataSlice& GetRemoteSlice() const;
     341              : 
     342              : private:
     343              :     RankId remoteRank_;
     344              :     LinkData link_;
     345              :     DataSlice localSlice_;
     346              :     DataSlice remoteSlice_;
     347              : };
     348              : 
     349              : class InsReadExtend : public Instruction {
     350              : public:
     351           31 :     InsReadExtend(
     352              :         RankId remoteRank, const LinkData& link, const DataBuffer& localBuffer, const DataBuffer& remoteBuffer)
     353           31 :         : Instruction(InstructionType::READ_EXTEND),
     354           31 :           remoteRank_(remoteRank),
     355           31 :           link_(link),
     356           31 :           localBuffer_(localBuffer),
     357           31 :           remoteBuffer_(remoteBuffer)
     358           31 :     {}
     359              :     string Describe() const override;
     360              : 
     361              :     RankId GetRemoteRank() const;
     362              :     const LinkData* GetLink() const override;
     363              :     const DataBuffer& GetLocalBuffer() const;
     364              :     const DataBuffer& GetRemoteBuffer() const;
     365              : 
     366              : private:
     367              :     RankId remoteRank_;
     368              :     LinkData link_;
     369              :     DataBuffer localBuffer_;
     370              :     DataBuffer remoteBuffer_;
     371              : };
     372              : 
     373              : class InsReadReduce : public Instruction {
     374              : public:
     375           44 :     InsReadReduce(
     376              :         RankId remoteRank, const LinkData& link, const DataSlice& localSlice, const DataSlice& remoteSlice,
     377              :         DataType dataType, ReduceOp reduceOp)
     378           44 :         : Instruction(InstructionType::READ_REDUCE),
     379           44 :           remoteRank_(remoteRank),
     380           44 :           link_(link),
     381           44 :           dataType_(dataType),
     382           44 :           reduceOp_(reduceOp),
     383           44 :           localSlice_(localSlice),
     384           44 :           remoteSlice_(remoteSlice)
     385           44 :     {}
     386              :     string Describe() const override;
     387              : 
     388              :     RankId GetRemoteRank() const;
     389              :     const LinkData* GetLink() const override;
     390              :     const DataSlice& GetLocalSlice() const;
     391              :     const DataSlice& GetRemoteSlice() const;
     392              :     const DataType GetDataType() const;
     393              :     const ReduceOp GetReduceOp() const;
     394              : 
     395              : private:
     396              :     RankId remoteRank_;
     397              :     LinkData link_;
     398              :     DataType dataType_;
     399              :     ReduceOp reduceOp_;
     400              :     DataSlice localSlice_;
     401              :     DataSlice remoteSlice_;
     402              : };
     403              : 
     404              : class InsBatchRead : public Instruction {
     405              : public:
     406              :     using Iterator = BaseConstIterator<vector, unique_ptr<Instruction>>;
     407           37 :     InsBatchRead(RankId remoteRank, const LinkData& link)
     408           37 :         : Instruction(InstructionType::BATCH_READ),
     409           37 :           remoteRank(remoteRank),
     410           37 :           link(link)
     411           37 :     {}
     412              :     string Describe() const override;
     413              : 
     414              :     RankId GetRemoteRank() const;
     415              :     const LinkData* GetLink() const override;
     416           11 :     Iterator Iter() const { return Iterator(readInsVec); };
     417              :     void PushReadIns(unique_ptr<Instruction> readIns);
     418              : 
     419              : private:
     420              :     RankId remoteRank;
     421              :     LinkData link;
     422              :     vector<unique_ptr<Instruction>> readInsVec;
     423              : };
     424              : 
     425              : class InsReadReduceExtend : public Instruction {
     426              : public:
     427           31 :     InsReadReduceExtend(
     428              :         RankId remoteRank, const LinkData& link, const DataBuffer& localBuffer, const DataBuffer& remoteBuffer,
     429              :         DataType dataType, ReduceOp reduceOp)
     430           31 :         : Instruction(InstructionType::READ_REDUCE_EXTEND),
     431           31 :           remoteRank_(remoteRank),
     432           31 :           link_(link),
     433           31 :           dataType_(dataType),
     434           31 :           reduceOp_(reduceOp),
     435           31 :           localBuffer_(localBuffer),
     436           31 :           remoteBuffer_(remoteBuffer)
     437           31 :     {}
     438              :     string Describe() const override;
     439              : 
     440              :     RankId GetRemoteRank() const;
     441              :     const LinkData* GetLink() const override;
     442              :     const DataBuffer& GetLocalBuffer() const;
     443              :     const DataBuffer& GetRemoteBuffer() const;
     444              :     const DataType GetDataType() const;
     445              :     const ReduceOp GetReduceOp() const;
     446              : 
     447              : private:
     448              :     RankId remoteRank_;
     449              :     LinkData link_;
     450              :     DataType dataType_;
     451              :     ReduceOp reduceOp_;
     452              :     DataBuffer localBuffer_;
     453              :     DataBuffer remoteBuffer_;
     454              : };
     455              : 
     456              : class InsWrite : public Instruction {
     457              : public:
     458           45 :     InsWrite(RankId remoteRank, const LinkData& link, const DataSlice& localSlice, const DataSlice& remoteSlice)
     459           45 :         : Instruction(InstructionType::WRITE),
     460           45 :           remoteRank_(remoteRank),
     461           45 :           link_(link),
     462           45 :           localSlice_(localSlice),
     463           45 :           remoteSlice_(remoteSlice)
     464           45 :     {}
     465              :     string Describe() const override;
     466              : 
     467              :     RankId GetRemoteRank() const;
     468              :     const LinkData* GetLink() const override;
     469              :     const DataSlice& GetLocalSlice() const;
     470              :     const DataSlice& GetRemoteSlice() const;
     471              : 
     472              : private:
     473              :     RankId remoteRank_;
     474              :     LinkData link_;
     475              :     DataSlice localSlice_;
     476              :     DataSlice remoteSlice_;
     477              : };
     478              : 
     479              : class InsWriteExtend : public Instruction {
     480              : public:
     481           33 :     InsWriteExtend(
     482              :         RankId remoteRank, const LinkData& link, const DataBuffer& localBuffer, const DataBuffer& remoteBuffer)
     483           33 :         : Instruction(InstructionType::WRITE_EXTEND),
     484           33 :           remoteRank_(remoteRank),
     485           33 :           link_(link),
     486           33 :           localBuffer_(localBuffer),
     487           33 :           remoteBuffer_(remoteBuffer)
     488           33 :     {}
     489              :     string Describe() const override;
     490              : 
     491              :     RankId GetRemoteRank() const;
     492              :     const LinkData* GetLink() const override;
     493              :     const DataBuffer& GetLocalBuffer() const;
     494              :     const DataBuffer& GetRemoteBuffer() const;
     495              : 
     496              : private:
     497              :     RankId remoteRank_;
     498              :     LinkData link_;
     499              :     DataBuffer localBuffer_;
     500              :     DataBuffer remoteBuffer_;
     501              : };
     502              : 
     503              : class InsWriteReduce : public Instruction {
     504              : public:
     505           40 :     InsWriteReduce(
     506              :         RankId remoteRank, const LinkData& link, const DataSlice& localSlice, const DataSlice& remoteSlice,
     507              :         DataType dataType, ReduceOp reduceOp)
     508           40 :         : Instruction(InstructionType::WRITE_REDUCE),
     509           40 :           remoteRank_(remoteRank),
     510           40 :           link_(link),
     511           40 :           dataType_(dataType),
     512           40 :           reduceOp_(reduceOp),
     513           40 :           localSlice_(localSlice),
     514           40 :           remoteSlice_(remoteSlice)
     515           40 :     {}
     516              :     string Describe() const override;
     517              : 
     518              :     RankId GetRemoteRank() const;
     519              :     const LinkData* GetLink() const override;
     520              :     const DataSlice& GetLocalSlice() const;
     521              :     const DataSlice& GetRemoteSlice() const;
     522              :     const DataType GetDataType() const;
     523              :     const ReduceOp GetReduceOp() const;
     524              : 
     525              : private:
     526              :     RankId remoteRank_;
     527              :     LinkData link_;
     528              :     DataType dataType_;
     529              :     ReduceOp reduceOp_;
     530              :     DataSlice localSlice_;
     531              :     DataSlice remoteSlice_;
     532              : };
     533              : 
     534              : class InsBatchWrite : public Instruction {
     535              : public:
     536              :     using Iterator = BaseConstIterator<vector, unique_ptr<Instruction>>;
     537           37 :     InsBatchWrite(RankId remoteRank, const LinkData& link)
     538           37 :         : Instruction(InstructionType::BATCH_WRITE),
     539           37 :           remoteRank(remoteRank),
     540           37 :           link(link)
     541           37 :     {}
     542              :     string Describe() const override;
     543              : 
     544              :     RankId GetRemoteRank() const;
     545              :     const LinkData* GetLink() const override;
     546           11 :     Iterator Iter() const { return Iterator(writeInsVec); };
     547              :     void PushWriteIns(unique_ptr<Instruction> writeIns);
     548              : 
     549              : private:
     550              :     RankId remoteRank;
     551              :     LinkData link;
     552              :     vector<unique_ptr<Instruction>> writeInsVec;
     553              : };
     554              : 
     555              : class InsWriteReduceExtend : public Instruction {
     556              : public:
     557           31 :     InsWriteReduceExtend(
     558              :         RankId remoteRank, const LinkData& link, const DataBuffer& localBuffer, const DataBuffer& remoteBuffer,
     559              :         DataType dataType, ReduceOp reduceOp)
     560           31 :         : Instruction(InstructionType::WRITE_REDUCE_EXTEND),
     561           31 :           remoteRank_(remoteRank),
     562           31 :           link_(link),
     563           31 :           dataType_(dataType),
     564           31 :           reduceOp_(reduceOp),
     565           31 :           localBuffer_(localBuffer),
     566           31 :           remoteBuffer_(remoteBuffer)
     567           31 :     {}
     568              :     string Describe() const override;
     569              : 
     570              :     RankId GetRemoteRank() const;
     571              :     const LinkData* GetLink() const override;
     572              :     const DataBuffer& GetLocalBuffer() const;
     573              :     const DataBuffer& GetRemoteBuffer() const;
     574              :     const DataType GetDataType() const;
     575              :     const ReduceOp GetReduceOp() const;
     576              : 
     577              : private:
     578              :     RankId remoteRank_;
     579              :     LinkData link_;
     580              :     DataType dataType_;
     581              :     ReduceOp reduceOp_;
     582              :     DataBuffer localBuffer_;
     583              :     DataBuffer remoteBuffer_;
     584              : };
     585              : 
     586              : class InsWriteWithFin : public Instruction {
     587              : public:
     588           40 :     InsWriteWithFin(
     589              :         RankId remoteRank, const LinkData& link, const DataSlice& localSlice, const DataSlice& remoteSlice,
     590              :         NotifyType notifyType = NotifyType::NORMAL, u32 bitValue = 0, u32 topicId = 0)
     591           40 :         : Instruction(InstructionType::WRITE_WITH_FIN),
     592           40 :           remoteRank_(remoteRank),
     593           40 :           link_(link),
     594           40 :           localSlice_(localSlice),
     595           40 :           remoteSlice_(remoteSlice),
     596           40 :           notifyType_(notifyType),
     597           40 :           bitValue_(bitValue),
     598           40 :           topicId_(topicId)
     599           40 :     {}
     600              :     string Describe() const override;
     601              : 
     602              :     RankId GetRemoteRank() const;
     603              :     const LinkData* GetLink() const override;
     604              :     const DataSlice& GetLocalSlice() const;
     605              :     const DataSlice& GetRemoteSlice() const;
     606              :     const NotifyType& GetNotifyType() const;
     607              :     const u32& GetTopicId() const;
     608              :     const u32& GetBitValue() const;
     609              : 
     610              : private:
     611              :     RankId remoteRank_;
     612              :     LinkData link_;
     613              :     DataSlice localSlice_;
     614              :     DataSlice remoteSlice_;
     615              :     NotifyType notifyType_;
     616              :     u32 bitValue_;
     617              :     u32 topicId_;
     618              : };
     619              : 
     620              : class InsWriteWithFinExtend : public Instruction {
     621              : public:
     622           33 :     InsWriteWithFinExtend(
     623              :         RankId remoteRank, const LinkData& link, const DataBuffer& localBuffer, const DataBuffer& remoteBuffer,
     624           31 :         NotifyType notifyType = NotifyType::NORMAL, u32 bitValue = 0, u32 topicId = 0)
     625           33 :         : Instruction(InstructionType::WRITE_WITH_FIN_EXTEND),
     626           33 :           remoteRank_(remoteRank),
     627           33 :           link_(link),
     628           33 :           localBuffer_(localBuffer),
     629           33 :           remoteBuffer_(remoteBuffer),
     630           33 :           notifyType_(notifyType),
     631           33 :           bitValue_(bitValue),
     632           33 :           topicId_(topicId)
     633           33 :     {}
     634              :     string Describe() const override;
     635              : 
     636              :     RankId GetRemoteRank() const;
     637              :     const LinkData* GetLink() const override;
     638              :     const DataBuffer& GetLocalBuffer() const;
     639              :     const DataBuffer& GetRemoteBuffer() const;
     640              :     const NotifyType& GetNotifyType() const;
     641              :     const u32& GetTopicId() const;
     642              :     const u32& GetBitValue() const;
     643              : 
     644              : private:
     645              :     RankId remoteRank_;
     646              :     LinkData link_;
     647              :     DataBuffer localBuffer_;
     648              :     DataBuffer remoteBuffer_;
     649              :     NotifyType notifyType_;
     650              :     u32 bitValue_;
     651              :     u32 topicId_;
     652              : };
     653              : 
     654              : class InsWriteReduceWithFin : public Instruction {
     655              : public:
     656           38 :     InsWriteReduceWithFin(
     657              :         RankId remoteRank, const LinkData& link, const DataSlice& localSlice, const DataSlice& remoteSlice,
     658              :         DataType dataType, ReduceOp reduceOp, NotifyType notifyType = NotifyType::NORMAL, u32 bitValue = 0,
     659              :         u32 topicId = 0)
     660           38 :         : Instruction(InstructionType::WRITE_REDUCE_WITH_FIN),
     661           38 :           remoteRank_(remoteRank),
     662           38 :           link_(link),
     663           38 :           dataType_(dataType),
     664           38 :           reduceOp_(reduceOp),
     665           38 :           localSlice_(localSlice),
     666           38 :           remoteSlice_(remoteSlice),
     667           38 :           notifyType_(notifyType),
     668           38 :           bitValue_(bitValue),
     669           38 :           topicId_(topicId)
     670           38 :     {}
     671              :     string Describe() const override;
     672              : 
     673              :     RankId GetRemoteRank() const;
     674              :     const LinkData* GetLink() const override;
     675              :     const DataSlice& GetLocalSlice() const;
     676              :     const DataSlice& GetRemoteSlice() const;
     677              :     const DataType GetDataType() const;
     678              :     const ReduceOp GetReduceOp() const;
     679              :     const NotifyType& GetNotifyType() const;
     680              :     const u32& GetTopicId() const;
     681              :     const u32& GetBitValue() const;
     682              : 
     683              : private:
     684              :     RankId remoteRank_;
     685              :     LinkData link_;
     686              :     DataType dataType_;
     687              :     ReduceOp reduceOp_;
     688              :     DataSlice localSlice_;
     689              :     DataSlice remoteSlice_;
     690              :     NotifyType notifyType_;
     691              :     u32 bitValue_;
     692              :     u32 topicId_;
     693              : };
     694              : 
     695              : class InsWriteReduceWithFinExtend : public Instruction {
     696              : public:
     697           31 :     InsWriteReduceWithFinExtend(
     698              :         RankId remoteRank, const LinkData& link, const DataBuffer& localBuffer, const DataBuffer& remoteBuffer,
     699              :         DataType dataType, ReduceOp reduceOp, NotifyType notifyType = NotifyType::NORMAL, u32 bitValue = 0,
     700              :         u32 topicId = 0)
     701           31 :         : Instruction(InstructionType::WRITE_REDUCE_WITH_FIN_EXTEND),
     702           31 :           remoteRank_(remoteRank),
     703           31 :           link_(link),
     704           31 :           dataType_(dataType),
     705           31 :           reduceOp_(reduceOp),
     706           31 :           localBuffer_(localBuffer),
     707           31 :           remoteBuffer_(remoteBuffer),
     708           31 :           notifyType_(notifyType),
     709           31 :           bitValue_(bitValue),
     710           31 :           topicId_(topicId)
     711           31 :     {}
     712              :     string Describe() const override;
     713              : 
     714              :     RankId GetRemoteRank() const;
     715              :     const LinkData* GetLink() const override;
     716              :     const DataBuffer& GetLocalBuffer() const;
     717              :     const DataBuffer& GetRemoteBuffer() const;
     718              :     const DataType GetDataType() const;
     719              :     const ReduceOp GetReduceOp() const;
     720              :     const NotifyType& GetNotifyType() const;
     721              :     const u32& GetTopicId() const;
     722              :     const u32& GetBitValue() const;
     723              : 
     724              : private:
     725              :     RankId remoteRank_;
     726              :     LinkData link_;
     727              :     DataType dataType_;
     728              :     ReduceOp reduceOp_;
     729              :     DataBuffer localBuffer_;
     730              :     DataBuffer remoteBuffer_;
     731              :     NotifyType notifyType_;
     732              :     u32 bitValue_;
     733              :     u32 topicId_;
     734              : };
     735              : 
     736              : class InsBatchOneSidedRead : public Instruction {
     737              : public:
     738           32 :     InsBatchOneSidedRead(
     739              :         RankId remoteRank, const LinkData& link, const vector<RmaBufSliceLite>& localSlice,
     740              :         const vector<RmtRmaBufSliceLite>& remoteSlice)
     741           32 :         : Instruction(InstructionType::BATCH_ONE_SIDED_READ),
     742           32 :           remoteRank_(remoteRank),
     743           32 :           link_(link),
     744           32 :           localSlice_(localSlice),
     745           32 :           remoteSlice_(remoteSlice)
     746           32 :     {}
     747              :     string Describe() const override;
     748              : 
     749              :     RankId GetRemoteRank() const;
     750              :     const LinkData* GetLink() const override;
     751              :     const vector<RmaBufSliceLite>& GetLocalSlice() const;
     752              :     const vector<RmtRmaBufSliceLite>& GetRemoteSlice() const;
     753              : 
     754              : private:
     755              :     RankId remoteRank_;
     756              :     LinkData link_;
     757              :     vector<RmaBufSliceLite> localSlice_;
     758              :     vector<RmtRmaBufSliceLite> remoteSlice_;
     759              : };
     760              : 
     761              : class InsBatchOneSidedWrite : public Instruction {
     762              : public:
     763           31 :     InsBatchOneSidedWrite(
     764              :         RankId remoteRank, const LinkData& link, const vector<RmaBufSliceLite>& localSlice,
     765              :         const vector<RmtRmaBufSliceLite>& remoteSlice)
     766           31 :         : Instruction(InstructionType::BATCH_ONE_SIDED_WRITE),
     767           31 :           remoteRank_(remoteRank),
     768           31 :           link_(link),
     769           31 :           localSlice_(localSlice),
     770           31 :           remoteSlice_(remoteSlice)
     771           31 :     {}
     772              :     string Describe() const override;
     773              : 
     774              :     RankId GetRemoteRank() const;
     775              :     const LinkData* GetLink() const override;
     776              :     const vector<RmaBufSliceLite>& GetLocalSlice() const;
     777              :     const vector<RmtRmaBufSliceLite>& GetRemoteSlice() const;
     778              : 
     779              : private:
     780              :     RankId remoteRank_;
     781              :     LinkData link_;
     782              :     vector<RmaBufSliceLite> localSlice_;
     783              :     vector<RmtRmaBufSliceLite> remoteSlice_;
     784              : };
     785              : 
     786              : class InsStreamSync : public Instruction {
     787              : public:
     788           32 :     InsStreamSync() : Instruction(InstructionType::STREAM_SYNC) {}
     789              :     string Describe() const override;
     790              : };
     791              : 
     792              : class InsAicpuReduce : public Instruction {
     793              : public:
     794           32 :     InsAicpuReduce(const DataSlice& srcSlice, const DataSlice& dstSlice, DataType dataType, ReduceOp reduceOp)
     795           32 :         : Instruction(InstructionType::AICPU_REDUCE),
     796           32 :           srcSlice_(srcSlice),
     797           32 :           dstSlice_(dstSlice),
     798           32 :           dataType_(dataType),
     799           32 :           reduceOp_(reduceOp)
     800           32 :     {}
     801              :     string Describe() const override;
     802              : 
     803              :     const DataSlice& GetSrcSlice() const;
     804              :     const DataSlice& GetDstSlice() const;
     805              :     const DataType GetDataType() const;
     806              :     const ReduceOp GetReduceOp() const;
     807              :     static void RunAicpuReduce(void* dst, u64 dstSize, void* src, u64 srcSize, DataType dataType, ReduceOp reduceOp);
     808              : 
     809              : private:
     810              :     template <typename T>
     811              :     static void AicpuReduceTemplate(T* dst, u64 dstSize, T* src, u64 srcSize, ReduceOp reduceOp);
     812              :     DataSlice srcSlice_;
     813              :     DataSlice dstSlice_;
     814              :     DataType dataType_;
     815              :     ReduceOp reduceOp_;
     816              : };
     817              : 
     818              : class InsPreStreamSync : public Instruction {
     819              : public:
     820            3 :     InsPreStreamSync() : Instruction(InstructionType::PRE_STREAM_SYNC) {}
     821              :     string Describe() const override;
     822              : };
     823              : 
     824              : } // namespace Hccl
     825              : #endif
        

Generated by: LCOV version 2.0-1