SST/macro
router.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_ROUTING_ROUTER_H_INCLUDED
13 #define SSTMAC_HARDWARE_NETWORK_ROUTING_ROUTER_H_INCLUDED
14 
15 
21 
22 #include <sprockit/debug.h>
24 
27 
28 
30 
31 #define rter_debug(...) \
32  debug_printf(sprockit::dbg::router, "Router on switch %d: %s", int(my_addr_), sprockit::printf(__VA_ARGS__).c_str())
33 
34 
35 namespace sstmac {
36 namespace hw {
37 
38 /**
39  @class router
40  Class that computes the next step a messag should taken in traversing
41  the network. This performs routing operations only and is not actually
42  a 'component' in the network - those are switches. Switch and router
43  are not synonymous in SST/macro. All switches have routers.
44 */
45 class router :
47 {
48  public:
49  /**
50  * @brief The structured_path struct Identifies a (structurally) unique
51  * path in the topology. For example, there might be multiple links on a
52  * router than connect to the +X router in a torus. However,
53  * these links are all considered to be ``structurally'' equivalent.
54  */
55  struct structured_path {
56  /**
57  * @brief redundancy How many redundant physical links compose the single structural link
58  */
59  int redundancy;
60 
61  /**
62  * @brief path_counter The index of the last redundant path taken
63  */
64  int path_counter;
65 
66  structured_path() : path_counter(0) {}
67 
68  /**
69  * @brief next_index
70  * @return The next redundant path that should be taken based on the previously taken paths
71  */
72  int next_index() {
73  int ret = path_counter;
74  path_counter = (path_counter + 1) % redundancy;
75  return ret;
76  }
77  };
78 
79  public:
80  virtual std::string
81  to_string() const {
82  return "router";
83  }
84 
85  virtual ~router();
86 
87  virtual void
88  init_factory_params(sprockit::sim_parameters* params);
89 
90  virtual void
91  finalize_init();
92 
93  /**
94  * @brief route Makes a routing decision for the packet.
95  * All routing decisions should be stored on the packet object itself.
96  * @param pkt
97  */
98  virtual void
99  route(packet* pkt) = 0;
100 
101  /**
102  Compute the minimal path to a node.
103  This method can not be const. For some cases,
104  there are multiple minimal paths that rotate
105  in a round-robin fasion to spread load (fat-tree, fbfly).
106  The router needs to update its round-robin index
107  when computing a path - hence no constness.
108  @param node_addr The node routing to
109  @param path [inout] The path to route along. This might
110  contain information about previous steps take along the path.
111  */
112  virtual void
113  minimal_route_to_node(
114  node_id node_addr,
115  structured_routable::path& path);
116 
117  /**
118  Compute the minimal path to a switch.
119  This method can not be const. For some cases,
120  there are multiple minimal paths that rotate
121  in a round-robin fasion to spread load (fat-tree, fbfly).
122  The router needs to update its round-robin index
123  when computing a path - hence no constness.
124  @param sw_addr The switch routing to
125  @param path [inout] The path to route along
126  */
127  virtual void
128  minimal_route_to_switch(
129  switch_id sw_addr,
130  structured_routable::path& path);
131 
132  virtual void
133  init_stats(event_manager* m){}
134 
135  void init_vc();
136 
137  virtual void
138  set_switch(network_switch* sw);
139 
140  /**
141  @return Whether we are ejecting
142  @param dst The destination node
143  @param ports The ports that make progress towards the final destination.
144  If ejecting, this contains only the ejection port.
145  */
146  bool
147  productive_paths_to_node(
148  node_id dst,
149  structured_routable::path_set& paths);
150 
151  /**
152  * @brief productive_paths_to_switch Get the set of all paths
153  * that corresponding to ``productive'' steps towards a destination switch
154  * @param dst The ID for the destination switch
155  * @param paths [inout] The set of productive paths that move closer to the destination switch
156  */
157  virtual void
158  productive_paths_to_switch(
159  switch_id dst,
160  structured_routable::path_set& paths) = 0;
161 
163  get_switch() const {
164  return netsw_;
165  }
166 
167  /**
168  * @brief addr
169  * @return
170  */
171  switch_id
172  addr() const {
173  return my_addr_;
174  }
175 
176  topology*
177  topol() const {
178  return top_;
179  }
180 
181  virtual void
182  set_topology(topology* top) {
183  top_ = top;
184  }
185 
186  /**
187  * @brief max_num_vc
188  * @return The maximum number of virtual channels the router must maintain
189  * to implement all possible routing algorithms
190  */
191  int
192  max_num_vc() const {
193  return max_num_vc_;
194  }
195 
196  protected:
198 
200  str_to_algo(const std::string& str);
201 
202  protected:
203  switch_id my_addr_;
204 
205  topology* top_;
206 
207  network_switch* netsw_;
208 
209  bool hop_count_reporting_;
210 
211  int hop_count_delta_;
212 
213  int max_num_vc_;
214 
215  typedef std::map<routing::algorithm_t, int> algo_to_vc_map;
216  algo_to_vc_map num_vc_lookup_;
217 
218  routing::algorithm_t algo_;
219 
220 };
221 
223 
224 
225 
226 
227 
228 }
229 }
230 #endif
231 
Definition: router.h:29
DeclareFactory(node)
topology_id switch_id
Definition: node_address.h:23
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
#define DeclareDebugSlot(name)
Macro used for declaring a debug slot in a header file.
Definition: debug.h:244
endpoint_id node_id
Definition: node_address.h:20