SST/macro
sim_partition.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-2010 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_SIM_PARTITION_H_INCLUDED
13 #define SSTMAC_BACKENDS_NATIVE_SIM_PARTITION_H_INCLUDED
14 
15 #include <sprockit/debug.h>
18 
22 
23 #include <vector>
24 
25 DeclareDebugSlot(partition);
26 
27 namespace sstmac {
28 
29 /**
30  * Class for storing all the partitions given to us by METIS.
31  * The inherited boost map stores individial partitions, while
32  * the parent_map_ member variable stores a flat map of switch to
33  * partition.
34  */
35 class partition :
37 {
38 
39  public:
40  virtual std::string
41  to_string() const {
42  return "partition";
43  }
44 
45  virtual ~partition();
46 
48  subset(int lpid) const {
49  if(lpid >= subsets_.size()) {
51  "partition::get_partition: invalid lpid %d requested for parallel run",
52  lpid);
53  }
54  return subsets_[lpid];
55  }
56 
57  int*
59  return num_switches_per_lp_;
60  }
61 
62  int
63  local_switch(int idx) const {
64  return local_switches_[idx];
65  }
66 
67  int*
69  return local_switches_;
70  }
71 
72  int*
74  return switch_to_lpid_;
75  }
76 
77  int
79  return num_switches_total_;
80  }
81 
82  int
84  return local_num_switches_;
85  }
86 
87  int
89 #if SSTMAC_SANITY_CHECK
90  if (switch_id >= num_switches_total_){
92  "partition::lpid_for_switch: invalid switch %d",
93  switch_id);
94  }
95 #endif
96  return switch_to_lpid_[switch_id];
97  }
98 
99  virtual int
100  thread_for_local_switch(int local_idx) const;
101 
102  protected:
104 
105  void init_local_switches();
106 
107  protected:
109 
111 
113 
115 
117 
119 
120  int nthread_;
121 
122  int nproc_;
123 
124  int me_;
125 
127 
128  std::vector<hw::index_subset*> subsets_;
129 
130 
131 };
132 
134 
136  public partition
137 {
138  public:
140 
141  virtual ~serial_partition();
142 
143  virtual void
144  init_factory_params(sprockit::sim_parameters* params);
145 
146  virtual void
147  finalize_init();
148 
149 };
150 
151 
153  public partition
154 {
155  public:
157 
158  virtual ~metis_partition();
159 
160  virtual void
161  init_factory_params(sprockit::sim_parameters* params);
162 
163  virtual void
164  finalize_init();
165 
166  protected:
167  void
168  read_partition(const std::string &partfilename, int nproc);
169 
170  protected:
171  hw::interconnect* fake_ic_;
172 
173 };
174 
176  public partition
177 {
178  public:
180 
181  virtual ~topology_partition();
182 
183  virtual void
184  init_factory_params(sprockit::sim_parameters* params);
185 
186  virtual void
187  finalize_init();
188 
189  virtual int
190  thread_for_local_switch(int local_idx) const {
191  return local_switch_to_thread_[local_idx];
192  }
193 
194  protected:
195  hw::topology* fake_top_;
196 
198 
200 
201 };
202 
204  public partition
205 {
206  public:
208 
209  virtual ~block_partition();
210 
211  virtual void
212  init_factory_params(sprockit::sim_parameters* params);
213 
214  virtual void
215  finalize_init();
216 
217  virtual void
218  partition_switches();
219 
220  protected:
221  hw::topology* fake_top_;
222 
223 };
224 
226  public block_partition
227 {
228  public:
230 
231  virtual ~occupied_block_partition();
232 
233  virtual void
234  init_factory_params(sprockit::sim_parameters* params);
235 
236  virtual void
237  partition_switches();
238 
239  virtual void
240  finalize_init();
241 
242  int
243  thread_for_local_switch(int local_idx) const;
244 
245  protected:
254 
255 };
256 
257 }
258 
259 #endif
260 
int * local_switches()
Definition: sim_partition.h:68
hw::index_subset * subset(int lpid) const
Definition: sim_partition.h:48
int * switch_to_lpid()
Definition: sim_partition.h:73
virtual int thread_for_local_switch(int local_idx) const
serial_partition(parallel_runtime *rt)
virtual int thread_for_local_switch(int local_idx) const
hw::topology * fake_top_
parallel_runtime * rt_
DeclareFactory1InitParam(partition, parallel_runtime *)
metis_partition(parallel_runtime *rt)
virtual std::string to_string() const
Definition: sim_partition.h:41
int local_num_switches() const
Definition: sim_partition.h:83
virtual void finalize_init()
Definition: factory.h:34
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...
int * num_switches_per_lp()
Definition: sim_partition.h:58
int local_switch(int idx) const
Definition: sim_partition.h:63
partition(parallel_runtime *rt)
virtual void init_factory_params(sim_parameters *params)
Definition: factory.h:30
occupied_block_partition(parallel_runtime *rt)
void init_local_switches()
int num_switches_total() const
Definition: sim_partition.h:78
#define spkt_throw_printf(exc, template_str,...)
Definition: errors.h:37
hw::interconnect * fake_ic_
int lpid_for_switch(int switch_id) const
Definition: sim_partition.h:88
virtual ~partition()
block_partition(parallel_runtime *rt)
topology_partition(parallel_runtime *rt)
DeclareDebugSlot(partition)
Class for storing all the partitions given to us by METIS.
Definition: sim_partition.h:35
std::vector< hw::index_subset * > subsets_
Error indicating some internal value was unexpected.
Definition: errors.h:83