-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbenchmark_gpu.sh
executable file
·176 lines (160 loc) · 4.94 KB
/
benchmark_gpu.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
#!/bin/bash
gpu=V100
type=blk3d
iter=5
size=1024
indexes=$(($size * 256 * 1024))
sqrt=`echo "e(l($indexes)/2)" | bc -l`
cbrt=`echo "e(l($indexes)/3)" | bc -l`
dim_x_2d=`echo "x=l($sqrt)/l(2); scale=0; if (x%1 != 0) x = (x + 1); x = (x / 1); 2 ^ x" | bc -l`
dim_y_2d=$(( $indexes / $dim_x_2d ))
dim_x_3d=`echo "x=l($cbrt)/l(2); scale=0; if (x%1 != 0) x = (x + 1); x = (x / 1); 2 ^ x" | bc -l`
dim_y_3d=$dim_x_3d
dim_z_3d=$(( $indexes / ($dim_x_3d * dim_y_3d) ))
size_switch=""
verify=""
pad_start=0
pad_end=0
pad_array=(0)
overlap=0
halo_start=0
halo_end=0
halo_step=1
halo_switch=""
halo_array=(0)
if [[ "$1" == "--verify" ]] || [[ "$2" == "--verify" ]] || [[ "$3" == "--verify" ]]
then
verify="--verify"
fi
if [[ "$1" == "--pad" ]] || [[ "$2" == "--pad" ]] || [[ "$3" == "--pad" ]]
then
if [[ "$type" == "blk3d" ]]
then
pad_end=8
pad_array=(0 1 2 4 8)
else
pad_end=32
pad_array=(0 1 2 4 8 16 32)
fi
fi
if [[ "$1" == "--halo" ]] || [[ "$2" == "--halo" ]] || [[ "$3" == "--halo" ]]
then
if [[ "$type" == "blk3d" ]]
then
halo_end=8
halo_array=(0 1 2 4 8)
else
halo_end=32
halo_array=(0 1 2 4 8 16 32)
fi
fi
echo "Type" | xargs printf "%-9s"
echo "Size" | xargs printf "%-15s"
echo "Pad" | xargs printf "%-6s"
echo "Halo" | xargs printf "%-6s"
echo "Redundancy" | xargs printf "%-12s"
echo "Performance\ (GB/s)" | xargs printf "%-41s"
echo "Efficiency\ (%)" | xargs printf "%-31s"
if [[ "$verify" == "--verify" ]]
then
echo "Verification" | xargs printf "%-11s"
fi
echo
ndr=1
VEC=1
if [[ $gpu == "V100" ]]
then
if [[ "$type" == "blk3d" ]]
then
BSIZE=32
else
BSIZE=512
fi
gpu_id=1
max_bw=897.0
else
if [[ "$type" == "blk3d" ]]
then
BSIZE=32
else
BSIZE=128
fi
gpu_id=2
max_bw=249.6
fi
make clean >/dev/null 2>&1; make $type NVIDIA=1 VEC=$VEC BSIZE=$BSIZE NDR=$ndr >/dev/null 2>&1
#for ((halo = $halo_start ; halo <= $halo_end ; halo += $halo_step))
for halo in "${halo_array[@]}"
do
compute_bsize_x=$(( $BSIZE - (2 * $halo) ))
compute_bsize_y=$(( $BSIZE - (2 * $halo) ))
dim_x_2d_aligned=$(( ($dim_x_2d % $compute_bsize_x) == 0 ? $dim_x_2d : ($dim_x_2d + $compute_bsize_x - $dim_x_2d % $compute_bsize_x) ))
dim_x_3d_aligned=$(( ($dim_x_3d % $compute_bsize_x) == 0 ? $dim_x_3d : ($dim_x_3d + $compute_bsize_x - $dim_x_3d % $compute_bsize_x) ))
dim_y_3d_aligned=$(( ($dim_y_3d % $compute_bsize_y) == 0 ? $dim_y_3d : ($dim_y_3d + $compute_bsize_y - $dim_y_3d % $compute_bsize_y) ))
if [[ "$type" == "std" ]]
then
halo_switch="-hw $halo"
size_switch="-s $size"
dim=$size
elif [[ "$type" == "blk2d" ]]
then
halo_switch="-hw $halo"
size_switch="-x $dim_x_2d_aligned -y $dim_y_2d"
dim=`echo "$dim_x_2d_aligned"x"$dim_y_2d"`
elif [[ "$type" == "blk3d" ]]
then
halo_switch="-hw $halo"
size_switch="-x $dim_x_3d_aligned -y $dim_y_3d_aligned -z $dim_z_3d"
dim=`echo "$dim_x_3d_aligned"x"$dim_y_3d_aligned"x"$dim_z_3d"`
else
size_switch="-s $size"
dim=$size
fi
#for ((pad = $pad_start ; pad <= $pad_end ; pad++))
for pad in "${pad_array[@]}"
do
out=`DEVICE_TYPE=GPU ./fpga-mem-bench $size_switch -n $iter -pad $pad $halo_switch -id $gpu_id $verify 2>&1`
#echo "$out" >> ast.txt
redundancy=`echo "$out" | grep "Redundancy:" | cut -d " " -f 2`
R1W1=`echo "$out" | grep "R1W1:" | cut -d " " -f 2`
R2W1=`echo "$out" | grep "R2W1:" | cut -d " " -f 2`
R3W1=`echo "$out" | grep "R3W1:" | cut -d " " -f 2`
R2W2=`echo "$out" | grep "R2W2:" | cut -d " " -f 2`
R1W1_eff=`echo "100 * ($R1W1/$max_bw)" | bc -l | xargs printf %0.1f`
R2W1_eff=`echo "100 * ($R2W1/$max_bw)" | bc -l | xargs printf %0.1f`
R3W1_eff=`echo "100 * ($R3W1/$max_bw)" | bc -l | xargs printf %0.1f`
R2W2_eff=`echo "100 * ($R2W2/$max_bw)" | bc -l | xargs printf %0.1f`
R1W1_ver=`echo "$out" | grep Verify | grep R1W1 | cut -d " " -f 4 | cut -c 1-1`
R2W1_ver=`echo "$out" | grep Verify | grep R2W1 | cut -d " " -f 4 | cut -c 1-1`
R3W1_ver=`echo "$out" | grep Verify | grep R3W1 | cut -d " " -f 4 | cut -c 1-1`
R2W2_ver=`echo "$out" | grep Verify | grep R2W2 | cut -d " " -f 4 | cut -c 1-1`
if [[ "$type" == "std" ]]
then
R1W0=`echo "$out" | grep "R1W0:" | cut -d " " -f 2`
R1W0_eff=`echo "100 * ($R1W0/$max_bw)" | bc -l | xargs printf %0.1f`
R1W0_ver=`echo "N/A"`
fi
echo $type | tr '[:lower:]' '[:upper:]' | xargs printf "%-9s"
echo $dim | xargs printf "%-15s"
echo $pad | xargs printf "%-6s"
echo $halo | xargs printf "%-6s"
echo $redundancy | xargs printf "%-12s"
if [[ "$type" == "std" ]]
then
echo "$R1W0|$R1W1|$R2W1|$R3W1|$R2W2" | xargs printf "%-41s"
echo "$R1W0_eff|$R1W1_eff|$R2W1_eff|$R3W1_eff|$R2W2_eff" | xargs printf "%-31s"
if [[ "$verify" == "--verify" ]]
then
echo "$R1W0_ver|$R1W1_ver|$R2W1_ver|$R3W1_ver|$R2W2_ver" | xargs printf "%-11s"
fi
else
echo "$R1W1|$R2W1|$R3W1|$R2W2" | xargs printf "%-41s"
echo "$R1W1_eff|$R2W1_eff|$R3W1_eff|$R2W2_eff" | xargs printf "%-31s"
if [[ "$verify" == "--verify" ]]
then
echo "$R1W1_ver|$R2W1_ver|$R3W1_ver|$R2W2_ver" | xargs printf "%-11s"
fi
fi
echo
done
done