Paramotopy
parallel parameter homotopy through bertini
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
slave.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 
14 
15 
16 #ifndef __SLAVE_H_INCLUDED__
17 #define __SLAVE_H_INCLUDED__
18 
19 
20 #include "step1_funcs.hpp"
21 #include "step2_funcs.hpp"
22 #include "mtrand.hpp"
23 #include "random.hpp"
24 #include "step2readandwrite.hpp"
25 #include "timing.hpp"
26 #include "datagatherer.hpp"
27 
28 
29 // you must include gmp pour include polysolve.
30 #include <gmp.h>
31 
32 extern "C" {
33 #include "bertini.h"
34 }
35 
36 
37 
48 
49 
50 public:
51 
52 
62  this->have_dotout = false;
63  this->have_input = false;
64  this->have_start = false;
65 
66  this->in_working_folder = false;
67  /* Find out how many processes there are in the default
68  communicator */
69  MPI_Comm_size(MPI_COMM_WORLD, &this->numprocs);
70 
71  MPI_Comm_rank(MPI_COMM_WORLD,&this->myid);
72 
73 
75  this->homedir = getenv("HOME");
76 
77  this->filename = "";
78  this->numfilesatatime = -1;
79 
80  this->tmpfolder = "";
81 
82  this->numparam = -1;
83  this->standardstep2 = -1;
84 
85  };
86 
87  void slave_main(ProgSettings input_settings,
97  runinfo input_p_info,
98  timer & process_timer);
99 
100 
101 
102 private:
103 
106 
107 
108  boost::filesystem::path filename;
111  boost::filesystem::path called_dir;
112  boost::filesystem::path homedir;
113 
114  boost::filesystem::path workingfolder;
115 
116  boost::filesystem::path tmpfolder;
117 
118 
119 
121 
122  unsigned int currentSeed;
123  int MPType;
124 
125 
127 
128  int numparam;
129 
130 
131  int numprocs;
132 
133 
134  int myid;
135 
137 
138 
139  std::vector<std::string> numdotout;
140  std::vector<std::string> arrdotout;
141  std::vector<std::string> degdotout;
142  std::vector<std::string> namesdotout;
143  std::vector<std::string> config;
144  std::vector<std::string> funcinput;
145  std::vector<std::string> preproc_data;
146 
147 
148  bool have_dotout;
149  bool have_input;
150  char* input_file;
151 
152  bool have_start;
153  char* start_file;
154 
155 
157 
158 
159 
160 
161 
169  void SlaveSetup();
170 
171 
172 
173 
174 
182  //
183 
184 
190  void SeedSwitch(timer & process_timer);
191 
192 
198  void SeedBasic(timer & process_timer);
199 
200 
207  void SeedSearch(timer & process_timer);
208 
209 
210 
211 
212 
213 
214 
215 
223  //
224 
225 
226 
227 
233  void LoopSwitch(timer & process_timer);
234 
235 
241  void LoopBasic(timer & process_timer);
242 
243 
249  void LoopSearch(timer & process_timer);
250 
251 
252 
253 
254 
262  //
263 
264 
265 
271  void CleanupSwitch(timer & process_timer);
272 
273 
279  void CleanupBasic(timer & process_timer);
280 
281 
288  void CleanupSearch(timer & process_timer);
289 
290 
291 
292 
293 
294 
302  //
308  void ReceiveInput(timer & process_timer);
309 
315  void ReceiveStart(timer & process_timer);
316 
317 
321  void WriteStart();
322 
326  void WriteInput();
327 
331  void ReadDotOut();
332 
336  void WriteDotOut();
337 
338 
342  void WriteNumDotOut(double current_params[]);
343 
344 
348  void SetWorkingFolder();
349 
350 
354  void PurgeWorkingFolder();
355 
359  void MoveToWorkingFolder();
360 
364  void GoCalledDir();
365 
366 
370  void ReadyCheck();
371 
372 
373 };
374 
375 
376 
377 
378 
379 
380 
381 
382 #endif
int numfilesatatime_orig
the expected number of files per send
Definition: slave.hpp:110
int numprocs
the number of processors in my MPI communicator.
Definition: slave.hpp:131
char * input_file
the input file in a c-friendly format
Definition: slave.hpp:150
std::vector< std::string > numdotout
num.out file.
Definition: slave.hpp:139
unsigned int currentSeed
the current seed for random number generator.
Definition: slave.hpp:122
void LoopBasic(timer &process_timer)
Definition: slave.cpp:132
std::vector< std::string > config
config file.
Definition: slave.hpp:143
void PurgeWorkingFolder()
Definition: slave.cpp:931
void WriteStart()
Definition: slave.cpp:584
void CleanupSwitch(timer &process_timer)
Definition: slave.cpp:466
std::vector< std::string > funcinput
func_input file.
Definition: slave.hpp:144
void SeedSwitch(timer &process_timer)
Definition: slave.cpp:78
void MoveToWorkingFolder()
Definition: slave.cpp:937
void slave_main(ProgSettings input_settings, runinfo input_p_info, timer &process_timer)
Definition: slave.cpp:16
boost::filesystem::path called_dir
where was I instantiated?
Definition: slave.hpp:111
bool have_dotout
flag indicating whether we have read the .out files into memory.
Definition: slave.hpp:148
void LoopSearch(timer &process_timer)
Definition: slave.cpp:276
std::vector< std::string > degdotout
degout file.
Definition: slave.hpp:141
void ReceiveInput(timer &process_timer)
Definition: slave.cpp:504
void CleanupBasic(timer &process_timer)
Definition: slave.cpp:478
char * start_file
the start file in a c-friendly format
Definition: slave.hpp:153
boost::filesystem::path workingfolder
where should I go to perform work?
Definition: slave.hpp:114
void CleanupSearch(timer &process_timer)
Definition: slave.cpp:483
runinfo paramotopy_info
the parsed paramotopy input file.
Definition: slave.hpp:104
void SeedSearch(timer &process_timer)
Definition: slave.cpp:90
slave_process()
Definition: slave.hpp:61
void LoopSwitch(timer &process_timer)
Definition: slave.cpp:113
void ReadDotOut()
Definition: slave.cpp:639
void SetWorkingFolder()
Definition: slave.cpp:900
bool in_working_folder
boolean indicating whether i think i am in the correct location to perform work.
Definition: slave.hpp:156
void ReadyCheck()
Definition: slave.cpp:954
std::vector< std::string > preproc_data
preproc_data file.
Definition: slave.hpp:145
int linenumber
what line is currently being run
Definition: slave.hpp:126
void SlaveSetup()
Definition: slave.cpp:55
void ReceiveStart(timer &process_timer)
Definition: slave.cpp:534
std::vector< std::string > namesdotout
names.out file.
Definition: slave.hpp:142
boost::filesystem::path filename
the filename for the problem
Definition: slave.hpp:108
Class for gathering data, from failed path analysis, and from completed runs.
int numparam
the number of parameters in the problem.
Definition: slave.hpp:128
boost::filesystem::path homedir
where is /Users/ofloveandhate?
Definition: slave.hpp:112
int myid
my id withing my MPI communicator
Definition: slave.hpp:134
std::vector< std::string > arrdotout
arr.out file.
Definition: slave.hpp:140
boost::filesystem::path tmpfolder
the basis for workingfolder
Definition: slave.hpp:116
void WriteDotOut()
Definition: slave.cpp:726
A class that stores the general program settings of Paramotopy.
ProgSettings paramotopy_settings
the ProgSettings for this process
Definition: slave.hpp:105
int MPType
MPType for current run.
Definition: slave.hpp:123
datagatherer slavegatherer
data member from datagatherer, which will gather bertini output files.
Definition: slave.hpp:120
void WriteInput()
Definition: slave.cpp:609
A class for the input file parser.
Definition: runinfo.hpp:41
void WriteNumDotOut(double current_params[])
Definition: slave.cpp:772
bool have_input
flag indicating whether we have received the INPUT file from master.
Definition: slave.hpp:149
int standardstep2
flag for total degree or coefficient parameter homotopy.
Definition: slave.hpp:136
int numfilesatatime
the expected number of files per send
Definition: slave.hpp:109
void SeedBasic(timer &process_timer)
Definition: slave.cpp:83
bool have_start
flag indicating whether we have received the START file from master.
Definition: slave.hpp:152
slave process for basic searches and brute-force runs.
Definition: slave.hpp:47
std::string stackoverflow_getcwd()
Capable of timing arbitrary categories of processes, using a map of timer_data's. ...
Definition: timing.hpp:71
void GoCalledDir()
Definition: slave.cpp:947