forked from neboat/cilkbench
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testMiniFE.sh
171 lines (158 loc) · 4.35 KB
/
testMiniFE.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
#!/usr/bin/env bash
TESTDIR="./miniFE/src"
source configureTests.sh
source parseArgs.sh
ALLTESTS="miniFE.x"
TEST_RUN_ARGS () {
case $1 in
"miniFE.x") echo "--nx 200 --ny 200 --nz 200";;
*) echo "INVALID CODE CASE $1"; exit;;
esac
}
CHECK_RUN_ARGS () {
case $1 in
"miniFE.x") echo "--nx 100 --ny 100 --nz 100";;
*) echo "INVALID CODE CASE $1"; exit;;
esac
}
MY_EXTRA_CFLAGS() {
echo ""
# case $1 in
# "tapir") echo "-g";; # -DPIR";;
# "ref") echo "-g";;
# "stapir") echo "-g";;
# "sref") echo "-g";;
# "serial") echo "-g";;
# "gcc") echo "-g";;
# "sgcc") echo "-g";;
# *) echo "Unknown compiler $1"; exit 1;;
# esac
}
CompileTest() {
Compiler=$1
Test=$2
Results=Compile-$Compiler-$Test.txt
rm -rf $Results
echo "<Compiling $Test with $Compiler>"
make clean
(CC=$(C_COMPILER $Compiler) \
CXX=$(CXX_COMPILER $Compiler) \
CILKFLAG=$(CILKFLAG $Compiler) \
EXTRA_CFLAGS="$(MY_EXTRA_CFLAGS $Compiler) $EXTRA_CFLAGS"\
EXTRA_CXXFLAGS="$(MY_EXTRA_CFLAGS $Compiler) $EXTRA_CFLAGS"\
OMPI_MPICXX=$CXX make -B > $Results 2>&1)
if [[ $? -ne "0" ]]; then
echo "<FAILED>"
fi
return $?
}
RaceDetectTest() {
Compiler=$1
Test=$2
Results=Cilksan-Compile-$Compiler-$Test.txt
rm -rf $Results
echo "<Compiling $Test with $Compiler for race detection>"
make clean
(CC=$(C_COMPILER $Compiler) \
CXX=$(CXX_COMPILER $Compiler) \
CILKFLAG=$(CILKFLAG $Compiler) \
EXTRA_CFLAGS="$CILKSAN_CFLAGS" \
EXTRA_CXXFLAGS="$CILKSAN_CFLAGS" \
EXTRA_LDFLAGS="$CILKSAN_LDFLAGS" \
OMPI_MPICXX=$CXX make -B > $Results 2>&1)
if [[ $? -ne "0" ]]; then
echo "<FAILED>"
else
echo "<Race-detecting $Test with $Compiler>"
LD_LIBRARY_PATH=$CILKSAN_LIB:$LD_LIBRARY_PATH ./$Test
if [[ $? -ne "0" ]]; then
echo "<FAILED>"
fi
fi
return $?
}
ScalabilityTest() {
Compiler=$1
Test=$2
Results=Cilkscale-Compile-$Compiler-$Test.txt
rm -rf $Results
echo "<Compiling $Test with $Compiler for scalability analysis>"
make clean
(CC=$(C_COMPILER $Compiler) \
CXX=$(CXX_COMPILER $Compiler) \
CILKFLAG=$(CILKFLAG $Compiler) \
EXTRA_CFLAGS="$CILKSCALE_CFLAGS" \
EXTRA_CXXFLAGS="$CILKSCALE_CFLAGS" \
EXTRA_LDFLAGS="$CILKSCALE_LDFLAGS" \
EXTRA_LDLIBS="$CILKSCALE_LDLIBS" \
OMPI_MPICXX=$CXX make -B > $Results 2>&1)
if [[ $? -ne "0" ]]; then
echo "<FAILED>"
else
echo "<Analyzing scalability of $Test with $Compiler>"
./$Test $(TEST_RUN_ARGS $Test)
if [[ $? -ne "0" ]]; then
echo "<FAILED>"
fi
fi
return $?
}
RunTest() {
Compiler=$1
Test=$2
Worker=$3
Trials=$4
Results=Run-$Compiler-$Test-$Worker.txt
rm -rf $Results
Failed=0
if [[ $CHECK_CORRECTNESS -ne 0 ]]; then
echo "CILK_NWORKERS=$Worker ./$Test $(CHECK_RUN_ARGS $Test)"
CILK_NWORKERS=$Worker ./$Test $(CHECK_RUN_ARGS $Test)
fi
# echo "CILK_NWORKERS=$Worker taskset -c 0-$(($Worker-1)) numactl -i all ./$Test $(TEST_RUN_ARGS $Test) >> $Results 2>&1"
# (RUN_ON_P_WORKERS $Worker "./$Test $(TEST_RUN_ARGS $Test)")
for Trial in `seq 1 $Trials`; do
# CILK_NWORKERS=$Worker taskset -c 0-$(($Worker-1)) numactl -i all ./$Test $(TEST_RUN_ARGS $Test) >> $Results 2>&1
time (RUN_ON_P_WORKERS $Worker "./$Test $(TEST_RUN_ARGS $Test)") >> $Results 2>&1
Failed=$Failed||$?
done
# Report failure or sorted running times.
if [[ $Failed -ne 0 ]]; then
echo "<FAILED>"
else
echo "<$Compiler $Test $Worker>"
grep "real" $Results | sort -bn | sed '/^\s*$/d' | head -n $Trials
fi
return $Failed
}
# if [[ "" == "$ALLTESTS" ]]; then
# usage
# fi
# Die if anything produces an error
set -e
for Test in $ALLTESTS; do
pushd $TESTDIR
for Compiler in $COMPILERS_TO_TEST; do
WORKERS=$WORKERS_TO_TEST
if [[ ($Compiler == "stapir") ||
($Compiler == "sref") ||
($Compiler == "serial") ||
($Compiler == "sgcc") ]]; then
WORKERS="1"
fi
CompileTest $Compiler $Test
if [[ $? -ne 0 ]]; then break; fi
if [[ $CHECK_CILKSAN -ne 0 ]]; then
RaceDetectTest $Compiler $Test
CompileTest $Compiler $Test
fi
if [[ $CHECK_CILKSCALE -ne 0 ]]; then
ScalabilityTest $Compiler $Test
CompileTest $Compiler $Test
fi
for Worker in $WORKERS; do
RunTest $Compiler $Test $Worker $NUMTRIALS
done
done
popd
done