-
Notifications
You must be signed in to change notification settings - Fork 8
/
test.sh
executable file
·211 lines (190 loc) · 4.07 KB
/
test.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
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
#! /usr/bin/env bash
source test-lib.sh
# Get config file options
SIMTIGHT_ROOT=`realpath ../`
CONFIG_H="$SIMTIGHT_ROOT/inc/Config.h"
FP_EN=`echo -n EnableFP | cpp -P -imacros $CONFIG_H - | xargs`
APPS=(
Samples/VecAdd
Samples/Histogram
Samples/Reduce
Samples/Scan
Samples/Transpose
Samples/MatVecMul
Samples/MatMul
Samples/BitonicSortSmall
Samples/BitonicSortLarge
Samples/SparseMatVecMul
InHouse/BlockedStencil
InHouse/StripedStencil
InHouse/VecGCD
InHouse/MotionEst
)
if [ "$FP_EN" == "1" ]; then
APPS+=(Samples/BitonicSortLarge_Float)
APPS+=(Samples/MatMul_Float)
fi
# Options
# =======
TestSim=
TestFPGA=
NoPgm=
AppsOnly=
LogSim=
EmitStats=
SkipTests=
SkipCPU=
# Arguments
# =========
while :
do
case $1 in
-h|--help)
echo "Run test-suite and example apps"
echo " --sim run in simulation (verilator)"
echo " --fpga-d run on FPGA (de10-pro revD)"
echo " --fpga-e run on FPGA (de10-pro revE)"
echo " --no-pgm don't reprogram FPGA"
echo " --apps-only run apps only (not test-suite)"
echo " --log-sim log simulator output to sim-log.txt"
echo " --stats emit performance stats"
echo " --skip-tests skip riscv-tests"
echo " --skip-cpu skip CPU testing"
exit
;;
--sim)
TestSim=yup
;;
--fpga-d)
TestFPGA=yup-d
;;
--fpga-e)
TestFPGA=yup-e
;;
--no-pgm)
NoPgm=yup
;;
--apps-only)
AppsOnly=yup
;;
--log-sim)
LogSim=yup
;;
--stats)
EmitStats=yup
;;
--skip-tests)
SkipTests=yup
;;
--skip-cpu)
SkipCPU=yup
;;
-?*)
printf 'Ignoring unknown flag: %s\n' "$1" >&2
;;
--)
shift
break
;;
*)
break
esac
shift
done
if [ "$TestSim" == "" ] && [ "$TestFPGA" == "" ]; then
TestSim=yup
fi
# Preparation
# ===========
# Prepare simulator
SIM_PID=
SIM_LOG_FILE=`pwd`/sim-log.txt
if [ "$TestSim" != "" ]; then
prepare_sim
fi
# Prepare FPGA
if [ "$TestFPGA" != "" ]; then
prepare_fpga
fi
# Test Suite
# ==========
if [ "$SkipTests" == "" ]; then
# In simulation
if [[ "$TestSim" != "" && "$AppsOnly" == "" ]]; then
if [ "$SkipCPU" == "" ]; then
echo "Test Suite (CPU, Simulation)"
echo "============================"
echo
make -s -C ../apps/TestSuite test-cpu-sim
assert $? "\nSummary: "
echo
fi
echo "Test Suite (SIMT Core, Simulation)"
echo "=================================="
echo
make -s -C ../apps/TestSuite test-simt-sim
assert $? "\nSummary: "
echo
fi
# On FPGA
if [[ "$TestFPGA" != "" && "$AppsOnly" == "" ]] ; then
echo "Test Suite (CPU, FPGA)"
echo "======================"
echo
make -s -C ../apps/TestSuite test-cpu
assert $? "\nSummary: "
echo
echo "Test Suite (SIMT Core, FPGA)"
echo "============================"
echo
make -s -C ../apps/TestSuite test-simt
assert $? "\nSummary: "
echo
fi
fi
# Sample Apps
# ===========
# Function to run app and check success (and emit stats)
checkApp() {
local Run=$1
local APP=$2
local tmpDir=$3
local APP_MANGLED=$(echo $APP | tr '/' '-')
local tmpLog=$tmpDir/$APP_MANGLED.log
$(cd ../apps/$APP && $Run > $tmpLog)
getStats $tmpLog
}
# In simulation
if [ "$TestSim" != "" ]; then
echo "Apps (Simulation)"
echo "================="
echo
if [ "$EmitStats" != "" ]; then
echo "(NOTE: simulation stats can be misleading due to tiny workloads)"
echo
fi
tmpDir=$(mktemp -d -t simtight-test-XXXX)
for APP in ${APPS[@]}; do
echo -n "$APP (build): "
make -s -C ../apps/$APP RunSim
assert $?
echo -n "$APP (run): "
checkApp ./RunSim $APP $tmpDir
done
fi
# On FPGA
if [ "$TestFPGA" != "" ] ; then
echo "Apps (FPGA)"
echo "==========="
echo
tmpDir=$(mktemp -d -t simtight-test-XXXX)
for APP in ${APPS[@]}; do
echo -n "$APP (build): "
make -s -C ../apps/$APP Run
assert $?
echo -n "$APP (run): "
checkApp ./Run $APP $tmpDir
done
fi
echo
echo "All tests passed"