SST/macro
network_switch.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_SWITCHES_NETWORKSWITCH_H_INCLUDED
13 #define SSTMAC_HARDWARE_NETWORK_SWITCHES_NETWORKSWITCH_H_INCLUDED
14 
15 
16 
18 #include <sprockit/debug.h>
19 
24 
25 #if SSTMAC_INTEGRATED_SST_CORE
27 #endif
28 
29 #include <vector>
30 
32 
33 namespace sstmac {
34 namespace hw {
35 
36 /**
37  * @brief The network_switch class
38  * A class encapsulating a network switch that packets must traverse on the network.
39  * The network switch performs both routing computations and congestion modeling.
40  */
41 class network_switch :
42  public connectable_component,
44 {
45  public:
46  std::string
47  to_string() const {
48  return "network switch";
49  }
50 
51 #if SSTMAC_INTEGRATED_SST_CORE
53  SST::ComponentId_t id,
54  SST::Params& params
55  );
56 
57  virtual void
58  init(unsigned int phase);
59 
60  virtual void
61  setup();
62 #endif
63 
64  virtual ~network_switch();
65 
66  topology*
67  topol() const {
68  return top_;
69  }
70 
71  switch_id
72  addr() const {
73  return my_addr_;
74  }
75 
76  /**
77  * @brief rter
78  * @return The router used for performing routing computations
79  */
80  router*
81  rter() const {
82  return router_;
83  }
84 
85  virtual void
86  init_factory_params(sprockit::sim_parameters* params);
87 
88  virtual void
89  initialize() {
90  //nothing to do by default
91  }
92 
93  virtual std::vector<switch_id>
94  connected_switches() const = 0;
95 
96  virtual void
97  set_topology(topology* top);
98 
99  /**
100  * @brief queue_length
101  * Compute the number of packets waiting on the switch. The queue length
102  * is a multiple of the ``system'' packet size, which can be different from the
103  * packet size used by SST/macro congestion models. For example,
104  * the packet size of the system beings simulated might be 100B, but SST/macro
105  * might be doing congestion computations on units of 1024B.
106  * @param port The port to check the queue length of
107  * @return The queue length as an integer number of packets waiting
108  */
109  virtual int
110  queue_length(int port) const = 0;
111 
112  /**
113  @param addr The destination node addr to eject to
114  @return The ejection port the node is connected on
115  */
116  int
117  eject_port(node_id addr);
118 
119  /**
120  @param addr The source node addr to ack to
121  @return The injection port the node is connected on
122  */
123  int
124  inject_port(node_id addr);
125 
126  /**
127  @return The total hop latency to transit from input of one switch to the next (with zero congestion)
128  */
129  virtual timestamp
130  hop_latency() const = 0;
131 
132  /**
133  * @brief lookahead For parallel simulations, returns the maximum PDES lookahead possible
134  * between two network switches. This is usually (but not always) the sames as the hop latency
135  * @return The PDES lookahead
136  */
137  virtual timestamp
138  lookahead() const = 0;
139 
140  /**
141  @return The bandwidth observed hopping from switch to switch (with zero congestion)
142  */
143  virtual double
144  hop_bandwidth() const = 0;
145 
146  /**
147  * @brief connect
148  * @param src_outport The port that packets will exit on the source
149  * @param dst_inport The port that packets will enter on the destination
150  * @param ty The type of connection (usually just output or input)
151  * An output connection is a data link that carries payload
152  * from src to dst. An input connection is a control link that
153  * usually just carries credit/arbitration info from dst to src.
154  * @param mod The dst (if output link) or src (if input link)
155  * @param cfg An special configure options for the link
156  */
157  void
158  connect(
159  int src_outport,
160  int dst_inport,
161  connection_type_t ty,
162  connectable* mod,
163  config* cfg);
164 
165  virtual void
166  set_event_manager(event_manager* m);
167 #if !SSTMAC_INTEGRATED_SST_CORE
168  protected:
169  network_switch();
170 #endif
171  protected:
172  virtual void
173  connect_injector(int src_outport, int dst_inport, event_handler* nic) = 0;
174 
175  virtual void
176  connect_ejector(int src_outport, int dst_inport, event_handler* nic) = 0;
177 
178  virtual void
179  connect_output(
180  int src_outport,
181  int dst_inport,
182  connectable* mod,
183  config* cfg) = 0;
184 
185  virtual void
186  connect_input(
187  int src_outport,
188  int dst_inport,
189  connectable* mod,
190  config* cfg) = 0;
191 
192  protected:
193  switch_id my_addr_;
194  router* router_;
195  topology* top_;
196 
197 };
198 
199 #if !SSTMAC_INTEGRATED_SST_CORE
201 #endif
202 
203 
204 }
205 }
206 
207 #endif
208 
Definition: router.h:29
parallel_runtime * init()
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 DeclareFactory(...)
Definition: factory.h:297
endpoint_id node_id
Definition: node_address.h:20
DeclareDebugSlot(network_switch) namespace sstmac