SST/macro
interconnect.h
Go to the documentation of this file.
1 /*
2  * This file is part of SST/macroscale:
3  * The macroscale architecture simulator from the SST suite.
4  * Copyright (c) 2009 Sandia Corporation.
5  * This software is distributed under the BSD License.
6  * Under the terms of Contract DE-AC04-94AL85000 with Sandia Corporation,
7  * the U.S. Government retains certain rights in this software.
8  * For more information, see the LICENSE file in the top
9  * SST/macroscale directory.
10  */
11 
12 #ifndef SSTMAC_HARDWARE_NETWORK_CONGESTION_INTERCONNECT_H_INCLUDED
13 #define SSTMAC_HARDWARE_NETWORK_CONGESTION_INTERCONNECT_H_INCLUDED
14 
17 
23 
25 
26 #include <sprockit/debug.h>
28 #include <sprockit/unordered.h>
29 
30 #include <set>
31 
32 DeclareDebugSlot(interconnect)
33 
34 #define interconn_debug(...) \
35  debug_printf(sprockit::dbg::interconnect, __VA_ARGS__)
36 
37 #if SSTMAC_INTEGRATED_SST_CORE
38 #define SSTMAC_SET_TOPOLOGY(obj, top) //no op
39 #define STATIC_INIT_TOPOLOGY(params) \
40 { \
41  sstmac::hw::topology* top = sstmac::hw::topology::static_topology(params); \
42  set_topology(top); \
43 } \
44 
45 #define STATIC_INIT_INTERCONNECT(params) \
46 { \
47  sstmac::hw::interconnect* top = sstmac::hw::interconnect::static_interconnect(params); \
48  set_interconnect(top); \
49 }
50 
51 #else
52 #define SSTMAC_SET_TOPOLOGY(obj, top) obj->set_topology(top);
53 #define STATIC_INIT_TOPOLOGY(params) //no op
54 #define STATIC_INIT_INTERCONNECT(params)
55 #endif
56 
57 namespace sstmac {
58 namespace hw {
59 
60 /**
61  * Base class for network congestion models.
62  */
63 class interconnect :
65 {
66 
67  public:
68  typedef spkt_unordered_map<switch_id, connectable*> internal_map;
69  typedef spkt_unordered_map<node_id, connectable*> endpoint_map;
70  typedef spkt_unordered_map<node_id, node*> node_map;
71  typedef spkt_unordered_map<node_id, nic*> nic_map;
72 
73  virtual std::string
74  to_string() const {
75  return "interconnect";
76  }
77 
78  virtual ~interconnect();
79 
80  virtual int
81  num_nodes() const;
82 
83  virtual topology*
84  topol() const {
85  return topology_;
86  }
87 
88  virtual void
89  init_factory_params(sprockit::sim_parameters* params);
90 
91 #if !SSTMAC_INTEGRATED_SST_CORE
92  /**
93  Do not actually inject the message into the network
94  or do any congestion modeling. Just immediately
95  schedule the message at its destination after some
96  computed delay.
97  @param msg The message to send to the destination
98  */
99  virtual void
100  immediate_send(event_scheduler* src, message* msg, timestamp start) const = 0;
101 
102  virtual void
103  set_event_manager(event_manager* mgr){};
104 #endif
105 
106  /**
107  * @brief Return the node corresponding to given ID.
108  * No bounds checking is done for validity of ID.
109  * NULL is a valid return value for parallel simulation
110  * since it means node belongs to another process
111  * @param nid The ID of the node object to get
112  * @return The node object or NULL, if ID is not found
113  */
114  node*
115  node_at(node_id nid) const {
116  node_map::const_iterator it = nodes_.find(nid);
117  if (it == nodes_.end()){
118  return 0;
119  } else {
120  return it->second;
121  }
122  }
123 
124  const node_map&
125  nodes() const {
126  return nodes_;
127  }
128 
129  virtual void
130  kill_node(node_id nid) = 0;
131 
132  virtual void
133  kill_node(node_id nid, timestamp t) = 0;
134 
135  static interconnect*
136  static_interconnect(sprockit::sim_parameters* params);
137 
138  virtual void
139  deadlock_check(){}
140 
141  protected:
142  interconnect();
143 
144  protected:
145  topology* topology_;
146 
147  node_map nodes_;
148  nic_map nics_;
149 
150  // network state
151  typedef void * Stats;
152  std::map <switch_id, std::map <switch_id, std::list <Stats> > > state;
153 
154  private:
155  static interconnect* static_interconnect_;
156 
157  void set_topology(topology* params);
158 };
159 
160 #if SSTMAC_INTEGRATED_SST_CORE
161 class sst_interconnect : public interconnect
162 {
163 
164  public:
165  sst_interconnect(partition* part, parallel_runtime* rt){}
166 
167  event_loc_id
168  event_location() const {
169  return event_loc_id::null;
170  }
171 
172  virtual void
173  init_factory_params(sprockit::sim_parameters* params);
174 
175  virtual void
176  kill_node(node_id nid);
177 
178  virtual void
179  kill_node(node_id nid, timestamp t);
180 
181 };
182 typedef sst_interconnect interconnect_base;
183 #else
184 class macro_interconnect : public interconnect
185 {
186  public:
187  virtual ~macro_interconnect();
188 
189  virtual void
190  init_factory_params(sprockit::sim_parameters *params);
191 
192  virtual void
193  set_event_manager(event_manager* m);
194 
195  void
196  set_node_event_manager(node* the_node, event_manager* m);
197 
198  void
199  set_event_manager_common(event_manager* m);
200 
201  void
202  kill_node(node_id nid);
203 
204  void
205  kill_node(node_id nid, timestamp t);
206 
207  virtual void
208  handle(event* ev);
209 
210  protected:
211  macro_interconnect(partition* part, parallel_runtime* rt) :
212  partition_(part), rt_(rt)
213  {
214  }
215 
216  protected:
217  partition* partition_;
218  parallel_runtime* rt_;
219 
220  typedef spkt_unordered_map<netlink_id, netlink*> netlink_map;
221  netlink_map netlinks_;
222 
223  typedef std::pair<timestamp, node_id> node_fail_event;
224  std::list<node_fail_event> failures_to_schedule_;
225 };
226 typedef macro_interconnect interconnect_base;
227 #endif
228 
229 DeclareFactory2InitParams(interconnect, partition*, parallel_runtime*);
230 
231 }
232 } // end of namespace sstmac
233 
234 #endif
static event_loc_id null
DeclareFactory2InitParams(processor, memory_model *, node *)
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
DeclareDebugSlot(interconnect) namespace sstmac
Definition: interconnect.h:32
endpoint_id node_id
Definition: node_address.h:20