Paramotopy
parallel parameter homotopy through bertini
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
master.hpp
Go to the documentation of this file.
1 #include <mpi.h>
2 #include <sys/wait.h>
3 #include <sys/stat.h>
4 #include <sys/types.h>
5 #include <vector>
6 #include <map>
7 #include <iostream>
8 #include <string>
9 #include <sstream>
10 #include <fstream>
11 #include <stdio.h>
12 #include <stdlib.h>
13 #include <iomanip>
14 
15 
16 #ifndef __MASTER_H__
17 #define __MASTER_H__
18 
19 #include "step1_funcs.hpp"
20 #include "step2_funcs.hpp"
21 #include "mtrand.hpp"
22 #include "random.hpp"
23 
24 #include "para_aux_funcs.hpp"
25 #include "step2readandwrite.hpp"
26 #include "runinfo.hpp"
27 #include "timing.hpp"
28 
29 
30 
31 
32 
42 
43 public:
44 
45 // master_process(communicator){
46 //
47 // /* Find out how many processes there are in the default
48 // communicator */
49 // MPI_Comm_size(MPI_COMM_WORLD, &this->numprocs);
50 //
51 // MPI_Comm_rank(MPI_COMM_WORLD,&this->myid);
52 //
53 //
54 // this->called_dir = stackoverflow_getcwd();
55 // this->homedir = getenv("HOME");
56 //
57 // this->num_active_workers = 0;
58 // }
59 
61 
62  /* Find out how many processes there are in the default
63  communicator */
64  MPI_Comm_size(MPI_COMM_WORLD, &this->numprocs);
65 
66  MPI_Comm_rank(MPI_COMM_WORLD,&this->myid);
67 
68 
70  this->homedir = getenv("HOME");
71 
72  this->num_active_workers = 0;
73  }
74 
75 
85  void master_main(ProgSettings input_settings,
86  runinfo input_p_info,
87  timer & process_timer);
88 
89 
90 
91 
92 
93 
94 private:
95 
98 
99  std::vector< int > lastnumsent;
100 
101  int numprocs;
102 
103  int myid;
104 
105  int numparam;
106 
107  boost::filesystem::path filename;
108 
110 
113 
116 
117 
118  boost::filesystem::path lastoutfilename;
119  boost::filesystem::path tmpfolder;
120  boost::filesystem::path called_dir;
121  boost::filesystem::path homedir;
122 
123  std::ofstream mc_out_stream;
124  std::ifstream mc_in_stream;
125 
126  std::vector< int > index_conversion_vector;// for the index making function
127 
128 
129  std::map< int, bool> active_workers;
131 
132 
133 
141  void MasterSetup();
142 
143 
144 
152  //
153 
154 
160  void SeedSwitch(timer & process_timer);
161 
162 
168  void SeedBasic(timer & process_timer);
169 
176  void SeedSearch(timer & process_timer);
177 
178 
179 
180 
181 
182 
183 
184 
192  //
193 
194 
200  void LoopSwitch(timer & process_timer);
201 
202 
208  void LoopBasic(timer & process_timer);
209 
215  void LoopSearch(timer & process_timer);
216 
217 
218 
219 
220 
228  //
229 
230 
231 
237  void CleanupSwitch(timer & process_timer);
238 
239 
245  void CleanupBasic(timer & process_timer);
246 
247 
254  void CleanupSearch(timer & process_timer);
255 
256 
257 
258 
259 
260 
268  //
269 
275  void SendInput(timer & process_timer);
276 
282  void SendStart(timer & process_timer);
283 
284 
285 
286 
287 
288 
289 
290 
298  //
299 
300 
301 
309  void NextRandomValue(int pointcounter, // localcounter tells which indices in tempsends
310  double tempsends[]);
311 
312 
313 
314 
324  void FormNextValues(int pointcounter,
325  std::vector< std::vector< std::pair<double,double> > > Values,
326  double tempsends[]);
327 
333  void FormNextValues_mc(int pointcounter,
334  double tempsends[]);
335 
336 
337 
342  void GetTerminationInt();
343 
347  void OpenMC();
348 
349 
354  void SetTmpFolder();
355 
360  void SetUpFolders();
361 
365  void TerminateInactiveWorker(int worker_id,
366  timer & process_timer);
367 
368 
372  void TerminateActiveWorker(int worker_id,
373  timer & process_timer);
374 
378  void ReadyCheck();
379 };
380 
381 
382 
383 
384 
385 
386 
387 
388 
389 #endif
void NextRandomValue(int pointcounter, double tempsends[])
Definition: master.cpp:102
void SeedSwitch(timer &process_timer)
Definition: master.cpp:208
std::vector< int > index_conversion_vector
Definition: master.hpp:126
void GetTerminationInt()
Definition: master.cpp:1097
void LoopBasic(timer &process_timer)
Definition: master.cpp:479
int numprocs
number of processors in the communicator
Definition: master.hpp:101
std::map< int, bool > active_workers
map for tracking the active workers.
Definition: master.hpp:129
void SetTmpFolder()
Definition: master.cpp:1173
void ReadyCheck()
Definition: master.cpp:1292
void LoopSwitch(timer &process_timer)
Definition: master.cpp:457
void TerminateInactiveWorker(int worker_id, timer &process_timer)
Definition: master.cpp:1233
void FormNextValues_mc(int pointcounter, double tempsends[])
Definition: master.cpp:165
void SendStart(timer &process_timer)
Definition: master.cpp:950
void CleanupBasic(timer &process_timer)
Definition: master.cpp:849
void MasterSetup()
Definition: master.cpp:67
std::ofstream mc_out_stream
parameter point out file
Definition: master.hpp:123
void CleanupSwitch(timer &process_timer)
Definition: master.cpp:818
runinfo paramotopy_info
the parsed paramotopy input file.
Definition: master.hpp:96
void SetUpFolders()
Definition: master.cpp:1197
boost::filesystem::path lastoutfilename
name of the progress file
Definition: master.hpp:118
void CleanupSearch(timer &process_timer)
Definition: master.cpp:933
void TerminateActiveWorker(int worker_id, timer &process_timer)
Definition: master.cpp:1261
void SeedSearch(timer &process_timer)
Definition: master.cpp:336
ProgSettings paramotopy_settings
the ProgSettings for this process
Definition: master.hpp:97
int myid
my MPI id relative to communicator
Definition: master.hpp:103
void OpenMC()
Definition: master.cpp:1131
void LoopSearch(timer &process_timer)
Definition: master.cpp:637
boost::filesystem::path filename
filename for problem
Definition: master.hpp:107
boost::filesystem::path tmpfolder
where the temp files at?
Definition: master.hpp:119
boost::filesystem::path called_dir
where was I when I was instantiated?
Definition: master.hpp:120
int numfilesatatime
current number of files passed out at each distribution
Definition: master.hpp:111
std::ifstream mc_in_stream
parameter point in file
Definition: master.hpp:124
int numparam
number of parameters in problem
Definition: master.hpp:105
void master_main(ProgSettings input_settings, runinfo input_p_info, timer &process_timer)
Definition: master.cpp:9
void SeedBasic(timer &process_timer)
Definition: master.cpp:233
int standardstep2
switch for total degree vs. coeff. homotopy
Definition: master.hpp:109
int numfilesatatime_orig
given number of files passed out at each distribution
Definition: master.hpp:112
int num_active_workers
parity checker
Definition: master.hpp:130
int current_absolute_index
the current absolute index.
Definition: master.hpp:115
boost::filesystem::path homedir
where is /Users/ofloveandhate?
Definition: master.hpp:121
A class that stores the general program settings of Paramotopy.
A class for the input file parser.
Definition: runinfo.hpp:41
void SendInput(timer &process_timer)
Definition: master.cpp:1013
int terminationint
maximum absolute_current_index value before loop breaks.
Definition: master.hpp:114
master process for basic searches and brute-force runs.
Definition: master.hpp:41
std::string stackoverflow_getcwd()
Capable of timing arbitrary categories of processes, using a map of timer_data's. ...
Definition: timing.hpp:71
std::vector< int > lastnumsent
progress tracker
Definition: master.hpp:99
void FormNextValues(int pointcounter, std::vector< std::vector< std::pair< double, double > > > Values, double tempsends[])
Definition: master.cpp:131