-
Notifications
You must be signed in to change notification settings - Fork 3
/
main.chpl
162 lines (129 loc) · 5.51 KB
/
main.chpl
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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
use CTypes;
// use fsp_simple_serial;
// use fsp_simple_call_mcore_search;
// use fsp_simple_call_inital_search;
// use fsp_simple_call_multilocale_search;
// use fsp_johnson_serial;
// use fsp_johnson_call_mcore_search;
// use fsp_johnson_call_initial_search;
// use fsp_johnson_call_multilocale_search;
//use parametrization_local_search;
use GPU_aux;
use queens_aux;
use queens_call_mcore_search;
use queens_call_multilocale_search;
use queens_GPU_single_locale;
use GPU_mlocale_utils;
use parameters_record;
//Variables from the command line
config const initial_depth: c_int = 2;
config const second_depth: c_int = 7;
config const size: uint(16) = 15; //queens
config const prepro: bool = false; //queens first solution
//the default coordinated is TRUE
config const scheduler: string = "dynamic";
config const mlchunk: int = 0; //Size of the chunk given to each locale. 0 -- uses a heuristic
config const lchunk: int = 1; //– The chunk size to yield to each task -- when the iterator uses also the second level of parallelism.
config const slchunk: int = 1; //chunk used by the final search called by the intermediate search -- for the second level of parallelism.
config const coordinated: bool = false; //master?
//available modes:
/// mlocale:
/// nested:
/// sgpu: single-gpu execution
/// cpu-gpu: uses all CPUs and GPUs of the locale at once.
config const pgas: bool = false; //pgas-based active set?
config const num_threads: int = here.maxTaskPar; //number of threads.
config const profiler: bool = false; //to gather profiler metrics and execution graphics.
config const upper_bound: c_int = 0; //value for the initial upper bound. If it is zero, the optimal solution is going to be used.
config const lower_bound: string = "queens"; //type of lowerbound. Johnson and simple.
config const atype: string = "none"; //atomic type. 'none' when initializing using the optimal -- use like that.
config const instance: int(8) = 13; //fsp instance
config const verbose: bool = false; //verbose network communication
config const heuristic: string = "none";
config const problem: string = "simple"; //fsp - johnson, fsp - simple, queens, minla
config const computers: int = 1;
config const mode: string = "nestedml";
config const mlsearch: string = "mlocale";
config const num_gpus: c_int = 1;
config const CPUP: real = 0.0; //CPU percent
config const language: string = "chpl"; //implementation of the GPU queens search
proc main(){
//@todo -- these chunks are confusing..
//if(heuristic!="none") then initialization(heuristic,lower_bound, instance, mode);
if(false)then{}
else{
select lower_bound {
// when "simple"{//using simple bound
// select mode{
// when "serial"{
// writeln("--- CHPL-SIMPLE serial search --- \n\n");
// fsp_simple_call_serial(upper_bound,instance);
// }
// when "mcore"{
// writeln(" --- CHPL-SIMPLE mcore search --- \n\n");
// fsp_simple_call_multicore_search(initial_depth,upper_bound,scheduler,lchunk,num_threads,instance);
// }
// when "nested"{
// writeln("--- CHPL-SIMPLE nested multi-locale search --- \n");
// fsp_simple_call_multilocale_search(initial_depth,second_depth,upper_bound,scheduler,
// lchunk,mlchunk,slchunk,coordinated,pgas,num_threads,profiler,atype,instance,mode,verbose);
// }
// otherwise{
// halt("###### ERROR ######\n###### ERROR ######\n###### ERROR ######\n###### WRONG PARAMETERS ######");
// }
// }
// }//end of simple bound
// when "johnson"{
// writeln("\n --- JOHNSON LOWER BOUND --- ");
// select mode{
// when "serial"{
// writeln("--- CHPL-Johnson serial search --- \n\n");
// fsp_johnson_call_serial(upper_bound, instance);
// }//serial
// when "mcore"{
// writeln("--- CHPL-Johnson mcore search --- \n\n");
// fsp_johnson_call_multicore_search(initial_depth,upper_bound,scheduler,lchunk,num_threads,instance,true);
// }//mcode
// when "nested"{
// writeln("--- CHPL-Johnson nested multi-locale search --- \n");
// fsp_johnson_call_multilocale_search(initial_depth,second_depth,upper_bound,scheduler,
// lchunk,mlchunk,slchunk,coordinated,pgas,num_threads,profiler,atype,instance,mode,verbose);
// }//johnson nested
// otherwise{
// halt("###### ERROR ######\n###### ERROR ######\n###### ERROR ######\n###### WRONG PARAMETERS ######");
// }
// }//mode
// }//johnson bound
when "queens"{
writeln("\n--- N-QUEENS --- ");
select mode{
when "serial"{
writeln("--- N-Queens serial search --- \n\n");
queens_serial_caller(size, mode, prepro);
}
when "first"{
writeln("--- N-Queens serial -- First Solution --- \n\n");
queens_serial_caller(size, mode, prepro);
}
when "mcore"{
writeln("--- N-Queens mcore search --- \n\n");
queens_node_call_search(size, initial_depth,scheduler,slchunk,num_threads);
}
when "nestedml"{
writeln("--- N-Queens --- ", mode ," -- ", mlsearch,"\n\n");
queens_call_multilocale_search(size,initial_depth,second_depth,scheduler,mode,mlsearch,
lchunk,mlchunk,slchunk,coordinated,pgas,num_threads,profiler,verbose,
CPUP, num_gpus,language);
}//nested
when "mgpu"{
writeln("--- N-Queens multi-GPU search - single locale --- \n\n");
GPU_queens_call_search(num_gpus, size,initial_depth,CPUP,lchunk, language);
}
otherwise{
halt("###### ERROR ######\n###### ERROR ######\n###### ERROR ######\n###### WRONG PARAMETERS ######");
}
}//mode
}//queens
}//lower bound
}
}