-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprofile_app_eventwise.sh
executable file
·180 lines (144 loc) · 5.4 KB
/
profile_app_eventwise.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
#!/bin/bash
# this script is meant to profile the events marking the beginning & end of compiler interrupt handler. It is important to build all the benchmarks first, in the CI mode that needs to be debugged. Also, to simultaneously profile the app based on intervals, run the profile_app_intervalwise.sh first, & then start this script. Some of the benchmarks like the water ones, don't seem to work through the script, but works manually, not sure why.
CUR_PATH=`pwd`/$(dirname "${BASH_SOURCE[0]}")/
SUB_DIR="${SUB_DIR:-"perf_profile"}"
DIR=$CUR_PATH/exp_results/$SUB_DIR
CYCLE="${CYCLE:-5000}"
THREAD=1
CI_SETTINGS="2 12"
EXTRA_FLAGS="-DINTV_SAMPLING"
#CI_SETTINGS="12"
source $CUR_PATH/include.sh
if ! [ $(id -u) = 0 ]; then
echo "This script needs to be run as root!"
exit
fi
perf_profile() {
bench=$1
ci_setting=$2
thread=$THREAD
suffix_conf=1
#ofile="$DIR/${bench}-ci${ci_setting}-for-sampling.data"
ofile="$DIR/${bench}-ci${ci_setting}.data"
perf probe -d ci_start -d ci_end__return
executable_name=$(get_executable_name $bench 1)
PREFIX="" dry_run_exp $bench $suffix_conf
pushd $BENCH_DIR
rm -f *.old
perf probe -l
if [ "$BENCH_SUITE" != "phoenix" ]; then
cmd="perf probe -x $executable_name ci_start=compiler_interrupt_handler"
run_command $cmd
cmd="perf probe -x $executable_name ci_end=compiler_interrupt_handler%return"
run_command $cmd
else
cmd="perf probe -x ./tests/$bench/$executable_name ci_start=compiler_interrupt_handler"
run_command $cmd
cmd="perf probe -x ./tests/$bench/$executable_name ci_end=compiler_interrupt_handler%return"
run_command $cmd
fi
echo "Probe listing:-"
perf probe -l
popd > /dev/null
# run system-wide profiler before the actual experiment run
cmd="mv $BUILD_LOG $DIR/tmp1"; run_command $cmd
cmd="mv $ERROR_LOG $DIR/tmp2"; run_command $cmd
$CUR_PATH/profile_app_intervalwise.sh $bench $ci_setting &
sleep 2
cmd="mv $DIR/tmp1 $BUILD_LOG"; run_command $cmd
cmd="mv $DIR/tmp2 $ERROR_LOG"; run_command $cmd
# Experiment run
case "$bench" in
"ocean-cp" | "ocean-ncp")
PREFIX="perf record -g -e probe_ocean:ci_start -e probe_ocean:ci_end__return -o $ofile"
;;
"lu-c" | "lu-nc")
PREFIX="perf record -g -e probe_lu:ci_start -e probe_lu:ci_end__return -o $ofile"
;;
"water-nsquared" | "water-spatial")
# does not work through script for some reason, but works manually
PREFIX="perf record -g -e probe_water:ci_start -e probe_water:ci_end__return -o $ofile"
;;
"blackscholes" | "fluidanimate" | "swaptions" | "canneal" | "streamcluster" | "dedup")
PREFIX="perf record -g -e probe_${executable_name}:ci_start -e probe_${executable_name}:ci_end__return -o $ofile"
;;
*)
PREFIX="perf record -g -e probe_${bench}:ci_start -e probe_${bench}:ci_end__return -o $ofile"
;;
esac
PREFIX="LD_PRELOAD=$LIBCALL_WRAPPER_PATH $PREFIX"
printf "${GREEN}Experiment run for CI:-\n${NC}" | tee -a $CMD_LOG
run_exp $bench $suffix_conf $thread $ci_setting 0 $CYCLE
perf probe -d ci_start -d ci_end__return
perf probe -l
sleep 10
echo -e "\n\n\n\n\n"
}
perf_profile_test() {
thread=$THREAD
echo "Experiment for performance profiling for $CYCLE cycles, CI Settings $CI_SETTINGS, $THREAD threads, app list: $*"
for ci_setting in $CI_SETTINGS; do
for bench in $*; do
ci_str=$(get_ci_str $ci_setting)
echo "Running performance profiling experiment for $bench with $thread threads & $ci_str type" | tee -a $CMD_LOG
set_benchmark_info $bench
build_ci $bench $ci_setting $thread
perf_profile $bench $ci_setting $thread
mv $OUT_FILE $DIR/${bench}-th${thread}-ci${ci_setting}-output
done
done
}
strace_profile() {
bench=$1
ci_setting=$2
thread=$THREAD
suffix_conf=1
#ofile="$DIR/${bench}-ci${ci_setting}-for-sampling.data"
ofile="$DIR/${bench}-ci${ci_setting}-th${thread}.strace"
executable_name=$(get_executable_name $bench 1)
PREFIX="" dry_run_exp $bench $suffix_conf
# Experiment run
PREFIX="strace -T -t -k -E LD_PRELOAD=$LIBCALL_WRAPPER_PATH -o $ofile "
printf "${GREEN}Experiment run for CI:-\n${NC}" | tee -a $CMD_LOG
run_exp $bench $suffix_conf $thread $ci_setting 0 $CYCLE
sleep 10
echo -e "\n\n\n\n\n"
}
strace_profile_test() {
thread=$THREAD
echo "Experiment for performance profiling for $CYCLE cycles, CI Settings $CI_SETTINGS, $THREAD threads, app list: $*"
for ci_setting in $CI_SETTINGS; do
for bench in $*; do
ci_str=$(get_ci_str $ci_setting)
echo "Running performance profiling experiment for $bench with $thread threads & $ci_str type" | tee -a $CMD_LOG
set_benchmark_info $bench
build_ci $bench $ci_setting $thread
strace_profile $bench $ci_setting $thread
mv $OUT_FILE $DIR/${bench}-th${thread}-ci${ci_setting}-output
done
done
}
benches="$splash2_benches $phoenix_benches $parsec_benches"
# Usage:
# No argument : run for all benchmark suites
# $1=0, $2=<name of benchmark>
# $1=1, $2=<name of benchmark suite>
if [ $# -ne 0 ]; then
if [ $1 -eq 1 ]; then
benches=""
for arg in $@; do
if [ "$arg" == "splash2" ]; then
benches="$benches$splash2_benches "
elif [ "$arg" == "phoenix" ]; then
benches="$benches$phoenix_benches "
elif [ "$arg" == "parsec" ]; then
benches="$benches$parsec_benches "
fi
done
else
benches="${@:2}"
fi
fi
perf_profile_test $benches
strace_profile_test $benches
print_end_notice