SST/macro
packet_flow_buffer.h
Go to the documentation of this file.
1 #ifndef BUFFER_H
2 #define BUFFER_H
3 
7 
8 namespace sstmac {
9 namespace hw {
10 
11 
13  public packet_flow_sender
14 {
15 
16  public:
17  virtual ~packet_flow_buffer();
18 
19  virtual void
20  set_output(int this_outport, int dst_inport,
21  event_handler* output);
22 
23  virtual int
24  queue_length() const {
25  return 0;
26  }
27 
29  output_location() const {
30  return output_.handler->event_location();
31  }
32 
34  input_location() const {
35  return input_.handler->event_location();
36  }
37 
38 
39 
40  protected:
41  /**
42  * @param send_lat
43  * @param credit_lat
44  * @param arb An arbitrator with outgoing bw already initialized
45  */
47  const timestamp& send_lat,
48  const timestamp& credit_lat,
50 
52 
53  std::string
54  buffer_string(const char* name) const;
55 
56  protected:
61 
62  static const int my_outport = 0;
63  static const int my_inport = 0;
64 };
65 
67  public packet_flow_buffer
68 {
69  public:
71 
72  virtual void
73  set_input(int this_inport, int src_outport,
74  event_handler* input);
75 
76  long
77  size_bytes() const {
78  return size_bytes_;
79  }
80 
81  int
83  return size_bytes_;
84  }
85 
86  protected:
88 
90  const timestamp& send_lat,
91  const timestamp& credit_lat,
92  int max_num_bytes,
94  size_bytes_(max_num_bytes),
95  packet_flow_buffer(send_lat, credit_lat, arb)
96  {
97  }
98 
100 
101 };
102 
104  public packet_flow_buffer
105 {
106  protected:
108  const timestamp& send_lat,
110  packet_flow_buffer(send_lat, timestamp(0), arb)
111  {
112  }
113 
115 
117 
118  void //no-op, I don't need to send credits to an input, I'm infinite
119  set_input(int my_inport, int dst_outport, event_handler *input){}
120 
121  int
122  num_initial_credits() const;
123 
124 };
125 
128 {
129  public:
131 
133  const timestamp& send_lat,
134  const timestamp& credit_lat,
135  int max_num_bytes,
136  int num_vc,
137  int packet_size,
139 
141 
142  int
143  queue_length() const;
144 
145  void
146  init_credits(int port, int num_credits);
147 
148  void
149  handle_credit(packet_flow_credit* msg);
150 
151  void
152  do_handle_payload(packet_flow_payload* pkt);
153 
154  std::string
156  return "network buffer";
157  }
158 
159  void deadlock_check();
160 
161  void deadlock_check(event* ev);
162 
163  protected:
164  int num_vc_;
165  std::vector<payload_queue> queues_;
166  std::vector<int> credits_;
167 
168  private:
169  void build_blocked_messages();
170 
171  private:
172  std::set<int> deadlocked_channels_;
173  std::map<int, std::list<packet_flow_payload*> > blocked_messages_;
177 };
178 
181 {
182  public:
184  const timestamp& send_lat,
185  const timestamp& credit_lat,
186  int max_num_bytes,
188 
190 
191  void
192  handle_credit(packet_flow_credit* msg);
193 
194  void
195  return_credit(packet* msg);
196 
197  void
198  do_handle_payload(packet_flow_payload* pkt);
199 
200  std::string
202  return "eject buffer";
203  }
204 
205  void
206  init_credits(int port, int num_credits);
207 
208 };
209 
212 {
213  public:
215  const timestamp& out_lat,
217  int packet_size);
218 
219  int
220  queue_length() const;
221 
222  void
223  init_credits(int port, int num_credits);
224 
225  bool
226  space_to_send(int bytes) const {
227  return credits_ >= bytes;
228  }
229 
230  void
231  handle_credit(packet_flow_credit* msg);
232 
233  void
234  do_handle_payload(packet_flow_payload* pkt);
235 
236  std::string
238  return "inject buffer";
239  }
240 
241  protected:
243 
244  long credits_;
245 
247 
248 };
249 
250 }
251 }
252 
253 
254 #endif // BUFFER_H
255 
packet_flow_bandwidth_arbitrator * arb_
std::vector< payload_queue > queues_
std::string buffer_string(const char *name) const
std::map< int, std::list< packet_flow_payload * > > blocked_messages_
virtual void set_input(int my_inport, int dst_outport, event_handler *input)=0
event_loc_id input_location() const
virtual void init_credits(int port, int num_credits)=0
event_loc_id output_location() const
packet_flow_finite_buffer(const timestamp &send_lat, const timestamp &credit_lat, int max_num_bytes, packet_flow_bandwidth_arbitrator *arb)
void set_input(int my_inport, int dst_outport, event_handler *input)
virtual void set_output(int this_outport, int dst_inport, event_handler *output)
The main interface for something that can respond to an event (sst_message).
Definition: event_handler.h:24
A basic container for time (subject to future transplant).
Definition: timestamp.h:29
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
event_loc_id event_location() const
Definition: event_handler.h:63
virtual int queue_length() const
virtual int num_initial_credits() const =0
virtual void deadlock_check()
Definition: event_handler.h:86
packet_flow_infinite_buffer(const timestamp &send_lat, packet_flow_bandwidth_arbitrator *arb)
virtual void do_handle_payload(packet_flow_payload *pkt)=0
virtual void handle_credit(packet_flow_credit *msg)=0