-
Notifications
You must be signed in to change notification settings - Fork 3
/
wsc-g++
executable file
·145 lines (110 loc) · 4.25 KB
/
wsc-g++
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
#!/bin/bash
# Dynamic linking to WaveScope engine by default? -- 1 or 0
DYNAMICLINK=0
CCARGS=""
FILE=""
SCHEDULER="default-scheduler"
# In the future, consider these optimize flags:
# -falign-functions=n -falign-jumps=n -falign-labels=n -falign-loops=n -fbranch-probabilities -fcaller-saves
# -fcprop-registers -fcse-follow-jumps -fcse-skip-blocks -fdata-sections -fdelayed-branch -fdelete-null-pointer-checks
# -fexpensive-optimizations -ffast-math -ffloat-store -fforce-addr -fforce-mem -ffunction-sections -fgcse -fgcse-lm
# -fgcse-sm -floop-optimize -fcrossjumping -fif-conversion -fif-conversion2 -finline-functions -finline-limit=n
# -fkeep-inline-functions -fkeep-static-consts -fmerge-constants -fmerge-all-constants -fmove-all-movables -fnew-ra
# -fno-branch-count-reg -fno-default-inline -fno-defer-pop -fno-function-cse -fno-guess-branch-probability -fno-inline
# -fno-math-errno -fno-peephole -fno-peephole2 -funsafe-math-optimizations -ffinite-math-only -fno-trapping-math
# -fno-zero-initialized-in-bss -fomit-frame-pointer -foptimize-register-move -foptimize-sibling-calls
# -fprefetch-loop-arrays -freduce-all-givs -fregmove -frename-registers -freorder-blocks -freorder-functions -fre-
# run-cse-after-loop -frerun-loop-opt -fschedule-insns -fschedule-insns2 -fno-sched-interblock -fno-sched-spec
# -fsched-spec-load -fsched-spec-load-dangerous -fsignaling-nans -fsingle-precision-constant -fssa -fssa-ccp
# -fssa-dce -fstrength-reduce -fstrict-aliasing -ftracer -fthread-jumps -funroll-all-loops -funroll-loops --param
if [ "$WSCDEBUG" == "1" ];
then CCARGS="$CCARGS -g ";
COPTFLAG="-O0"
#then CCARGS="$CCARGS -g -O0";
#else CCARGS="$CCARGS -O2";
fi
if [ "$COPTFLAG" == "" ];
then COPTFLAG="-O2"
fi
while [ $# != 0 ]; do
if [ "$1" == "-dynamic" ];
then DYNAMICLINK=1;
elif [ "$1" == "-static" ];
then DYNAMICLINK=0;
elif [ "$1" == "-nothreads" ];
then
echo Configuring for SINGLE THREADED mode.
CCARGS="$CCARGS -DBOOST_SP_DISABLE_THREADS"
elif [ "$1" == "--scheduler" ];
then shift;
SCHEDULER="$1";
elif [ "$1" == "-O2" ] || [ "$1" == "-O3" ] ||
[ "$1" == "-pg" ] || [ "$1" == "-g" ] ;
then CCARGS="$CCARGS $1";
# elif [ `echo $1 | sed` == "-" ]
# then echo "Unknown flag: $1"
else FILE="$1";
fi
shift;
done;
# Now pull extra libraries to link from the first line of the file:
FIRST=`head -n1 "$FILE.cpp"`
MATCH=`echo $FIRST | grep "^//WSLIBDEPS:"`
# -fPIC | -O1/2/3 | -g
#WS_FLAGS="-fPIC -pg $CCARGS"
echo SENDING OFF CCARGS: $CCARGS
WS_FLAGS=" $CCARGS $COPTFLAG"
case $SCHEDULER in
default-scheduler) SCHEDULER_MACRO=""
;;
depth-first) SCHEDULER_MACRO="-DDEPTH_FIRST"
;;
train-scheduler) SCHEDULER_MACRO="-DTRAIN_SCHEDULER"
;;
corefit-scheduler-ex) SCHEDULER_MACRO="-DCOREFIT_SCHEDULER_EX"
;;
corefit-scheduler-df) SCHEDULER_MACRO="-DCOREFIT_SCHEDULER_DF"
;;
esac
#-Wno-div-by-zero ## Doesn't work for C++...
#WS_WARNINGS="-Wall -Werror -Wno-unused-variable -Wno-unused-function "
WS_WARNINGS=""
WS_INCLUDES="-I$WAVESCOPED/include "
WS_MACROS="-DSegList -DuseArray -Di386 $SCHEDULER_MACRO"
# [2007.11.14] Removing this by default: -DTIMING_RDTSC
#WS_LINK="-lfftw3f -lm -lgsl -lgslcblas -lpthread "
WS_LINK=" -lpthread " # -lpapi
if [ "$MATCH" != "" ];
then
EXTRALIBS=`echo $FIRST | sed "s/\/\/WSLIBDEPS://"`
WS_LINK="$WS_LINK $EXTRALIBS"
echo Linking extra libraries requested by query file: $EXTRALIBS
fi
if [ "$WSARCH" == "ensbox" ];
then THELIB=libws-SMSegList_ENSBOX
else THELIB=libws-SMSegList
fi
if [ $DYNAMICLINK == "1" ];
then WS_LINK="$WAVESCOPED/$THELIB.so $WS_LINK";
else WS_LINK="$WAVESCOPED/$THELIB.a $WS_LINK";
fi
WS_ALLARGS=" $WS_FLAGS $WS_WARNINGS $WS_INCLUDES $WS_MACROS "
#echo link: $WS_LINK
echo Compiling .cpp file using g++.
#echo g++ $WS_ALLARGS -o "$FILE.exe" "$FILE.cpp" $WS_LINK;
if [ "$WSGPLUSPLUS" == "" ];
then WSGPLUSPLUS="g++ "
export WSEXESUFFIX="exe"
fi
echo $WSGPLUSPLUS $WS_ALLARGS -o "$FILE"."$WSEXESUFFIX" "$FILE.cpp" $WS_LINK;
start=`date +%s`
if $WSGPLUSPLUS $WS_ALLARGS -o "$FILE"."$WSEXESUFFIX" "$FILE.cpp" $WS_LINK;
then
end=`date +%s`
echo "Time spent in g++: "$[($end) - ($start)]" seconds"
else
echo
echo g++ had errors, aborting.
exit 1;
fi;
#elapsed=$[$start - $end]