-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathbertini_real.cpp
More file actions
143 lines (103 loc) · 3.97 KB
/
bertini_real.cpp
File metadata and controls
143 lines (103 loc) · 3.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
#include "bertini_real.hpp"
int main(int argC, char *args[])
/***************************************************************\
* USAGE: *
* ARGUMENTS: *
* RETURN VALUES: *
* NOTES: *
\***************************************************************/
{
////
// INITIALIZATION
////
MPI_Init(&argC,&args);
//instantiate options
BertiniRealConfig program_options;
SolverConfiguration solve_options;
int MPType;
program_options.parse_commandline(argC, args); // everybody gets to parse the command line.
if (program_options.debugwait()) {
if (solve_options.is_head()) {
std::cout << "in debug mode, waiting to start so you can attach to this process" << std::endl;
std::cout << "master PID: " << getpid() << std::endl;
for (int ii=0; ii<30; ii++) {
std::cout << "starting program in " << 30-ii << " seconds" << std::endl;
sleep(1);
std::cout << "\033[F"; // that's a line up movement. only works with some terminals
}
}
if (solve_options.use_parallel()) {
MPI_Barrier(MPI_COMM_WORLD);
}
}
int seed;
if (solve_options.is_head()) {
// split the input_file. this must be called before setting up the solver config.
seed = parse_input_file(program_options.input_filename(), &MPType);
// set up the solver configuration
get_tracker_config(solve_options,MPType);
solve_options.T.ratioTol = 0.9999999999999999999999999; // manually assert to be more permissive. i don't really like this.
}
else
{ // catch the bcast from parallel parsing (which cannot be disabled)
MPI_Bcast(&seed,1,MPI_INT,0,MPI_COMM_WORLD); // first is declaration that a parse is going to happen.
int arbitrary_int;
MPI_Bcast(&arbitrary_int,1,MPI_INT,0,MPI_COMM_WORLD); // second is the bcast from the parse.
//yes, you do have to do both of these.
}
// seed the random number generator
srand(seed);
if (solve_options.use_parallel()) { // everybody participates in this.
MPI_Bcast(&solve_options.path_number_modulus,1,MPI_INT,0,MPI_COMM_WORLD);
bcast_tracker_config_t(&solve_options.T, solve_options.id(), solve_options.head() );
}
initMP(solve_options.T.Precision); // set up some globals.
solve_options.use_midpoint_checker = 0;
solve_options.verbose_level(program_options.verbose_level());
solve_options.use_gamma_trick = program_options.use_gamma_trick();
solve_options.robust = program_options.robustness()>=1;
solve_options.save_all_paths_to_disk = program_options.save_all_paths_to_disk();
if (solve_options.is_head()) {
MainProcess current_process(program_options, solve_options);
try{
current_process.main_loop();
}
catch (std::runtime_error &e)
{
std::cout << "uncaught runtime exception from Main process caught in bertini_real;" << std::endl;
std::cout << e.what() << std::endl;
}
catch (std::logic_error &e)
{
std::cout << "uncaught logic exception from Main process caught in bertini_real;" << std::endl;
std::cout << e.what() << std::endl;
}
catch (std::exception &e){
std::cout << "uncaught other exception from Main process caught in bertini_real;" << std::endl;
std::cout << e.what() << std::endl;
}
}
else{
WorkerProcess current_process(program_options, solve_options);
try{
current_process.main_loop();
}
catch (std::runtime_error& e)
{
std::cout << "uncaught runtime exception from Main process caught in bertini_real;" << std::endl;
std::cout << e.what() << std::endl;
}
catch (std::logic_error& e)
{
std::cout << "uncaught logic exception from Main process caught in bertini_real;" << std::endl;
std::cout << e.what() << std::endl;
}
catch (std::exception& e){
std::cout << "uncaught other exception from worker process caught in bertini_real;" << std::endl;
std::cout << e.what() << std::endl;
}
}
clearMP();
MPI_Finalize();
return 0;
}