SST/macro
parallel_runtime.h
Go to the documentation of this file.
1 #ifndef PARALLEL_RUNTIME_H
2 #define PARALLEL_RUNTIME_H
3 
4 
15 
16 DeclareDebugSlot(parallel);
17 
18 namespace sstmac {
19 
22  public lockable
23 {
24  public:
25  virtual ~parallel_runtime();
26 
27  struct incoming_msg {
29  void* buffer;
30  };
31 
32  static const int global_root;
33 
34  virtual void
35  init_factory_params(sprockit::sim_parameters* params);
36 
37  virtual void
38  finalize_init();
39 
40  virtual int64_t
41  allreduce_min(int64_t mintime) = 0;
42 
43  virtual int64_t
44  allreduce_max(int64_t maxtime) = 0;
45 
46  virtual void
47  global_sum(long* data, int nelems, int root) = 0;
48 
49  virtual void
50  global_sum(long long* data, int nelems, int root) = 0;
51 
52  virtual void
53  global_max(int* data, int nelems, int root) = 0;
54 
55  virtual void
56  global_max(long* data, int nelems, int root) = 0;
57 
58  virtual void
59  send(int dst, void* buffer, int buffer_size) = 0;
60 
61  virtual void
62  gather(void* send_buffer, int num_bytes, void* recv_buffer, int root) = 0;
63 
64  virtual void
65  allgather(void* send_buffer, int num_bytes, void* recv_buffer) = 0;
66 
67  virtual void
68  recv(int src, void* buffer, int buffer_size) = 0;
69 
70  int
71  global_max(int my_elem){
72  int dummy = my_elem;
73  global_max(&dummy, 1, global_root);
74  return dummy;
75  }
76 
77  long
78  global_max(long my_elem){
79  long dummy = my_elem;
80  global_max(&dummy, 1, global_root);
81  return dummy;
82  }
83 
84  virtual void
85  bcast(void* buffer, int bytes, int root) = 0;
86 
87  void
88  bcast_string(std::string& str, int root);
89 
90  std::istream*
91  bcast_file_stream(const std::string& fname);
92 
93  virtual void
94  finalize() = 0;
95 
96  virtual void
97  init_runtime_params(sprockit::sim_parameters* params);
98 
99  virtual void
100  init_partition_params(sprockit::sim_parameters* params);
101 
102  /**
103  @param pool A buffer cache corresponding to a pool of free buffers
104  @param incoming A buffer cache holding buffers that correspond to incoming messages
105  */
106  virtual void
107  send_recv_messages(std::vector<void*>& incoming);
108 
109  /**
110  * @param The topology id to send a remote message to
111  * @param buffer The buffer containing a serialized message
112  * @param size The size of the buffer being sent
113  */
114  virtual void
115  send_event(int thread_id,
116  timestamp t,
117  topology_id tid,
118  event_loc_id src,
119  uint32_t seqnum,
120  event* ev);
121 
122  int
123  me() const {
124  return me_;
125  }
126 
127  int
128  nproc() const {
129  return nproc_;
130  }
131 
132  int
133  nthread() const {
134  return nthread_;
135  }
136 
137  int
138  ser_buf_size() const {
139  return buf_size_;
140  }
141 
142  partition*
143  topology_partition() const;
144 
145  virtual void
146  wait_merge_array(int tag) = 0;
147 
148  virtual void
149  declare_merge_array(void* buffer, int size, int tag) = 0;
150 
151  virtual bool
152  release_merge_array(int tag) = 0;
153 
154  void
155  free_recv_buffers(const std::vector<void*>& buffers);
156 
157  protected:
159 
160  virtual void
161  do_send_message(int lp, void* buffer, int size) = 0;
162 
163  virtual void
164  do_send_recv_messages(std::vector<void*>& buffers) = 0;
165 
166  protected:
167  int nproc_;
168  int nthread_;
169  int me_;
170  std::vector<message_buffer_cache> send_buffer_pools_;
172  typedef std::pair<int, void*> send_buf_t;
173  std::vector<std::vector<void*> > send_buffers_;
176 
177 };
178 
180 
181 }
182 
183 #endif // PARALLEL_RUNTIME_H
virtual void wait_merge_array(int tag)=0
void free_recv_buffers(const std::vector< void * > &buffers)
int32_t topology_id
Definition: node_address.h:22
int global_max(int my_elem)
virtual int64_t allreduce_max(int64_t maxtime)=0
DeclareDebugSlot(parallel)
int thread_id
Definition: thread_id.h:21
virtual bool release_merge_array(int tag)=0
std::pair< int, void * > send_buf_t
virtual void finalize()=0
virtual void do_send_recv_messages(std::vector< void * > &buffers)=0
message_buffer_cache recv_buffer_pool_
virtual void finalize_init()
virtual void allgather(void *send_buffer, int num_bytes, void *recv_buffer)=0
virtual void recv(int src, void *buffer, int buffer_size)=0
std::vector< message_buffer_cache > send_buffer_pools_
virtual void send_recv_messages(std::vector< void * > &incoming)
A basic container for time (subject to future transplant).
Definition: timestamp.h:29
virtual void init_partition_params(sprockit::sim_parameters *params)
virtual int64_t allreduce_min(int64_t mintime)=0
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...
std::istream * bcast_file_stream(const std::string &fname)
void bcast_string(std::string &str, int root)
virtual void gather(void *send_buffer, int num_bytes, void *recv_buffer, int root)=0
virtual void init_factory_params(sprockit::sim_parameters *params)
long global_max(long my_elem)
static const int global_root
virtual void global_max(int *data, int nelems, int root)=0
virtual void send(int dst, void *buffer, int buffer_size)=0
virtual void declare_merge_array(void *buffer, int size, int tag)=0
virtual void global_sum(long *data, int nelems, int root)=0
virtual void init_runtime_params(sprockit::sim_parameters *params)
partition * topology_partition() const
Class for storing all the partitions given to us by METIS.
Definition: sim_partition.h:35
virtual void bcast(void *buffer, int bytes, int root)=0
virtual void do_send_message(int lp, void *buffer, int size)=0
virtual void send_event(int thread_id, timestamp t, topology_id tid, event_loc_id src, uint32_t seqnum, event *ev)
DeclareFactory(parallel_runtime)
std::vector< std::vector< void * > > send_buffers_