SST/macro
nic.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_BACKENDS_NATIVE_COMPONENTS_NIC_NETWORKINTERFACE_H_INCLUDED
13 #define SSTMAC_BACKENDS_NATIVE_COMPONENTS_NIC_NETWORKINTERFACE_H_INCLUDED
14 
27 
28 #include <sprockit/debug.h>
30 
31 DeclareDebugSlot(nic);
32 
33 #define nic_debug(...) \
34  debug_printf(sprockit::dbg::nic, "NIC on node %d: %s", \
35  int(addr()), sprockit::printf(__VA_ARGS__).c_str())
36 
37 namespace sstmac {
38 namespace hw {
39 
40 /**
41  * A networkinterface is a delegate between a node and a server module.
42  * This object helps ornament network operations with information about
43  * the process (ppid) involved.
44  */
45 class nic :
47  public failable,
49 {
50 #if SSTMAC_INTEGRATED_SST_CORE
51  public:
52  void handle_event(SST::Event* ev);
53 #endif
54  public:
55  virtual std::string
56  to_string() const = 0;
57 
58  virtual ~nic();
59 
60  /**
61  * Initialize all member variables from the parameters object
62  * @param params
63  */
64  virtual void
65  init_factory_params(sprockit::sim_parameters* params);
66 
67  /**
68  * @return A unique ID for the NIC positions. Opaque typedef to an int.
69  */
70  node_id
71  addr() const {
72  return my_addr_;
73  }
74 
75  /**
76  * Set an event handler wrapper encapsulation the parent computational unit.
77  * @param nd The compute node attached to the NIC
78  */
79  virtual void
80  set_node(node* nd){
81  parent_ = nd;
82  }
83 
84  /**
85  * Delete all static variables associated with this class.
86  * This should be registered with the runtime system via need_delete_statics
87  */
88  static void
90 
91  /**
92  * A final initialization function called for the object after all parameters have been read.
93  * Guarantees initialization of all subclass variables.
94  */
95  virtual void
96  finalize_init();
97 
98  virtual void
99  handle(event *ev) = 0;
100 
101  void
102  mtl_handle(event* ev);
103 
105  mtl_handler() const {
106  return mtl_handler_;
107  }
108 
109  /**
110  Perform the set of operations standard to all NICs.
111  This then passes control off to a model-specific #do_send
112  function to actually carry out the send
113  @param payload The network message to send
114  */
115  void
117 
118  /**
119  Perform the set of operations standard to all NICs
120  for transfers within a node. This function is model-independent,
121  unlike #internode_send which must pass control to #do_send.
122  * @param payload
123  */
124  void
126 
127  /**
128  * @return The injection latency for moving a packet from the NIC to the
129  * first network router (or netlink block, etc)
130  */
131  virtual timestamp
132  injection_latency() const = 0;
133 
134  virtual double
135  injection_bandwidth() const = 0;
136 
137  virtual void
139 
140 
141  protected:
142  nic(sprockit::factory_type* interconn);
143 
144  /**
145  Start the message sending and inject it into the network
146  This performs all model-specific work
147  @param payload The network message to send
148  */
149  virtual void
150  do_send(network_message* payload) = 0;
151 
152  void
153  send_to_node(network_message* netmsg);
154 
155  bool
156  negligible_size(int bytes) const {
157  return bytes <= negligible_size_;
158  }
159 
160  /**
161  The NIC can either receive an entire message (bypass the byte-transfer layer)
162  or it can receive packets. If an incoming message is a full message (not a packet),
163  it gets routed here. Unlike #recv_chunk, this has a default implementation and does not throw.
164  @param chunk
165  */
166  void
167  recv_message(message* msg);
168 
169  protected:
171 
173 
174  interconnect* interconn_;
176 
177  private:
184 
185  private:
186  /**
187  For messages requiring an NIC ACK to signal that the message
188  has injected into the interconnect. Create an ack and
189  send it up to the parent node.
190  */
191  void
192  ack_send(network_message* payload);
193 
194  void
196 
197  void record_message(network_message* msg);
198 
199 };
200 
202 
203 }
204 } // end of namespace sstmac.
205 
206 #endif
207 
stat_global_int * global_bytes_sent_
Definition: nic.h:182
A class describing an event.
Definition: sst_message.h:42
void internode_send(network_message *payload)
Perform the set of operations standard to all NICs.
DeclareDebugSlot(nic)
node * parent_
Definition: nic.h:175
void recv_message(message *msg)
The NIC can either receive an entire message (bypass the byte-transfer layer) or it can receive packe...
stat_spyplot * spy_bytes_
Definition: nic.h:179
node_id addr() const
Definition: nic.h:71
void intranode_send(network_message *payload)
Perform the set of operations standard to all NICs for transfers within a node.
interconnect * interconn_
Definition: nic.h:174
DeclareFactory1InitParam(nic, sprockit::factory_type *)
nic(sprockit::factory_type *interconn)
void record_message(network_message *msg)
void mtl_handle(event *ev)
virtual void set_node(node *nd)
Set an event handler wrapper encapsulation the parent computational unit.
Definition: nic.h:80
The main interface for something that can respond to an event (sst_message).
Definition: event_handler.h:24
bool negligible_size(int bytes) const
Definition: nic.h:156
void send_to_node(network_message *netmsg)
virtual ~nic()
void send_to_interconn(network_message *netmsg)
A basic container for time (subject to future transplant).
Definition: timestamp.h:29
int negligible_size_
Definition: nic.h:172
static void delete_statics()
Delete all static variables associated with this class.
event_handler * mtl_handler() const
Definition: nic.h:105
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
stat_histogram * hist_msg_size_
Definition: nic.h:180
virtual std::string to_string() const =0
virtual void init_factory_params(sprockit::sim_parameters *params)
Initialize all member variables from the parameters object.
A networkinterface is a delegate between a node and a server module.
Definition: nic.h:45
virtual void handle(event *ev)=0
this stat_collector class keeps a spy plot
Definition: stat_spyplot.h:28
virtual void finalize_init()
A final initialization function called for the object after all parameters have been read...
The interface for something that can schedule messages.
void ack_send(network_message *payload)
For messages requiring an NIC ACK to signal that the message has injected into the interconnect...
virtual void set_event_parent(event_scheduler *m)
Set the eventmanager for this scheduler.
virtual double injection_bandwidth() const =0
virtual void do_send(network_message *payload)=0
Start the message sending and inject it into the network This performs all model-specific work...
node_id my_addr_
Definition: nic.h:170
endpoint_id node_id
Definition: node_address.h:20
event_handler * mtl_handler_
Definition: nic.h:183
stat_local_int * local_bytes_sent_
Definition: nic.h:181
virtual timestamp injection_latency() const =0
stat_spyplot * spy_num_messages_
Definition: nic.h:178