-
Notifications
You must be signed in to change notification settings - Fork 3
/
wsc2
executable file
·164 lines (118 loc) · 4.32 KB
/
wsc2
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
#!/bin/bash
export WSVARIANT=wsc2
export REGFLAG=$WSVARIANT
source `dirname $0`/assert_regimentd
# Get out only the relevant options:
RELEVANT=`getopt -a -l "v:,main:,ss:,sigseg:,gc:,gcc:,o:,limitcpus,cpus:,D:,realtime,tbb,threads,noprelude,nothreads,nogcc,no-gcc,tree,O0,O1,O2,O3,dbg" -o ":" -- "$@"`
#RELEVANT=`getopt -a "ss:,sigseg:,gc:,gcc:,cpus:,D:,realtime,threads,nothreads,nogcc,no-gcc,O0,O1,O2,O3" -o ":" -- "$@"`
#echo wsc2 getopt result: $RELEVANT
# I would like to pass only the relevant options on to "wsc", but I
# can't currently get getopt to do everything I want it to, i.e. pass
# through everything not handled in after the "--".
# [2008.08.18] Make sure to use the one stored in the same directory.
WSC=`dirname $0`/wsc
#================================================================================
#echo CALLING WSC $WSC $* -exit-error -no-gcc
rm -f query.c query_*.c query.exe query_*.exe
if $WSC $* -no-gcc
then echo
else CODE=$?
echo ERROR, wsc2 failed with code $CODE.
exit $CODE;
fi
# Now the compile is finished
#================================================================================
## TEMP: PTHREADS BY DEFAULT :
#THREADS=true
eval set -- "$RELEVANT"
NOGCC=
while [ $# != 0 ]; do
#for flag in $RELEVANT; do
flag=$1
# echo Handling flag: $flag
case $flag in
# Sadly duplicating the COPTFLAG business because no way for "wsc" to pass the env vars back up.
"--O0" ) COPTFLAG="$flag";;
"--O1" ) COPTFLAG="$flag";;
"--O2" ) COPTFLAG="$flag";;
"--O3" ) COPTFLAG="$flag";;
"--dbg" ) COPTFLAG="$flag";;
"--tbb" ) THREADS=true;; # -tbb implies -threads
"--threads" ) THREADS=true;;
"--nothreads") THREADS="";;
"--nogcc" | "--no-gcc" ) NOGCC=true;;
"--gcc" ) export CC="$2"; shift;;
"--limitcpus") export WS_LINK+=" -DLIMITCPUS "; shift;;
# "--cpus") export WS_LINK+=" -DLIMITCPUS ";
# TEMP=$2;
# export LIMITCPUS="$((TEMP-1))";
# shift;;
"--D" ) export WS_LINK="$WS_LINK -D$2"; shift;;
"--o" ) export CFILE="$2"; shift;;
# This option bypasses the (scheme) compiler and affects the generated code:
"--realtime" ) export WS_LINK="$WS_LINK -DWS_REAL_TIMERS ";;
"--" ) break;;
# *) echo " Uh, unhandled...";;
esac;
shift;
done
export COPTFLAG
#echo WITH CFILE $CFILE
#exit
#echo After parsing args, WS_LINK is $WS_LINK
if ! [ "$THREADS" = "" ];
then export WS_LINK="$WS_LINK -DWS_THREADED -lpthread ";
fi
if [ "$CC" = "icc" ] || ([ "$CC" = "" ] && [ "`which icc`" != "" ])
# Could do -static also:
#then export CC='icc -O3 -ipo -no-prec-div'
then export CC='icc -ipo -no-prec-div'
fi
if [ "$CFILE" = "" ]; then CFILE=query; fi
rm -f "$CFILE".exe "$CFILE"_*.exe
for file in `ls "$CFILE"*.c 2> /dev/null`; do
export CFILE=$file
$REGIMENTD/bin/wsc2-gcc
CODE=$?
if [ "$CODE" != "0" ]; then exit $CODE; fi
done
# if ! [ -f "query.c" ]
# then echo "query.c not found..."
# elif [ $NOGCC ]
# then echo "Not calling C compiler."; exit 0
# else exec wsc2-gcc
# fi
## Run again to profile branches:
# ./query.exe
# CMD="gcc $OPTFLAGS -o query.exe $WS_LINK query.c -fbranch-probabilities"
# echo $CMD; $CMD
# GCC flags not enabled by -O3:
# -fforce-addr
# -funroll-loops / unroll-all-loops
# -finline-limit=
# -fno-keep-static-consts
# -fmerge-all-constants (non conforming behavior)
# -fsched-spec-load
# -fsched-spec-load-dangerous
# -fmove-all-movables
# -fbranch-probabilities
# -fno-guess-branch-probability
# -fprefetch-loop-arrays
# Experimental:
# -fnew-ra - Experimental register allocator
# -ftracer
# -fssa - not ready for productio use
# -ffunction-sections -fdata-sections -- place functions and data into their own sections, helps linker.
# Our array representation is going to require disabling:
# -fstrict-aliasing
# May or may not increase performance (might disable)
# -fcrossjumping
# -freduce-all-givs
# -falign-labels
# DANGER opts that must be turned on by hand, breaks IEEE math.
# -ffast-math
# -fno-math-errno
# -funsafe-math-optimizations
# -ffinite-math-only - disable handling of NANs and INFs
# -fno-trapping-math - don't worry about DIV zero and so on
# -fsingle-precision-constant