-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnw-loop.sh
executable file
·102 lines (92 loc) · 2.75 KB
/
nw-loop.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
help=false
kernel0=""
kernel1=""
kernel2=""
kernel3=""
title="n, cpu (ms)"
for flag in "$@"
do
case $flag in
-h|--help)
echo "\nUsage: compiles and runs the project in a loop using a predetermined set of values.\n"
echo "Options:"
echo "========\n"
echo "-h, --help --- Shows a list of available flags and explanation of each command"
echo "-a, --all --- Runs code along with all kernels (Does nothing right now)"
echo "-0 --- Runs kernel0 (Does nothing right now)"
echo "-1 --- Runs kernel1 (Does nothing right now)"
echo "-2 --- Runs kernel2 (Does nothing right now)"
echo "-3 --- Runs kernel3 (Does nothing right now)"
help=true
shift
;;
-0)
kernel0="-0"
title="$title, kernel 0 (ms)"
shift
;;
-1)
kernel1="-1"
title="$title, kernel 1 (ms)"
shift
;;
-2)
kernel2="-2"
title="$title, kernel 2 (ms)"
shift
;;
-3)
kernel3="-3"
title="$title, kernel 3 (ms)"
shift
;;
*)
break
;;
esac
done
make
echo $title > benchmark.csv
for i in 10 100 1000 10000; do
j=$(($i/10))
while [ $j -lt $i ]; do
printf "$j, " >> benchmark.csv
output=`./nw -N $j $kernel0 $kernel1 $kernel2 $kernel3 | grep -E "CPU|version" | grep -oE "[0-9]+\.[0-9]+"`
csv=`echo $output | cut -d \ -f 1`
if [ $kernel0 != "" ]
then
csv="$csv, `echo $output | cut -d \ -f 2`"
fi
if [ $kernel1 != "" ]
then
csv="$csv, `echo $output | cut -d \ -f 3`"
fi
if [ $kernel2 != "" ]
then
csv="$csv, `echo $output | cut -d \ -f 4`"
fi
echo $csv >> benchmark.csv
j=$(($j+$i/10))
done
done
j=10000
while [ $j -le 50000 ]; do
printf "$j, " >> benchmark.csv
output=`./nw -N $j $kernel0 $kernel1 $kernel2 $kernel3 | grep -E "CPU|version" | grep -oE "[0-9]+\.[0-9]+"`
csv=`echo $output | cut -d \ -f 1`
if [ $kernel0 != "" ]
then
csv="$csv, `echo $output | cut -d \ -f 2`"
fi
if [ $kernel1 != "" ]
then
csv="$csv, `echo $output | cut -d \ -f 3`"
fi
if [ $kernel2 != "" ]
then
csv="$csv, `echo $output | cut -d \ -f 4`"
fi
echo $csv >> benchmark.csv
j=$(($j+5000))
done
make clean