forked from intel/caffe
-
Notifications
You must be signed in to change notification settings - Fork 0
/
run.sh
executable file
·65 lines (45 loc) · 1.69 KB
/
run.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
#!/bin/bash
prototxt="models/intel_optimized_models/resnet50_v1/resnet50_int8_perf.prototxt"
iterations=1200
skip=200
NUM_CORE=56
s_BS=10
e_BS=10
INSTANCE=2
rm -rf logs
mkdir logs
rm -f ./temp.sh
for j in $INSTANCE
do
for ((bs = $s_BS; bs <= $e_BS; bs += 1))
do
if [ "$bs" -gt "10" ] && [ "$j" -gt "14" ];then
continue
fi
sed -i "1,/dim/s/dim.*/dim:$bs/" $prototxt
rm -rf logs/bs${bs}_inst$j
mkdir logs/bs${bs}_inst$j
NUM_INSTANCE=$j
INTERVAL=$(($NUM_CORE / $NUM_INSTANCE))
export KMP_HW_SUBSET=1t
export KMP_AFFINITY=granularity=fine,compact,1,0
export OMP_NUM_THREADS=$INTERVAL
sudo sh -c 'echo 3 > /proc/sys/vm/drop_caches'
for ((i = 0; i < $NUM_CORE; i += $INTERVAL))
do
end=$(($i + $INTERVAL - 1))
NUMA_NUM=$(($i/28))
echo "KMP_HW_SUBSET=1T KMP_AFFINITY=granularity=fine,compact,1,0 OMP_NUM_THREADS=$INTERVAL numactl -C $i-$end -m $NUMA_NUM ./build/tools/caffe time --forward_only --phase TEST -model $prototxt -iterations $iterations >logs/bs${bs}_inst${j}/numa$i 2>&1 &" >>temp.sh
done
echo "wait" >>temp.sh
bash ./temp.sh
rm -f logs/bs${bs}_inst${j}/latency
for ((i = 0; i < $NUM_CORE; i += $INTERVAL))
do
grep "###" logs/bs${bs}_inst${j}/numa$i |awk -F' ' '{ print $5 }'|awk -F'#' '{ print $4 }' | awk -F':' -v iter=$iterations -v s=$skip 'BEGIN {sum=0} {if($1>=s && $1<(iter-s)) sum+=$2;} END{ print (sum /(iter-s-s))'} >> logs/bs${bs}_inst${j}/latency
done
latency=$(cat logs/bs${bs}_inst${j}/latency | awk 'BEGIN {sum=0} {sum+=$1} END{print (sum / NR)}')
fps=`echo "1000 * $bs * $j / $latency" | bc `
echo "bs: $bs instance: $j latency: $latency fps: $fps"
done
done