SST/macro
packetizer.h
Go to the documentation of this file.
1 #ifndef PACKETIZER_H
2 #define PACKETIZER_H
3 
9 #if SSTMAC_INTEGRATED_SST_CORE
11 #include <sst/core/interfaces/simpleNetwork.h>
12 #endif
13 
14 namespace sstmac {
15 namespace hw {
16 
18 {
19  public:
20  virtual void notify(int vn, message* msg) = 0;
21 
23 };
24 
25 class packetizer :
27  public event_subscheduler
28 {
29 
30  public:
31  virtual ~packetizer();
32 
33  void start(int vn, message* payload);
34 
35  void packetArrived(int vn, packet* pkt);
36 
37  void sendWhatYouCan(int vn);
38 
40  notifier_ = handler;
41  }
42 
43  int packetSize() const {
44  return packet_size_;
45  }
46 
47 #if SSTMAC_INTEGRATED_SST_CORE
48  public:
49  virtual void
50  init_sst_params(SST::Params& params, SST::Component* parent){}
51 #endif
52 
53  virtual void
54  init_factory_params(sprockit::sim_parameters *params);
55 
56  private:
57  virtual void inject(int vn, long bytes, long byte_offset, message* payload) = 0;
58 
59  virtual bool spaceToSend(int vn, int num_bits) const = 0;
60 
61  private:
63 
64  struct pending_send{
66  long bytes_left;
67  long offset;
68  };
69 
70  std::map<int, std::list<pending_send> > pending_;
71 
73 
75 
76  protected:
77  packetizer() : notifier_(nullptr){}
78 
79  void bytesArrived(int vn, uint64_t unique_id, int bytes, message* parent);
80 
81 };
82 
84 
85 #if SSTMAC_INTEGRATED_SST_CORE
86 class SimpleNetworkPacket : public SST::Event
87 {
88  NotSerializable(SimpleNetworkPacket)
89 
90  public:
91  SimpleNetworkPacket(uint64_t id) : unique_id(id) {}
92  uint64_t unique_id;
93 };
94 
95 class SimpleNetworkPacketizer :
96  public packetizer
97 {
98  public:
99  bool spaceToSend(int vn, int num_bits) const;
100 
101  void inject(int vn, long bytes, long byte_offset, message *payload);
102 
103  virtual void init_sst_params(SST::Params &params, SST::Component *parent);
104 
105  bool recvNotify(int vn);
106 
107  bool sendNotify(int vn);
108 
109  private:
110  SST::Interfaces::SimpleNetwork* m_linkControl;
111  SST::Interfaces::SimpleNetwork::HandlerBase* m_recvNotifyFunctor;
112  SST::Interfaces::SimpleNetwork::HandlerBase* m_sendNotifyFunctor;
113 
114 };
115 #endif
116 
117 }
118 }
119 
120 #endif // PACKETIZER_H
A class describing an event.
Definition: sst_message.h:42
DeclareFactory(node)
void setNotify(packetizer_callback *handler)
Definition: packetizer.h:39
virtual void notify(int vn, message *msg)=0
#define NotSerializable(obj)
Definition: serializable.h:26
std::map< int, std::list< pending_send > > pending_
Definition: packetizer.h:70
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
packetizer_callback * notifier_
Definition: packetizer.h:74
int packetSize() const
Definition: packetizer.h:43