-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlaunch
More file actions
executable file
·315 lines (293 loc) · 13.9 KB
/
launch
File metadata and controls
executable file
·315 lines (293 loc) · 13.9 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
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
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
#!/bin/bash
APPS=(mobilenetv2 resnet50 ssdmobilenetv2_320x320 ssdresnet50v1_640x640 smallbert talkingheads)
# NUMINSTANCES=1
DEVICE=cpu
ITERATIONS=10
function main() {
PWD=$(pwd)
SCRIPTDIR=$( cd -- "$( dirname -- "${BASH_SOURCE[0]}" )" &> /dev/null && pwd )
COMMAND=$1
GPU=0
if [[ "$PWD" != "$SCRIPTDIR" ]]; then
print_error "This script needs to be launched in its own root directory!\nexit"
exit 1
fi
parse_arg "${@:2}"
case $COMMAND in
hello-world)
local app=mobilenetv2
print_info "CURRENT APPLICATION=$app, RATIO=default"
cd ../applications/${app}
if [[ $DEVICE = "gpu" ]]; then
bash exp_script.sh latency-mon-gpu -n=1 --policy=1 --device=$DEVICE
bash exp_script.sh latency-gpu -n=1 --policy=1 --device=$DEVICE
else
bash exp_script.sh latency-mon -n=1 --policy=1 --device=$DEVICE
bash exp_script.sh latency -n=1 --policy=1 --device=$DEVICE
fi
cd - > /dev/null 2>&1
;;
latency)
print_warning "This script requires bash version newer than 4.0. The current version is ${BASH_VERSION}."
declare -A ratio
ratio+=( ["mobilenetv2"]=0.8 ["resnet50"]=0.8 ["ssdmobilenetv2_320x320"]=0.8 ["ssdresnet50v1_640x640"]=0.8 ["smallbert"]=0.8 ["talkingheads"]=0.8 )
for app in ${APPS[@]}; do
echo
mempolicy=( NONE func,ratio,${ratio[$app]} conn,ratio,${ratio[$app]} func,none )
cpupolicy=( NONE func,ratio,${ratio[$app]} conn,ratio,${ratio[$app]} func,none )
print_info "CURRENT APPLICATION=$app, RATIO=${ratio[$app]}"
cd ../applications/${app}
print_info "$app-pocket"
# for p in 1 2 3; do
for p in 1; do
for n in $(seq 1 10); do
print_info "$app-pocket policy=$p, n=$n, i=$ITERATIONS"
for i in $(seq 1 $ITERATIONS); do
bash exp_script.sh latency \
-n=$n \
--mempolicy=${mempolicy[$p]} \
--cpupolicy=${cpupolicy[$p]} \
--device=$DEVICE 2>&1 | grep inference_time | sed 's/^.*inference_time=//g'
done
done
done
print_info "$app-monolithic"
for n in $(seq 1 10); do
print_info "$app-pocket n=$n, i=$ITERATIONS"
for i in $(seq 1 $ITERATIONS); do
bash exp_script.sh latency-mon -n=$n --policy=1 --device=$DEVICE 2>&1 | grep inference_time | sed 's/^.*inference_time=//g'
done
done
cd - > /dev/null 2>&1
done
;;
latency-gpu)
print_warning "This script requires bash version newer than 4.0. The current version is ${BASH_VERSION}."
declare -A ratio
ratio+=( ["mobilenetv2"]=0.8 ["resnet50"]=0.8 ["ssdmobilenetv2_320x320"]=0.8 ["ssdresnet50v1_640x640"]=0.8 ["smallbert"]=0.8 ["talkingheads"]=0.8 )
for app in ${APPS[@]}; do
echo
mempolicy=( NONE func,ratio,${ratio[$app]} conn,ratio,${ratio[$app]} func,none )
cpupolicy=( NONE func,ratio,${ratio[$app]} conn,ratio,${ratio[$app]} func,none )
print_info "CURRENT APPLICATION=$app, RATIO=${ratio[$app]}"
cd ../applications/${app}
print_info "$app-pocket"
for p in 1 2 3; do
for n in 1 3 5 10 15 20; do
print_info "$app-pocket policy=$p, n=$n, i=$ITERATIONS"
inf_arr=()
be_arr=()
fe_arr=()
for i in $(seq 1 $ITERATIONS); do
IFS=$'\n' lines=($(bash exp_script.sh latency-gpu \
-n=$n \
--mempolicy=${mempolicy[$p]} \
--cpupolicy=${cpupolicy[$p]} \
--device=$DEVICE 2>&1 | grep _time))
# echo \#lines ${#lines[@]}
# echo lines ${lines[@]}
local last_idx=$(( ${#lines[@]} - 1 ))
for i in $(seq 0 $last_idx); do
# echo line=${lines[$i]}
if [[ ${lines[$i]} == *"inference_time"* ]]; then
local inf=$(echo ${lines[$i]} | grep inference_time | sed 's/^.*inference_time=//g')
# echo inf=$inf
inf_arr+=($inf)
elif [[ ${lines[$i]} == *"be_time"* ]]; then
local be=$(echo ${lines[$i]} | grep be_time | sed 's/^.*be_time=//g')
# echo be=$be
be_arr+=($be)
elif [[ ${lines[$i]} == *"fe_time"* ]]; then
local fe=$(echo ${lines[$i]} | grep fe_time | sed 's/^.*fe_time=//g')
# echo fe=$fe
fe_arr+=($fe)
fi
done
# bash exp_script.sh latency-gpu \
# -n=$n \
# --mempolicy=${mempolicy[$p]} \
# --cpupolicy=${cpupolicy[$p]} \
# --device=$DEVICE 2>&1 | grep inference_time | sed 's/^.*inference_time=//g'
done
echo inference_time ${inf_arr[@]}
echo be_time ${be_arr[@]}
echo fe_time ${fe_arr[@]}
done
done
print_info "$app-monolithic"
for n in 1 3 5 10 15 20; do
print_info "$app-pocket n=$n, i=$ITERATIONS"
inf_arr=()
for i in $(seq 1 $ITERATIONS); do
IFS=$'\n' lines=($(bash exp_script.sh latency-mon-gpu -n=$n --policy=1 --device=$DEVICE 2>&1 | grep inference_time))
local last_idx=$(( ${#lines[@]} - 1 ))
for i in $(seq 0 $last_idx); do
local inf=$(echo ${lines[$i]} | grep inference_time | sed 's/^.*inference_time=//g')
# echo line=${lines[$i]}
# echo inf=$inf
inf_arr+=($inf)
done
done
echo inference_time ${inf_arr[@]}
done
cd - > /dev/null 2>&1
done
;;
latency-tmp)
print_warning "This script requires bash version newer than 4.0. The current version is ${BASH_VERSION}."
declare -A ratio
ratio+=( ["mobilenetv2"]=0.8 ["resnet50"]=0.8 ["ssdmobilenetv2_320x320"]=0.8 ["ssdresnet50v1_640x640"]=0.8 ["smallbert"]=0.8 ["talkingheads"]=0.8 )
APPS=(ssdresnet50v1_640x640)
ITERATIONS=1
for app in ${APPS[@]}; do
echo
mempolicy=( NONE func,ratio,${ratio[$app]} conn,ratio,${ratio[$app]} func,none )
cpupolicy=( NONE func,ratio,${ratio[$app]} conn,ratio,${ratio[$app]} func,none )
print_info "CURRENT APPLICATION=$app, RATIO=${ratio[$app]}"
cd ../applications/${app}
print_info "$app-pocket"
for p in 1 2; do
for n in 1 5 10 20; do
print_info "$app-pocket policy=$p, n=$n, i=$ITERATIONS"
for i in $(seq 1 $ITERATIONS); do
bash exp_script.sh latency-gpu \
-n=$n \
--mempolicy=${mempolicy[$p]} \
--cpupolicy=${cpupolicy[$p]} \
--device=$DEVICE 2>&1 | grep inference_time | sed 's/^.*inference_time=//g'
done
done
done
cd - > /dev/null 2>&1
done
;;
eval-policy)
for app in ${APPS[@]}; do
cd ../applications/${app}
for p in $(seq 0 8); do
docker rm -f $(docker ps -aq) > /dev/null 2>&1
print_info "[parse/header] CURRENT APPLICATION=$app, RATIO=0.$p"
bash exp_script.sh latency -n=1 --cpupolicy="func,ratio,0.$p" --mempolicy="func,ratio,0.$p" 2>&1 grep 'inference_time\|>>>>>>>'
done
done
;;
exec-breakdown)
local apps=(ssdresnet50v1_640x640 smallbert)
for app in ${apps[@]}; do
cd ../applications/${app}
# to evaluate pocket-dynamic
print_info "[parse/header] CURRENT APPLICATION=$app, POLICY=dynamic"
docker rm -f $(docker ps -aq) # to removing dangling instance and clean up
bash exp_script.sh measure-exec -n=1 --policy=1 && docker wait pocket-client-0001
docker logs pocket-client-0001 2>&1 | grep 'total_time\|be_time\|fe_time\|fe_ratio'
# to evaluate none
print_info "[parse/header] CURRENT APPLICATION=$app, POLICY=none"
docker rm -f $(docker ps -aq) # to removing dangling instance and clean up
bash exp_script.sh measure-exec -n=1 --policy=3 && docker wait pocket-client-0001
docker logs pocket-client-0001 2>&1 | grep 'total_time\|be_time\|fe_time\|fe_ratio'
# to evaluate pocket-static
print_info "[parse/header] CURRENT APPLICATION=$app, POLICY=static"
docker rm -f $(docker ps -aq) # to removing dangling instance and clean up
bash exp_script.sh measure-exec -n=1 --policy=4 && docker wait pocket-client-0001
docker logs pocket-client-0001 2>&1 | grep 'total_time\|be_time\|fe_time\|fe_ratio'
done
;;
latency-fc)
# @Todo
;;
# boottime)
# # local APPS=(ssdmobilenetv2_320x320 ssdresnet50v1_640x640)
# for app in ${APPS[@]}; do
# echo
# print_info "[parse/header] CURRENT APPLICATION=$app"
# cd ../applications/${app}
# for n in 1 5 10 20; do
# print_info "[parse/header] $app-pocket n=$n, i=$ITERATIONS"
# for i in $(seq 1 $ITERATIONS); do
# bash exp_script.sh boottime \
# -n=$n
# done
# done
# for n in 1 5 10 20; do
# print_info "[parse/header] $app-monolith n=$n, i=$ITERATIONS"
# for i in $(seq 1 $ITERATIONS); do
# bash exp_script.sh boottime-mon \
# -n=$n
# done
# done
# if [[ $(which criu | wc -l) -lt 1 ]]; then
# print_error "criu is not installed. skipping c/r experiment"
# continue
# sudo add-apt-repository ppa:criu/ppa -y
# sudo apt update -y
# sudo apt-get install criu -y
# fi
# # for n in 1; do
# for n in 1 5 10 20; do
# docker rm -f $(docker ps -aq)
# docker container prune --force
# sudo rm -rf /tmp/*checkpoint* && sudo systemctl restart docker; sleep 10
# print_info "[parse/header] $app-cr n=$n, i=$ITERATIONS"
# for i in $(seq 1 $ITERATIONS); do
# bash exp_script.sh boottime-mon-cr \
# -n=$n
# done
# done
# cd - > /dev/null 2>&1
# done
# ;;
*)
print_error "No such command: $COMMAND"
;;
esac
}
function parse_arg() {
for arg in $@; do
case $arg in
--gpu=*)
GPU=${arg#*=}
DEVICE=$([[ $GPU = "1" ]] && echo gpu || echo cpu)
;;
--app=*|-a=*)
APPS=(${arg#*=})
;;
--apps=*)
IFS=',' read -r -a APPS <<< "${arg#*=}"
;;
# --num=*|-n=*)
# NUMINSTANCES=${args#*=}
# ;;
--iteration=*|--iter=*|-i=*)
ITERATIONS=${arg#*=}
;;
*)
print_error "No such option: $arg"
;;
esac
done
}
_BOLD="\e[1m"
_DIM="\e[2m"
_RED="\e[31m"
_LYELLOW="\e[93m"
_LGREEN="\e[92m"
_LCYAN="\e[96m"
_LMAGENTA="\e[95m"
_RESET="\e[0m"
function print_error() {
local message=$1
echo -e "${_BOLD}${_RED}[ERROR]${_RESET} ${message}${_RESET}"
}
function print_warning() {
local message=$1
echo -e "${_BOLD}${_LYELLOW}[WARN]${_RESET} ${message}${_RESET}"
}
function print_info() {
local message=$1
echo -e "${_BOLD}${_LGREEN}[INFO]${_RESET} ${message}${_RESET}"
}
function print_debug() {
local message=$1
echo -e "${_BOLD}${_LCYAN}[DEBUG]${_RESET} ${message}${_RESET}"
}
main "$@"; exit