-
Notifications
You must be signed in to change notification settings - Fork 1
/
bax.sh
executable file
·271 lines (228 loc) · 7.39 KB
/
bax.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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
#!/bin/bash
# Author: Andreas Hager-Clukas
# Email: andreas.hager-clukas@hm.edu
set -ue
SCRIPT_ROOT="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
SCRIPT_TARGET=${SCRIPT_ROOT}/target_scrips
SCRIPT_ANALYSIS=${SCRIPT_ROOT}/analysis
OUT_DIR=${SCRIPT_ROOT}/out
# Set default values
clean=false
musl=false
embench=false
linux=false
start_db=false
purge_db=false
build_dfg=false
analyze_dfg=false
build_target=false
analyze_binary=false
run_embench_size=false
run_etiss_embench=false
analyze_traces=false
debug=false
# Usage manual entry
usage() {
cat << EOF
Usage: ${0##*/} [OPTIONS]
This script builds and executes the Analysis for Embench-iot.
Available options:
--clean Clean run full analysis (default: $clean)
--musl Set target to musl (default: $musl)
--embench set target to Embench (default: $embench)
--linux set target to Linux (default: $linux)
--start-db Start the database service (default: $start_db)
--purge-db Purge the database (default: $purge_db)
--build-dfg Build the data flow graph (default: $build_dfg)
--analyze-dfg Analyze the data flow graph (default: $analyze_dfg)
--build-target Build target (default: $build_target)
--analyze-binary Analyze binary files (default: $analyze_binary)
--run-embench-size Run Embench benchmark for size (default: $run_embench_size)
--run-etiss-embench Run ETISS with Embench benchmark (default: $run_etiss_embench)
--analyze-traces Enable trace analysis (default: $analyze_traces)
--help Display this help and exit
EOF
exit
}
# Loop through arguments and process them
for arg in "$@"
do
case $arg in
--clean)
clean=true
shift # Remove --clean from processing
;;
--start-db)
start_db=true
shift # Remove --start-db from processing
;;
--embench)
embench=true
shift # Remove --embench from processing
;;
--musl)
musl=true
shift # Remove --musl from processing
;;
--linux)
linux=true
shift # Remove --linux from processing
;;
--purge-db)
purge_db=true
shift # Remove --purge-db from processing
;;
--build-dfg)
build_dfg=true
shift # Remove --build-dfg from processing
;;
--analyze-dfg)
analyze_dfg=true
shift # Remove --analyze-dfg from processing
;;
--build-target)
build_target=true
shift # Remove --build-embench from processing
;;
--analyze-binary)
analyze_binary=true
shift # Remove --analyze-binary from processing
;;
--run-embench-size)
run_embench_size=true
shift # Remove --run-embench-size from processing
;;
--run-etiss-embench)
run_etiss_embench=true
shift # Remove --run-etiss-embench from processing
;;
--analyze-traces)
analyze_traces=true
shift # Remove --analyze-traces from processing
;;
--help)
usage
;;
*)
# Unknown option
echo "Error: Invalid option $arg"
exit 1
;;
esac
done
if [ "$clean" = true ] ; then
start_db=true
purge_db=true
build_llvm=true
build_dfg=true
analyze_dfg=true
build_target=true
analyze_binary=true
run_embench_size=true
run_etiss_embench=true
analyze_traces=true
fi
if [ "$debug" = true ] ; then
echo "INFO params:"
echo " clean=$clean"
echo " start_db=$start_db"
echo " purge_db=$purge_db"
echo " build_llvm=$build_llvm"
echo " build_dfg=$build_dfg"
echo " analyze_dfg=$analyze_dfg"
echo " build_target=$build_target"
echo " analyze_binary=$analyze_binary"
if [ "$embench" = true ] ; then
echo " run_embench_size=$run_embench_size"
echo " run_etiss_embench=$run_etiss_embench"
fi
echo " analyze_traces=$analyze_traces"
fi
if [ "$clean" = true ] ; then
echo "INFO: Cleaning old $OUT_DIR"
rm -r ${OUT_DIR}
mkdir ${OUT_DIR}
fi
if [ "$purge_db" = true ] ; then
echo "INFO: Start memgraph"
docker start memgraph &> ${OUT_DIR}/docker_start_out.txt
fi
if [ "$purge_db" = true ] ; then
echo "INFO: Purge db"
echo "MATCH (N) DETACH DELETE N;" | mgconsole
fi
if [ "$build_dfg" = true ] ; then
# build dfg pass
echo "INFO: Build DFG analysis LLVM-Pass"
${SCRIPT_ROOT}/build_dfg_pass.sh &> ${OUT_DIR}/dfg_pass_build.txt
# Static analyze benchmark
echo "INFO: Building DFG"
if [ "$embench" = true ] ; then
${SCRIPT_TARGET}/static_dfg_analyze_embench_iot.sh &> ${OUT_DIR}/embench_dfg_pass_run.txt
fi
if [ "$musl" = true ] ; then
${SCRIPT_TARGET}/static_dfg_analyze_musl.sh &> ${OUT_DIR}/musl_dfg_pass_run.txt
fi
if [ "$linux" = true ] ; then
${SCRIPT_TARGET}/static_dfg_analyze_linux.sh &> ${OUT_DIR}/linux_dfg_pass_run.txt
fi
fi
if [ "$analyze_dfg" = true ] ; then
echo "INFO: Analyzing DFG"
python3 ${SCRIPT_ANALYSIS}/dfg.py --pdc True &> ${OUT_DIR}/dfg_analysis.txt
fi
if [ "$build_target" = true ] ; then
if [ "$embench" = true ] ; then
echo "INFO: Building embench"
${SCRIPT_TARGET}/compile_embench_iot.sh &> ${OUT_DIR}/embench_build.txt
echo "INFO: Building embench for ETISS"
${SCRIPT_TARGET}/build_for_etiss.sh &> ${OUT_DIR}/embench_for_etiss_build.txt
fi
if [ "$musl" = true ] ; then
echo "INFO: Building musl"
${SCRIPT_TARGET}/compile_musl.sh &> ${OUT_DIR}/musl_build.txt
echo "INFO: Building bench for musl"
echo "TODO: select bench" # maybe https://www.stupid-projects.com/posts/compile-benchmarks-with-gcc-musl-and-clang/ https://bitbucket.org/dimtass/gcc_musl_clang_benchmark/src/master/
fi
if [ "$linux" = true ] ; then
echo "INFO: Building linux"
${SCRIPT_TARGET}/compile_linux.sh &> ${OUT_DIR}/linux_build.txt
fi
fi
if [ "$analyze_binary" = true ] ; then
if [ "$embench" = true ] ; then
echo "INFO: Disassembling Binaries"
${SCRIPT_TARGET}/disassemble_embench_bins.sh
echo "INFO: Static analyzing the binaries of Embench-iot"
${SCRIPT_TARGET}/static_analyze_embench.sh out &> ${OUT_DIR}/static_embench_out.txt
fi
if [ "$musl" = true ] ; then
echo "INFO: Disassembling Binaries"
${SCRIPT_TARGET}/disassemble_musl_bins.sh
echo "INFO: Static analyzing the binaries of musl"
${SCRIPT_ROOT}/static_analyze.sh out &> ${OUT_DIR}/static_musl_out.txt
fi
if [ "$linux" = true ] ; then
echo "INFO: Disassembling Binaries"
${SCRIPT_TARGET}/disassemble_linux_bins.sh
echo "INFO: Static analyzing the linux binary"
${SCRIPT_ROOT}/static_analyze.sh out &> ${OUT_DIR}/static_linux_out.txt
fi
fi
if [ "$run_embench_size" = true ] ; then
echo "INFO: Executing the static size benchmark of Embench-iot"
python3 ${SCRIPT_ROOT}/embench-iot/benchmark_size.py --json-output --json-comma &> ${OUT_DIR}/embench_static_size.json
fi
if [ "$run_etiss_embench" = true ] ; then
echo "INFO: Generating the dynamic traces for Embench-iot"
${SCRIPT_TARGET}/execute_etiss_embench.sh
fi
if [ "$analyze_traces" = true ] ; then
echo "INFO: Analyzing traces"
cd ${OUT_DIR}
TRACES=$(printf '%s ' *_trace.txt)
cd ${SCRIPT_TARGET}
# echo " INFO Executing: python3 ${SCRIPT_TARGET}/seal/analysis/dynamic/main.py --path ${OUT_DIR} ${TRACES}"
python3 ${SCRIPT_ANALYSIS}/dynamic.py --path ${OUT_DIR} ${TRACES}
fi
cd ${SCRIPT_TARGET}