-
Notifications
You must be signed in to change notification settings - Fork 0
/
internals.sh
executable file
·123 lines (107 loc) · 3.74 KB
/
internals.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
#!/bin/bash
set -e
# Config parameters, for where to find stuff
XTASK_DIR="${XTASK_DIR:-${HOME}/xtask}"
SWIFT_DIR="${SWIFT_DIR:-${HOME}/swift-t-install}"
# Test params
MAXW=`lscpu | grep '^CPU(s)' | awk '{print $2}'`
RUNS=1
while getopts r:w:x:Xo:Sc:C: o; do
case "${o}" in
w) MAXW=${OPTARG} ;;
r) RUNS=${OPTARG} ;;
x) unset tests["$OPTARG"] ;;
o) tests["$OPTARG"]=1 ;;
X) unset tests[*]; declare -A tests=( ) ;;
c) CFLAGS="${CFLAGS} -${OPTARG}" ;;
C) CC="${OPTARG}" ;;
s) STCFLAGS="${STCFLAGS} -${OPTARG}" ;;
S) DISABLE_STC=1 ;;
esac
done
echo "Using runtimes: ${!tests[*]}"
# Setup the environ
export TURBINE_USER_LIB=$SWIFT_DIR/turbine/lib
export LD_LIBRARY_PATH=$SWIFT_DIR/lb/lib:$SWIFT_DIR/c-utils/lib:$HOME
# Function to compile the different versions of a test
if ! [[ -d bin ]]; then mkdir bin; fi
echo "Compiling C with \${CC} ${CFLAGS:=-O3}"
if [[ -z $DISABLE_STC ]]
then echo "Compiling Swift with \${STC} ${STCFLAGS:=-O3}"
fi
# The timer wrapper
clang $CFLAGS -std=gnu99 time.c -o bin/time
function comp() {
# This isn't actually an imp, it counts tasks. Its... slow.
clang $CFLAGS -std=gnu99 -DUSE_xtask -I$XTASK_DIR/include tests/$1.c \
-o bin/$1.counter -pthread -L$XTASK_DIR -lxtask-counter -lm
# The different XTask implementations
clang $CFLAGS -std=gnu99 -DUSE_xtask -I$XTASK_DIR/include tests/$1.c \
-o bin/$1.jigstack -pthread -L$XTASK_DIR -lxtask-jigstack -lm
#clang $CFLAGS -std=gnu99 -DUSE_xtask -I$XTASK_DIR/include tests/$1.c \
# -o bin/$1.oneatom -pthread -L$XTASK_DIR -lxtask-oneatom -lm
#clang $CFLAGS -std=gnu99 -DUSE_xtask -I$XTASK_DIR/include tests/$1.c \
# -o bin/$1.atomstack -pthread -L$XTASK_DIR -lxtask-atomstack -lm
# The different XTask implementations, but using XData
if [[ -a tests/$1.xd.c ]]; then
clang $CFLAGS -std=gnu99 -DUSE_xtask -I$XTASK_DIR/include tests/$1.xd.c \
-o bin/$1.jigstackxd -pthread -L$XTASK_DIR -lxtask-jigstack -lm
#clang $CFLAGS -std=gnu99 -DUSE_xtask -I$XTASK_DIR/include tests/$1.xd.c \
# -o bin/$1.oneatomxd -pthread -L$XTASK_DIR -lxtask-oneatom -lm
#clang $CFLAGS -std=gnu99 -DUSE_xtask -I$XTASK_DIR/include tests/$1.xd.c \
# -o bin/$1.atomstackxd -pthread -L$XTASK_DIR -lxtask-atomstack -lm
fi
# OpenMP, baseline parallel competitor
clang $CFLAGS -std=gnu99 -DUSE_openmp tests/$1.c -o bin/$1.openmp \
-fopenmp -lm
# Cilk, like OpenMP but Intel-grown.
gcc $CFLAGS -std=gnu99 -DUSE_cilk tests/$1.c -o bin/$1.cilk -fcilkplus -lm
# Single-threaded, currently best-case.
clang $CFLAGS -std=gnu99 -DUSE_single -o bin/$1.single tests/$1.c -lm
# Swift/T. The tortise.
if [[ -z "$DISABLE_STC" ]]
then $SWIFT_DIR/stc/bin/stc $STCFLAGS tests/$1.swift bin/$1.tic \
|| echo STC failed, ignoring...
fi
}
# Function to run a test
if ! [[ -d out ]]; then mkdir out; fi
function run() {
C="$2"
T="$1"
shift 2
if [[ ${tests["$T"]} ]]; then
if [[ ${#T} -le 5 ]]; then AL="\\t\\t"; else AL="\\t"; fi
echo -en "[$T]${AL}Counting for test $C..."
args=( "${@/\{\}/1}" )
TCNT=`bin/"$C".counter "${args[@]/=/}" |& grep '^TASKCOUNT' \
| awk '{print $2}'`
echo " $TCNT tasks"
CMD=bin/"$C.$T"
MINW=1
if [[ $T = swiftt ]]; then
CMD="$SWIFT_DIR/turbine/bin/turbine -n {} bin/$C.tic"
MINW=2
elif [[ $T = xtasklua ]]; then
CMD="lua5.3 -e package.cpath='$XTASK_DIR/?.so' tests/$C.lua"
fi
echo -en "[$T]${AL} Running test $C..."
ERR=
for n in `seq $MINW $MAXW`; do
for r in `seq 1 $RUNS`; do
echo "${CMD/\{\}/$n} ${@/\{\}/$n}" >&2
echo -n "$n "
bin/time ${CMD/\{\}/$n} "${@/\{\}/$n}" \
|| echo ERR
echo >&2
done
done 2> out/tmp.log | lua5.3 data.lua "$TCNT" > out/"$C-$T".dat | :
X=${PIPESTATUS[1]}
if [[ $X -ne 0 ]]; then
echo "Error while running test (code $X):"
cat out/tmp.log
rm out/tmp.log
exit 1
else rm out/tmp.log; fi
fi
}