SST/macro
node.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_NODE_NODE_H_INCLUDED
13 #define SSTMAC_BACKENDS_NATIVE_COMPONENTS_NODE_NODE_H_INCLUDED
14 
21 
32 
34 #include <sprockit/debug.h>
35 
36 DeclareDebugSlot(node);
37 #define node_debug(...) \
38  debug_printf(sprockit::dbg::node, "Node %d: %s", int(addr()), sprockit::printf(__VA_ARGS__).c_str())
39 
40 namespace sstmac {
41 namespace hw {
42 
43 class node :
45  public failable,
47 {
48 
49  public:
50 #if SSTMAC_INTEGRATED_SST_CORE
51  node(
52  SST::ComponentId_t id,
53  SST::Params& params
54  );
55 
56  void setup();
57 
58  void init(unsigned int phase);
59 #endif
60  virtual void
62 
63 
64  virtual ~node();
65  /**
66  Standard factory type initializer. Perform extra initialization work
67  after all parameters have been read in.
68  */
69  virtual void
70  finalize_init();
71 
72  /**
73  Standard factory type initializer. Read in all parameters.
74  @params The parameter object
75  */
76  virtual void
77  init_factory_params(sprockit::sim_parameters* params);
78 
79  /**
80  Initializer used in stand-alone core.
81  @param n The network interface object
82  */
83  void
84  set_nic(nic* n){
85  nic_ = n;
86  }
87 
88  void
89  connect(int src_outport, int dst_inport,
91  config *cfg);
92 
93  /**
94  @return The object encapsulating the memory model
95  */
97  mem() const {
98  return mem_model_;
99  }
100 
101  /**
102  @return A handler wrapper for scheduling events to the NIC
103  */
104  nic*
105  get_nic() const {
106  return nic_;
107  }
108 
109  /**
110  @return The operating system managing apps on this node
111  */
113  os() const {
114  return os_;
115  }
116 
117  /**
118  @return A unique string description of the node
119  */
120  virtual std::string
121  to_string() const;
122 
123  /**
124  @return A unique integer identifier
125  */
126  node_id
127  addr() const {
128  return my_addr_;
129  }
130 
131  /**
132  Cause the node to crash. This cancels all future events for this node.
133  */
134  void fail_stop();
135 
136  /**
137  Choose a unique (64-bit) integer ID for a message. This will never be reused
138  except for integer overflow.
139  @return A unique 64-bit integer
140  */
143  return next_outgoing_id_++;
144  }
145 
146  /**
147  Make the node execute a particular compute function. This
148  generally causes the function to be executed immediately.
149  @param func Enum identifying the type of computation
150  @param data Event object encapsulating data/metadata for computation
151  @param cb The event to execute when kernel is complete
152  */
153  virtual void
154  execute(ami::COMP_FUNC func,
155  event* data,
156  callback* cb) = 0;
157 
158  /**
159  * @brief execute Asynchronously execute a kernel on some
160  * service associated with the node. This generally enqueues an operation
161  * to be performed - not necessarily executing it immediately.
162  * @param func
163  * @param data
164  */
165  virtual void
167  event* data);
168 
169  virtual void
170  handle(event* ev);
171 
172  /**
173  Push a network message (operation at the MTL layer) onto the NIC
174  @param netmsg
175  */
176  void send_to_nic(network_message* netmsg);
177 
178  protected:
179  node();
180 
181  void connect_nic();
182 
183  protected:
185 
187 
189 
191 
193 
195 
196  int ncores_;
197 
198  int nsocket_;
199 
200  private:
201  void build_launchers(sprockit::sim_parameters* params);
202 
203  private:
204  std::list<sw::launch_event*> launchers_;
206 
207 #if !SSTMAC_INTEGRATED_SST_CORE
208  public:
209  void launch(timestamp start, sw::launch_event* msg);
210 #else
211  void launch();
212 #endif
213 
214 };
215 
217 
218 }
219 } // end of namespace sstmac
220 
221 #endif
222 
processor * proc_
Definition: node.h:192
memory_model * mem() const
Definition: node.h:97
virtual void execute(ami::COMP_FUNC func, event *data, callback *cb)=0
Make the node execute a particular compute function.
unique_event_id next_outgoing_id_
Definition: node.h:205
SERVICE_FUNC
Functions that do not block and should return asynchronously.
Definition: ami.h:45
COMP_FUNC
Functions that block and must complete before returning.
Definition: ami.h:38
void send_to_nic(network_message *netmsg)
Push a network message (operation at the MTL layer) onto the NIC.
void build_launchers(sprockit::sim_parameters *params)
DeclareFactory(node)
sw::operating_system * os_
Definition: node.h:186
Base type for implementations of an engine that is able to schedule events and advance simulation tim...
Definition: event_manager.h:47
void fail_stop()
Cause the node to crash.
unique_event_id allocate_unique_id()
Choose a unique (64-bit) integer ID for a message.
Definition: node.h:142
node_id my_addr_
Definition: node.h:188
int nsocket_
Definition: node.h:198
void set_nic(nic *n)
Initializer used in stand-alone core.
Definition: node.h:84
virtual void init_factory_params(sprockit::sim_parameters *params)
Standard factory type initializer.
node_id addr() const
Definition: node.h:127
std::list< sw::launch_event * > launchers_
Definition: node.h:204
memory_model * mem_model_
Definition: node.h:190
A basic container for time (subject to future transplant).
Definition: timestamp.h:29
parallel_runtime * init()
SUMI = Simulator unified messagine interface It is also the name for a solid ink in Japanese - i...
DeclareDebugSlot(node)
virtual std::string to_string() const
nic * nic_
Definition: node.h:194
virtual void set_event_manager(event_manager *man)
Set the eventmanager for this scheduler.
A networkinterface is a delegate between a node and a server module.
Definition: nic.h:45
virtual void handle(event *ev)
sw::app_launch * env_
Definition: node.h:184
endpoint_id node_id
Definition: node_address.h:20
virtual void finalize_init()
Standard factory type initializer.
An interface for processor models.
Definition: processor.h:32
void connect(int src_outport, int dst_inport, connection_type_t ty, connectable *mod, config *cfg)
connect
nic * get_nic() const
Definition: node.h:105
void launch(timestamp start, sw::launch_event *msg)
sw::operating_system * os() const
Definition: node.h:113