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

Generated by: LCOV version 2.0-1