SST/macro
packet_flow_crossbar.h
Go to the documentation of this file.
1 #ifndef PACKETFLOW_CROSSBAR_H
2 #define PACKETFLOW_CROSSBAR_H
3 
9 
10 namespace sstmac {
11 namespace hw {
12 
14  public packet_flow_sender
15 {
16  public:
17  virtual ~packet_flow_NtoM_queue();
18 
20  timestamp send_lat,
21  timestamp credit_lat,
22  double out_bw,
23  int num_vc,
24  int buffer_size,
26 
28  timestamp send_lat,
29  timestamp credit_lat,
30  int num_vc,
31  int buffer_size);
32 
33  int
34  thread_id() const {
36  }
37 
38  virtual void
39  do_handle_payload(packet_flow_payload* pkt){
41  }
42 
43  void
44  set_input(int my_inport, int src_outport, event_handler* input);
45 
46  void
47  set_output(int my_outport, int dst_inport, event_handler* output);
48 
49  virtual void
50  handle_credit(packet_flow_credit* msg);
51 
52  virtual void
53  start_message(message* msg);
54 
55  void
56  init_credits(int port, int num_credits);
57 
58  int
60  return buffer_size_;
61  }
62 
63  int
64  buffer_size() const {
65  return buffer_size_;
66  }
67 
68  void
69  configure_mod_ports(int mod);
70 
71  void
72  configure_div_ports(int div, int max_port);
73 
74  void
75  configure_offset_ports(int offset, int max_port);
76 
77  void
78  configure_basic_ports(int num_ports);
79 
80  inline int
81  local_port(int port) const {
82  if (port_mod_){
83  return port % port_mod_;
84  } else {
85  return port / port_div_ - port_offset_;
86  }
87  }
88 
89  inline int
90  local_slot(int port, int vc) const {
91  return local_port(port) * num_vc_ + vc;
92  }
93 
95  port_arbitrator(int port){
96  return port_arbitrators_[local_port(port)];
97  }
98 
99  void
100  deadlock_check();
101 
102  void
103  deadlock_check(event* ev);
104 
105  protected:
106  struct request {
107  int port;
109  };
110 
111  typedef std::list<request> buffer_request_list;
112 
113  typedef spkt_unordered_map<int, buffer_request_list> xbar_request_map;
114 
115  void
116  handle_routed_payload(packet_flow_payload* pkt);
117 
118  protected:
119  typedef spkt_unordered_map<int, packet_flow_input> input_map;
120 
121  typedef std::vector<packet_flow_output> output_map;
122  typedef std::vector<int> credit_map;
123  typedef std::vector<payload_queue> queue_map;
124 
126 
127  std::vector<packet_flow_bandwidth_arbitrator*> port_arbitrators_;
128 
129  input_map inputs_;
130  //indexed by slot number = (port,vc)
131  output_map outputs_;
132  //indexed by slot number = (port,vc)
133  credit_map credits_;
134  //indexed by slot number = (port,vc)
135  queue_map queues_;
136 
137  int num_vc_;
142 
143  double out_bw_;
144 
145  std::map<int, std::set<int> > deadlocked_channels_;
146 
147  std::map<int, std::map<int, std::list<packet_flow_payload*> > > blocked_messages_;
148 
149  protected:
150  void
151  send_payload(packet_flow_payload* pkt);
152 
153  void
155 
156  private:
157  inline int& credit(int port, int vc){
158  return credits_[local_slot(port, vc)];
159  }
160 
161  void resize(int num_ports);
162 
163  inline payload_queue& queue(int port, int vc){
164  return queues_[local_slot(port, vc)];
165  }
166 
167  std::string
168  input_name(packet_flow_payload* pkt);
169 
170  std::string
171  output_name(packet_flow_payload* pkt);
172 
174  output_handler(packet_flow_payload* pkt);
175 
176 };
177 
180 {
181  public:
182  virtual std::string
183  to_string() const {
184  return "packet_flow_demuxer";
185  }
186 
188  timestamp send_lat,
189  timestamp credit_lat,
190  int num_vc,
191  int buffer_size);
192 
193  std::string
195  return "demuxer";
196  }
197 };
198 
199 
202 {
203  public:
205  timestamp send_lat,
206  timestamp credit_lat,
207  double out_bw,
208  int num_vc,
209  int buffer_size,
211 
212  std::string
214  return "muxer";
215  }
216 
217 };
218 
221 {
222  public:
224  timestamp send_lat,
225  timestamp credit_lat,
226  double out_bw,
227  int num_vc,
228  int buffer_size,
230 
232  timestamp send_lat,
233  timestamp credit_lat,
234  int num_vc,
235  int buffer_size,
236  const char* name = 0);
237 
238  std::string
240  if (name_) return name_;
241  else return "crossbar";
242  }
243 
244  private:
245  const char* name_;
246 
247 };
248 
249 
250 }
251 }
252 
253 #endif // PACKETFLOW_CROSSBAR_H
254 
std::vector< packet_flow_bandwidth_arbitrator * > port_arbitrators_
std::string packet_flow_name() const
virtual void start_message(message *msg)
A class describing an event.
Definition: sst_message.h:42
std::map< int, std::map< int, std::list< packet_flow_payload * > > > blocked_messages_
std::map< int, std::set< int > > deadlocked_channels_
void configure_div_ports(int div, int max_port)
packet_flow_NtoM_queue(timestamp send_lat, timestamp credit_lat, double out_bw, int num_vc, int buffer_size, packet_flow_bandwidth_arbitrator *arb)
int local_slot(int port, int vc) const
void configure_offset_ports(int offset, int max_port)
void set_output(int my_outport, int dst_inport, event_handler *output)
int thread_id() const
Definition: event_handler.h:78
event_handler * output_handler(packet_flow_payload *pkt)
spkt_unordered_map< int, packet_flow_input > input_map
void handle_routed_payload(packet_flow_payload *pkt)
std::string output_name(packet_flow_payload *pkt)
virtual void do_handle_payload(packet_flow_payload *pkt)
std::string input_name(packet_flow_payload *pkt)
The main interface for something that can respond to an event (sst_message).
Definition: event_handler.h:24
packet_flow_bandwidth_arbitrator * arb_tmpl_
std::vector< packet_flow_output > output_map
virtual void handle_credit(packet_flow_credit *msg)
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...
virtual std::string to_string() const
void send_payload(packet_flow_payload *pkt)
void init_credits(int port, int num_credits)
packet_flow_bandwidth_arbitrator *& port_arbitrator(int port)
payload_queue & queue(int port, int vc)
void configure_basic_ports(int num_ports)
std::vector< payload_queue > queue_map
spkt_unordered_map< int, buffer_request_list > xbar_request_map
void set_input(int my_inport, int src_outport, event_handler *input)