-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstart.sh
executable file
·239 lines (234 loc) · 8.52 KB
/
start.sh
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
#!/bin/bash
run_type="serial"
sim_name=""
sim_options="-q "
pdf_options=""
aggr_coeff=""
number_test=""
quiet="no"
topology_path="tests_topology/config.txt"
catalog_path="tests_topology/catalog"
output_location="tree_simulator_bin"
targets=()
error="no"
initial_location=$(pwd)
options=""
lp_aggregation="--lp_aggregation_criteria=regional"
make_redirect=""
for arg
do
if [[ $arg == "aggregated" || $arg == "--aggregated" || $arg == "-aggr" ]]; then
pdf_options="-a"
elif [[ ${arg:0:11} == "--sim_coef=" ]]; then
aggr_coeff="-sim_coef "+${arg#"--sim_coef="}
elif [[ ${arg:0:5} == "--sc=" ]]; then
aggr_coeff="-sim_coef "+${arg#"--sc="}
elif [[ $arg == "-q" || $arg == "--quiet" ]]; then
quiet="yes"
elif [[ ${arg:0:6} == "--top=" ]]; then
topology_path=${arg#"--top="}
elif [[ $arg == "-g" || $arg == "--generator" ]]; then
targets[${#targets[@]}]="generator"
elif [[ $arg == "-a" || $arg == "--analytical_model" ]]; then
targets[${#targets[@]}]="analytical model"
elif [[ $arg == "-s" || $arg == "--simulation" ]]; then
targets[${#targets[@]}]="simulation"
sim_options+="--run-complete "
elif [[ $arg == "-r" || $arg == "--results" ]]; then
targets[${#targets[@]}]="results"
elif [[ $arg == "all" || $arg == "--all" ]]; then
targets[${#targets[@]}]="all"
options="all"
sim_options+="--run-complete "
elif [[ ${arg:0:29} == "--redir_compilation_messages=" ]]; then
make_redirect=">>${arg#"--redir_compilation_messages="} 2>&1"
sim_options+="$arg "
elif [[ ${arg:0:6} == "--cat=" ]]; then
catalog_path=${arg#'--cat='}
elif [[ ${arg:0:17} == "--lp_aggregation=" ]]; then
lp_aggregation="--lp_aggregation_criteria=${arg#"--lp_aggregation="}"
elif [[ ${arg:0:6} == "--out=" ]]; then
output_location=${arg#'--out='}
sim_options+=$arg
elif [[ $arg == "clean" ]]; then
targets[${#targets[@]}]="clean"
sim_options+="$arg "
else
sim_options+=$arg" "
arg=${arg//'-'/''}
arg=${arg,,}
if [[ $arg == "rootsim" ]]; then
sim_name="ROOT-Sim"
elif [[ $arg == "rootsim3" || $arg == "neurome" ]]; then
sim_name="NeuRome"
elif [[ $arg == "use" ]]; then
sim_name="USE"
fi
fi
if [[ $arg == "parallel" ]]; then
run_type="parallel"
fi
done
if [[ ${#targets[@]} > 1 && $options == "all" ]]; then
echo -e "ERROR: all and other execution options specified, use ONLY all or -g, -a, -s, -r."
error="yes"
fi
if [[ ${#targets[@]} == 0 ]]; then
echo -e "ERROR: no command specified, use at least one of these: -g -a -s -r --all.\n"
error="yes"
fi
if [[ $quiet == "no" || $error == "yes" ]]; then
echo -e "This script will test the tree_simulator model with the configuration provided in \"tests_topology\"."
echo -e "\nThe script can generate the topology, run the analytical model, run the simulation model and present the result in a pdf located in \"pdf_result\". The pdf file name will be: h-m-s-simulator_used-run_type-results."
echo -e "\nHowever to run any of these operations an argument needs to be given, see below in \"Execution options\"."
echo -e "\nArgument list:\n
\nGeneral options\n
\"-q --quiet\": suppress this message\n
\"--redir_compilation_messages=[path to file]\": redirect compilation messages to a file. The file will be used in append.\n
\"clean\": remove all the products of a previous run, including the output location and all object files.
\n Execution options\n
\"-g\": generate only the topology files\n
\"-a\": only run the analytical model\n
\"-s\": run only the simulation model\n
\"-r\": create only the pdf with the results\n
\"all --all\":execute all the above steps (don't use this argument with the ones above)\n
\nData options:\n
\"aggregated --aggregated -aggr\": in the pdf results, aggregate nodes that have similar characteristics (by default a 20% tolerance is used for aggreagtion)\n
\"--lp_aggregation=[central,regional,local,lan]\": customizes how the elements are to be aggregated into LPs.
\"--cat=\": path to the catalog folder that stores element types, defaults to \"tests_topology/catalog\"\n
\"--top=\": path to the topology file from the \"rootsim-models\" folder; if this argument is not specified the the default path will be \"tests_topology/config.txt\"\n
\"-sc= --sim_coef=\": to define a custom tolerance value (as a number between 0 and 1) for the results aggregation\n
\"--out=\": location where all the produced files (data and executables) will be located, defaults to \"tree_simulator_bin\"\n
\nSimulation options:
All the arguments that can be passed to \"tree_simulator/run.sh\" are supported, here we will provide only a brief list of the most important ones:\n
\"--wt=\":number of threads\n
\"--lp=\":number of lps\n
\"gdb\": run the simulation under gdb\n
\"valgrind\": run the simulation under valgrind\n
\"parallel\": run the simulation with more than one thread\n
\"serial\": run the simulation with only one thread (default choice)\n
\"NeuRome\": use NeuRome as a simulation platform.\n
\"ROOT-Sim\": use ROOT-Sim as a simulation platform.\n
\"USE\": use USE as a simulation platform.\n"
echo -e "\nUnrecognized arguments will be ignored."
fi
if [[ $error == "yes" ]];then
exit 255
else
if [[ $quiet == "no" ]]; then
read -n1 -r -p "Press any key to continue or CTRL+C to exit" key
fi
fi
#converting into absolute path
if [[ $output_location =~ ^[^/].*$ ]]; then
output_location="$(pwd)/$output_location"
fi
mkdir -p $output_location
for target in ${targets[@]}; do
if [[ $target == "clean" ]]; then
echo "Cleaning..."
rm -rf $output_location
make -C utils/partop clean >/dev/null
make -C model_computation clean >/dev/null
cd tree_simulator
bash run.sh -q clean
cd ..
echo "Done."
fi
if [[ $target == "all" || $target == "generator" ]]; then
echo "Starting generator..."
python3 utils/generator/generator.py $catalog_path $topology_path $output_location
err=$?
if [[ $err != 0 ]]; then
echo "error during topology generation, aborting."
exit $err
fi
echo "Done."
eval make -C utils/partop driverBinaries $make_redirect
err=$?
if [[ $err != 0 ]]; then
echo "Error during compilation of topology binary files generator, aborting."
exit $err
fi
echo "Setting up folders for binary files..."
rm -rf $output_location"/bin"
mkdir -p $output_location"/bin/gentop" $output_location"/bin/lptop"
echo "Done."
echo "Creating binary files..."
./utils/partop/driverBinaries $output_location"/topology.txt" $output_location"/LP.txt" $output_location $lp_aggregation
err=$?
if [[ $err != 0 ]]; then
echo "Error during generation of topology binary files, aborting."
exit $err
fi
echo "Done."
fi
if [[ $target == "all" || $target == "analytical model" ]]; then
echo "Starting analytical model computation..."
eval LOCATION="$output_location" make -C model_computation $make_redirect
err=$?
if [[ $err != 0 ]]; then
echo "Error during compilation of analytical model, aborting."
exit $err
fi
cd $output_location
./analytical_model_computation
err=$?
cd $initial_location
if [[ $err != 0 ]]; then
echo "Error during analytical model computation, aborting."
exit $err
fi
echo "Done."
fi
if [[ $target == "all" || $target == "simulation" ]]; then
echo "Starting simulation..."
cd tree_simulator
bash run.sh $sim_options
err=$?
cd ..
if [[ $err != 0 ]]; then
echo "Error during model simulation, aborting."
exit $err
fi
echo "Done."
fi
if [[ $target == "all" || $target == "results" ]]; then
echo "Parsing jsons and merging them..."
if [[ $pdf_options == "-a" ]]; then
echo "...aggregated results."
python3 jsonMerger/jsonParse.py -a $output_location $output_location $output_location $output_location
else
echo "...standard."
python3 jsonMerger/jsonParse.py $output_location $output_location $output_location $output_location
fi
err=$?
if [[ $err != 0 ]]; then
echo "Error during data parsing, aborting."
exit $err
fi
echo "Done."
cd $output_location
echo "Creating pdf..."
eval pdflatex complete_results.tex $make_redirect
err=$?
rm -f complete_results.log complete_results.aux
if [[ $err != 0 ]]; then
echo "Error during document creation, aborting."
exit $err
fi
echo "Done."
echo "Moving and renaming pdf..."
res_name=$(date +%H_%M_%S)-$sim_name-$run_type-complete_results.pdf
if [[ $output_location =~ ^.*tree_simulator_bin$ ]]; then
output_location="$initial_location/pdf_results"
fi
mv complete_results.pdf $output_location/$res_name
if [[ $err != 0 ]]; then
echo "Error during document rename, aborting."
exit $err
fi
echo "Done, results are in file $res_name located in the \"$output_location\" folder."
cd $initial_location
fi
done