-
Notifications
You must be signed in to change notification settings - Fork 0
/
testLangs.sh
executable file
·153 lines (124 loc) · 4.42 KB
/
testLangs.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
#!/bin/bash
#
# Compiler sanity check, tests the following:
# (1) The C (LAR) back-end: tagged Susp values, the -enum transformation,
# numerical and data benchmarks, polymorphism (including GADTs),
# the OpenMP-based runtime, and arbitrary precision integers (with libgmp).
# The tests use the lar_opt.h representation and garbage collection with libgc.
# (2) The 0-order call-by-name interpreter (intensional with context dictionaries).
# (3) The FL non-strict interpreter (with non-strict activation records).
# (4) The 0-order lazy eduction interpreter (intensional with a warehouse).
#
GHCI_FLAGS="-v0 -w -XGADTs"
export GICFLAGS="-gic-tc"
source find-gic.sh
echo "Using GIC=${GIC}"
if [ -x "$(command -v stack)" ]; then
GHCI=`stack path --compiler-bin`/ghci
else
GHCI="ghci"
fi
echo "Using GHCI=${GHCI}"
############# Test tags
echo Testing -tag...
TAG_EXAMPLE=Examples/Data/example2.hs
CFLAGS2="-DUSE_TAGS" ./run_lar.sh -tag ${TAG_EXAMPLE}
echo "result" | ${GHCI} ${GHCI_FLAGS} ${TAG_EXAMPLE}
unset CFLAGS2
############# Test -enum type transformation
echo Testing -enum...
TAG_EXAMPLE=Examples/Data/example2.hs
CC=gcc ./run_lar.sh -enum ${TAG_EXAMPLE}
echo "result" | ${GHCI} ${GHCI_FLAGS} ${TAG_EXAMPLE}
############# Test arbitrary precision integers
echo Testing Integer...
INTEGER_EXAMPLE=Examples/Num/bigints.hs
INTEGER_EXAMPLE2=${INTEGER_EXAMPLE}.x.hs
echo ${INTEGER_EXAMPLE}, LAR:
CC=gcc ./run_lar.sh -gic-tc-nsig ${INTEGER_EXAMPLE}
echo -n ${INTEGER_EXAMPLE}, GHCi:
# replace custom multiplication operator with * for GHC
cat ${INTEGER_EXAMPLE} | sed -e "s/\`mulI\`/*/" > ${INTEGER_EXAMPLE2}
echo "result" | ${GHCI} ${GHCI_FLAGS} ${INTEGER_EXAMPLE2}
rm ${INTEGER_EXAMPLE2}
############# Tests the TTD emulator
echo -- TTD emulator --
for file in Examples/Num/exmh1.hs Examples/Num/memoize.hs Examples/Data/example1.hs Examples/Data/example2.hs
do
echo -n ${file}, TTD emulator:\
${GIC} ${GICFLAGS} -ettd -workers 100 ${file}
echo -n ${file}, GHCi:\
echo "result" | ${GHCI} ${GHCI_FLAGS} ${file}
done
############# Tests the call-by-name eduction interpreter
echo -- Call-by-name eduction --
for file in Examples/Num/memoize.hs Examples/Data/example1.hs Examples/Data/addsx.hs Examples/Data/biglist.hs Examples/Data/records.hs Examples/Data/unit.hs
do
echo -n ${file}, call-by-name eduction:\
${GIC} ${GICFLAGS} -ecbn ${file}
echo -n ${file}, GHCi:\
echo "result" | ${GHCI} ${GHCI_FLAGS} ${file}
done
############# Tests the non-strict FL interpreter
echo -- Non-strict FL interpreter --
for file in Examples/Num/memoize.hs Examples/Data/example1.hs Examples/Data/addsx.hs Examples/Data/biglist.hs Examples/Data/records.hs Examples/Data/unit.hs Examples/Data/addsx.hs
do
echo -n ${file}, non-strict FL interpreter:\
${GIC} ${GICFLAGS} -fl ${file}
echo -n ${file}, GHCi:\
echo "result" | ${GHCI} ${GHCI_FLAGS} ${file}
done
############# Tests the lazy eduction interpreter
echo -- Lazy eduction --
for file in Examples/Num/memoize.hs Examples/Data/example1.hs Examples/Data/addsx.hs Examples/Data/biglist.hs Examples/Data/nested.hs Examples/Data/records.hs Examples/Data/unit.hs
do
echo -n ${file}, lazy eduction:\
${GIC} ${GICFLAGS} -e ${file}
echo -n ${file}, GHCi:\
echo "result" | ${GHCI} ${GHCI_FLAGS} ${file}
done
############# Compares the results from the LAR back-end against those from GHCi
ulimit -s 262143
function testLAR {
#echo Testing file ${file}...
echo -n $1, GHCi\ \ \ \ \ \ :\
echo "result" | ${GHCI} ${GHCI_FLAGS} $1
# echo -n $1, LAR, libgc:\
# ./run_libgc.sh $1
# echo -n $1, LAR, semi:\
# ./run_lar.sh -mem 1280000000 $1
echo -n $1, LAR, compact-semi:\
CFLAGS2="-w" ./run_lar.sh -mem 2280000000 -tco -compact $1
}
# Use the single-threaded runtime.
unset OMP
echo -- LAR --
echo -- 1. Simple types --
export GICFLAGS="-gic-tc-nsig"
for file in Examples/Num/exmh*.hs Examples/Num/myex*.hs Examples/Data/*.hs
do
testLAR ${file}
done
echo -- 2. Polymorphic --
# Use the type checker of the GHC API and explicit type signatures.
export GICFLAGS=-ghc-tc
for file in Examples/Polymorphic/*.hs
do
testLAR ${file}
done
echo -- 3. GADTs --
export GICFLAGS=-ghc-tc
for file in Examples/GADT/*.hs
do
testLAR ${file}
done
echo -- 4. Parallel --
# Use the built-in type checker, ignore type signatures.
export GICFLAGS=-gic-tc-nsig
# Use the OpenMP-based runtime.
export OMP=1
GHCIFLAGS="${GHCIFLAGS} -threaded"
for file in Examples/Parallel/*.hs
do
testLAR ${file}
done