11 timer & process_timer)
109 double rand_real = drand(), rand_imag = drand();
120 tempsends[pointcounter*(2*numparam+1)+2*ii] = rand_real;
121 tempsends[pointcounter*(2*numparam+1)+2*ii+1] = rand_imag;
132 std::vector< std::vector< std::pair<double,double> > > Values,
136 std::vector< int > indexvector;
143 for (
int jj=
numparam-1; jj>-1; --jj) {
152 tempsends[pointcounter*(2*numparam+1)+2*jj] = Values[jj][ indexvector[jj] ].first;
153 tempsends[pointcounter*(2*numparam+1)+2*jj+1] = Values[jj][ indexvector[jj] ].second;
171 std::vector< std::pair<double, double> > CValues;
172 std::stringstream ss;
175 for (
int jj = 0; jj <
numparam;++jj){
176 ss >> tempsends[pointcounter*(2*numparam+1)+2*jj];
177 ss >> tempsends[pointcounter*(2*numparam+1)+2*jj+1];
224 std::cerr <<
"invalid main_mode setting" << std::endl;
225 MPI_Abort(MPI_COMM_WORLD, 54);
247 for (
int proc_count=1;proc_count<(
numprocs);++proc_count){
255 for (
int ii = 0; ii <numtodo; ++ii){
273 <<
" " << tempsends[2*jj+1] <<
" ";
307 MPI_Send(&tempsends[0],
351 std::cerr <<
"invalid userdefined mode inside search mode" << std::endl;
352 MPI_Abort(MPI_COMM_WORLD,438);
361 double fractpart, intpart;
369 for (
int proc_count=1;proc_count<(
numprocs);++proc_count){
378 for (
int ii = 0; ii <numtodo; ++ii){
423 MPI_Send(&tempsends[0],
491 int lastlineprocessed = -1;
502 MPI_Recv(&lastlineprocessed,
546 for (
int ii = 0; ii < numtodo; ++ii){
566 #endif //write the mc line if not userdefined
588 MPI_Send(&tempsends[0],
603 std::stringstream tempss;
611 std::ofstream lastout;
614 lastout << tempss.str();
652 int num_solns_this_iteration = -1;
657 int num_found_solns = 0;
670 MPI_Recv(&num_solns_this_iteration,
681 num_found_solns += num_solns_this_iteration;
719 for (
int ii = 0; ii < numtodo; ++ii){
727 #endif //write the mc line if not userdefined
748 MPI_Send(&tempsends[0],
763 std::stringstream tempss;
771 std::ofstream lastout;
774 lastout << tempss.str();
836 int arbitraryinteger = 1;
837 MPI_Bcast(&arbitraryinteger, 1, MPI_INT, 0, MPI_COMM_WORLD);
840 boost::filesystem::path temppath(
tmpfolder);
841 boost::filesystem::remove_all(
tmpfolder);
855 int* receive_buffer =
new int[1];
860 std::cerr <<
"discrepancy in number of active workers" << std::endl;
861 MPI_Abort(MPI_COMM_WORLD, 778);
864 std::cout <<
"number of workers is correct at cleanup" << std::endl;
873 MPI_Recv(&receive_buffer[0],
887 std::map< int, bool>::iterator iter;
888 std::stringstream printme;
889 printme <<
"remaining active workers:\n";
891 printme <<
"worker" << iter->first <<
"\n";
893 printme << std::endl;
895 std::cout << printme.str();
916 finishedfile /=
"step2finished";
919 fout.open(finishedfile.c_str());
927 delete[] receive_buffer;
967 int start_length = start.size() + 1;
969 char *start_send =
new char[start_length];
970 for (
int ii = 0; ii < int(start.size()); ++ii){
971 start_send[ii] = start[ii];
973 start_send[start.size()] =
'\0';
982 for (
int ii = 1; ii <
numprocs; ++ii){
983 MPI_Send(&start_length, 1, MPI_INT, ii,
NUM_CHARACTERS, MPI_COMM_WORLD);
986 process_timer.
add_time(
"send",numprocs-1);
996 for (
int ii = 1; ii <
numprocs; ++ii){
997 MPI_Send(&start_send[0], start_length, MPI_CHAR, ii,
TEXT_FILE, MPI_COMM_WORLD);
1000 process_timer.
add_time(
"send",numprocs-1);
1004 delete[] start_send;
1023 std::string inputstring;
1046 std::cout <<
"the input file is:\n " << inputstring << std::endl;
1050 int input_length = inputstring.size() + 1;
1054 for (
int ii = 1; ii <
numprocs; ++ii){
1055 MPI_Send(&input_length, 1, MPI_INT, ii,
NUM_CHARACTERS, MPI_COMM_WORLD);
1058 process_timer.
add_time(
"send",numprocs-1);
1062 char *input_send =
new char[input_length];
1063 for (
int ii = 0; ii < int(inputstring.size()); ++ii){
1064 input_send[ii] = inputstring[ii];
1066 input_send[inputstring.size()] =
'\0';
1071 for (
int ii = 1; ii <
numprocs; ++ii){
1072 MPI_Send(&input_send[0], input_length, MPI_CHAR, ii,
TEXT_FILE, MPI_COMM_WORLD);
1075 process_timer.
add_time(
"send",numprocs-1);
1079 delete[] input_send;
1138 boost::filesystem::remove(mcfname);
1146 std::cerr <<
"failed to open the parameter value out file: " << mcfname << std::endl;
1161 std::cerr <<
"critical error: failed to open mc file to read parameter values. filename: " << mcfname << std::endl;
1177 std::stringstream templocation;
1201 DataCollectedbase_dir /=
"step2/DataCollected";
1202 boost::filesystem::create_directories(DataCollectedbase_dir);
1206 mydirfname /=
"folders";
1207 std::ofstream fout(mydirfname.c_str());
1208 if (!fout.is_open()){
1209 std::cerr <<
"failed to open " << mydirfname.string() <<
" to write folder names!\n";
1213 std::stringstream converter;
1216 boost::filesystem::path makeme = DataCollectedbase_dir;
1219 makeme += converter.str();
1223 fout << makeme.string() <<
"\n";
1224 boost::filesystem::create_directories(makeme);
1234 timer & process_timer)
1239 int arbitraryinteger = 0;
1244 MPI_Send(&arbitraryinteger,
1255 std::cerr <<
"terminating an active worker as an inactive!\n";
1256 MPI_Abort(MPI_COMM_WORLD,690);
1262 timer & process_timer)
1267 int arbitraryinteger = 0;
1272 MPI_Send(&arbitraryinteger,
1283 std::cerr <<
"terminating an INactive worker as active!\n";
1284 MPI_Abort(MPI_COMM_WORLD,691);
1295 bool its_all_good =
true;
1296 std::vector< std::string > reported_errors;
1300 reported_errors.push_back(
"unset numfilesatatime");
1301 its_all_good =
false;
1306 reported_errors.push_back(
"unset terminationint");
1307 its_all_good =
false;
1311 reported_errors.push_back(
"no tmpfolder");
1312 its_all_good =
false;
1317 std::cerr <<
"master " <<
myid <<
" reported its not all good, with bad flags:\n";
1319 for (
int ii=0; ii<int(reported_errors.size()); ii++) {
1320 std::cerr <<
"master flag" << ii <<
" " << reported_errors[ii] << std::endl;
1322 std::cerr <<
"\n\nABORTING master " << myid << std::endl;
1323 MPI_Abort(MPI_COMM_WORLD, 652);
void NextRandomValue(int pointcounter, double tempsends[])
void SeedSwitch(timer &process_timer)
std::vector< int > index_conversion_vector
void LoopBasic(timer &process_timer)
int numprocs
number of processors in the communicator
std::map< int, bool > active_workers
map for tracking the active workers.
void LoopSwitch(timer &process_timer)
std::vector< int > NumMeshPoints
void TerminateInactiveWorker(int worker_id, timer &process_timer)
void FormNextValues_mc(int pointcounter, double tempsends[])
void SendStart(timer &process_timer)
void CleanupBasic(timer &process_timer)
std::ofstream mc_out_stream
parameter point out file
void CleanupSwitch(timer &process_timer)
runinfo paramotopy_info
the parsed paramotopy input file.
int GetMcNumLines(boost::filesystem::path base_dir, int numparam)
boost::filesystem::path lastoutfilename
name of the progress file
void CleanupSearch(timer &process_timer)
void TerminateActiveWorker(int worker_id, timer &process_timer)
void SeedSearch(timer &process_timer)
ProgSettings paramotopy_settings
the ProgSettings for this process
int myid
my MPI id relative to communicator
void LoopSearch(timer &process_timer)
boost::filesystem::path filename
filename for problem
boost::filesystem::path tmpfolder
where the temp files at?
boost::filesystem::path called_dir
where was I when I was instantiated?
int numfilesatatime
current number of files passed out at each distribution
std::ifstream mc_in_stream
parameter point in file
int numparam
number of parameters in problem
void master_main(ProgSettings input_settings, runinfo input_p_info, timer &process_timer)
void SeedBasic(timer &process_timer)
int standardstep2
switch for total degree vs. coeff. homotopy
boost::filesystem::path inputfilename
boost::filesystem::path location
int numfilesatatime_orig
given number of files passed out at each distribution
int num_active_workers
parity checker
int current_absolute_index
the current absolute index.
void add_time(const std::string timer_name)
std::vector< std::pair< double, double > > MakeRandomValues(int garbageint)
A class that stores the general program settings of Paramotopy.
std::vector< std::vector< std::pair< double, double > > > Values
A class for the input file parser.
std::string WriteFailStep2(std::vector< std::pair< double, double > > CValues, ProgSettings paramotopy_settings, runinfo paramotopy_info)
std::string WriteStep2(std::vector< std::pair< double, double > > CValues, ProgSettings paramotopy_settings, runinfo paramotopy_info)
void SendInput(timer &process_timer)
int terminationint
maximum absolute_current_index value before loop breaks.
std::vector< std::pair< double, double > > BoundsLeft
void press_start(const std::string timer_name)
Capable of timing arbitrary categories of processes, using a map of timer_data's. ...
std::vector< int > lastnumsent
progress tracker
std::vector< std::pair< double, double > > BoundsRight
int GetStart(boost::filesystem::path dir, std::string &start, std::string startfilename)
void FormNextValues(int pointcounter, std::vector< std::vector< std::pair< double, double > > > Values, double tempsends[])