Paramotopy
parallel parameter homotopy through bertini
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
step2.cpp
Go to the documentation of this file.
1 #include "step2.hpp"
2 
3 
4 
5 
6 int main(int argc, char* argv[]){
7 
8  timer process_timer; // initializes the t_start value in the timer, and a map of zeros for the other timers.
9  //do this straight away for total time.
10 
11  srand(time(NULL));
12 
13 
14  int steptwomode;
15  int myid;
16  int numprocs;
17  int namelen;
18  char processor_name[MPI_MAX_PROCESSOR_NAME];
19  int headnode=0;
20 
21  std::ifstream fin;
22 
23  std::string sharedmemorylocation;
24 
25 
26  std::string proc_name_str;
27  MPI_Init(&argc,&argv);
28  MPI_Comm_size(MPI_COMM_WORLD,&numprocs);
29  MPI_Comm_rank(MPI_COMM_WORLD,&myid);
30  MPI_Get_processor_name(processor_name,&namelen);
31  proc_name_str = processor_name;
32 
33 
34 
35  boost::filesystem::path called_dir = boost::filesystem::current_path();
36  boost::filesystem::path homedir = getenv("HOME");
37 
38 
39  boost::filesystem::path filename, location;
40 
41 
42 
43  std::vector<std::vector<std::pair<double,double> > > AllParams;
44  std::vector<std::string> ParamNames;
45  std::stringstream commandss; //we put info on and off this stringstream, to get from strings to numbers.
46 
47 
48 
50  //
51  // should be done getting info from commandstring (argv):
52  //
53  // filename
54  // location
55  // steptwomode
56  //
58 
59  if ( (argc!=1) && (numprocs>1)){
60  std::string progname;
61  progname = argv[0];
62  filename = argv[1];
63  location = argv[2];
64  commandss << argv[3]; // convert this number
65  commandss >> steptwomode;
66  commandss.clear(); commandss.str("");
67  }
68  else{
69  // didn't provide filename or any arguments ...
70  std::cerr << "Nothing passed as an argument ... \n"
71  << "this should never pop up as this program is only "
72  << " called from paramotopy...\n";
73  MPI_Finalize();
74  return 1;
75  }
76 
77 
78 
79 
80 
81 
82 
83 
84  runinfo paramotopy_info; //holds all the info for the run
85 
86 #ifdef timingstep2
87  process_timer.press_start("read");
88 #endif
89  paramotopy_info.GetInputFileName(filename); //dear god please don't fail to find the file.
90  paramotopy_info.ParseData(location);
91 #ifdef timingstep2
92  process_timer.add_time("read");
93 #endif
94  paramotopy_info.location = location; // essentially from the command line
95  paramotopy_info.steptwomode = steptwomode;
96 
97 
98 
99 
100 
101  //instantiate the settings
102  boost::filesystem::path settingsfilename = location;
103  settingsfilename /= "prefs.xml";
104  if (!boost::filesystem::exists(settingsfilename)) {
105  std::cerr << "for some reason the prefs file " << settingsfilename << " does not exist! id:" << myid << std::endl;
106  exit(-219);
107  }
108  ProgSettings paramotopy_settings(settingsfilename);
109 #ifdef timingstep2
110  process_timer.press_start("read");
111 #endif
112  paramotopy_settings.load(); // parse the settings xml file
113 #ifdef timingstep2
114  process_timer.add_time("read");
115 #endif
116 
117 
118 
119  //get random values from file in base_dir. probably destroyed during parsing process. gotta do this after parsing.
120 #ifdef timingstep2
121  process_timer.press_start("read");
122 #endif
123  paramotopy_info.GetRandomValues();
124 #ifdef timingstep2
125  process_timer.add_time("read");
126 #endif
127 
128 
129 
130 
131 
132 
133 
134 
135 
136 
137 
138 
139 
140  boost::filesystem::path base_dir = make_base_dir_name(boost::filesystem::path(filename)); //
141 
142 
143 
144 
145 
146  boost::filesystem::path timingfolder = location;
147  timingfolder /= "timing";
148 #ifdef timingstep2
149  if (myid==0) {
150  if (boost::filesystem::exists(timingfolder)){
151  boost::filesystem::remove_all(timingfolder);
152  }
153  boost::filesystem::create_directories(timingfolder);
154  }
155 #endif
156 
157 
158 
159 
160 
161 
162 
163 
164 
165  //the main body of the program is here:
166  if (myid==headnode){
167  master_process master;
168  master.master_main(paramotopy_settings, paramotopy_info, process_timer);
169  }
170  else{
171  slave_process slave;
172  slave.slave_main(paramotopy_settings, paramotopy_info, process_timer);
173  }
174 
175 
176 
177 
178 
179 #ifdef timingstep2
180  process_timer.write_timing_data(timingfolder,myid);
181 #endif
182 
183 
184 
185 
186  MPI_Finalize();//wrap it up
187 
188 
189 
190 
191  return 0;
192 
193 }//re: main
194 
195 
196 
197 
198 
199 
200 
201 
202 
203 
204 
205 
206 
207 
int steptwomode
Definition: runinfo.hpp:95
int main(int argc, char *argv[])
Definition: step2.cpp:6
void slave_main(ProgSettings input_settings, runinfo input_p_info, timer &process_timer)
Definition: slave.cpp:16
void ParseData()
Definition: runinfo.cpp:636
void load(boost::filesystem::path pFilename)
boost::filesystem::path make_base_dir_name(boost::filesystem::path filename)
void master_main(ProgSettings input_settings, runinfo input_p_info, timer &process_timer)
Definition: master.cpp:9
boost::filesystem::path location
Definition: runinfo.hpp:71
void add_time(const std::string timer_name)
Definition: timing.cpp:12
A class that stores the general program settings of Paramotopy.
void GetInputFileName()
Definition: runinfo.cpp:299
void GetRandomValues()
Definition: runinfo.cpp:812
A class for the input file parser.
Definition: runinfo.hpp:41
bool write_timing_data(const boost::filesystem::path folder_to_write_to, const int myid)
Definition: timing.cpp:57
master process for basic searches and brute-force runs.
Definition: master.hpp:41
slave process for basic searches and brute-force runs.
Definition: slave.hpp:47
void press_start(const std::string timer_name)
Definition: timing.cpp:5
Capable of timing arbitrary categories of processes, using a map of timer_data's. ...
Definition: timing.hpp:71