-
Notifications
You must be signed in to change notification settings - Fork 0
/
setup_env.sh
209 lines (166 loc) · 6.11 KB
/
setup_env.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
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
#!/bin/bash
# To Build: http://mageec.org/wiki/Building_MILEPOST
BASE_DIR=~/tools/ctuning-cc-2.5-gcc-4.4.4-ici-2.05-milepost-2.1
WORKING_DIR=$PWD
#pathadd function source:
#http://superuser.com/questions/39751/add-directory-to-path-if-its-not-already-there
pathadd() {
if [ -d "$1" ] && [[ ":$PATH:" != *":$1:"* ]]; then
PATH="$1:${PATH:+"$PATH"}"
fi
}
# Check php is installed
command -v php > /dev/null 2>&1 || { echo >&2 "PHP not installed"; exit 1; }
# (EDITED) _set_environment_for_analyis_compiler__milepost_gcc.sh
BUILD_EXT=install
BUILD_DIR=$BASE_DIR/$BUILD_EXT
PWD_SAVE=PWD
pathadd $BUILD_DIR/bin
pathadd $BASE_DIR/ccc-framework/src-plat-indep/plugins
export LD_LIBRARY_PATH=$BUILD_DIR/lib:$BUILD_DIR/lib64:$LD_LIBRARY_PATH
#set MILEPOST compiler names (in the future it may be some other compiler
#that supports ICI and plugins)
export CTUNING_ANALYSIS_CC=gcc
export CTUNING_ANALYSIS_CPP=g++
export CTUNING_ANALYSIS_FORTRAN=gfortran
#ICI PLUGINS
export ICI2_PLUGIN_VER=gcc-plugin-ici2
export ICI_LIB=$BUILD_DIR/lib
export ICI_PLUGIN_VER=$ICI2_PLUGIN_VER
export CCC_ICI_USE=ICI_USE
export CCC_ICI_PLUGINS=ICI_PLUGIN
export CCC_ICI_PASSES_FN=ici_passes_function
export CCC_ICI_PASSES_EXT=.txt
#export CCC_ICI_PASSES_RECORD_PLUGIN=$ICI_LIB/$ICI_PLUGIN_VER-save-executed-passes.so
export CCC_ICI_PASSES_RECORD_PLUGIN=$ICI_LIB/$ICI_PLUGIN_VER-extract-program-structure.so
export CCC_ICI_FEATURES_ST_FN=ici_features_function
export CCC_ICI_FEATURES_ST_EXT=.ft
export CCC_ICI_FEATURES_ST_EXTRACT_PLUGIN=$ICI_LIB/$ICI_PLUGIN_VER-extract-program-static-features.so
export ICI_PROG_FEAT_PASS=fre
export ML_ST_FEAT_TOOL=$BUILD_DIR/bin/featlstn.P
export XSB_DIR="$BUILD_DIR/3.2"
export ICI_PROG_FEAT_EXT_TOOL=$BUILD_DIR/bin/ml-feat-proc
export CCC_ROOT=$BASE_DIR/ccc-framework
export CCC_PLUGINS=$CCC_ROOT/src-plat-indep/
export PATH=$CCC_ROOT/src-plat-indep/plugins:$PATH
export CCC_UUID=uuidgen
# End of _set_environment_for_analysis_compiler__milepost_gcc.sh
# Check CCC_UUID is correctly set
if [ ! $(command -v $CCC_UUID) ]; then
if [ $(command -v uuidgen) ]; then
UUID_COMMAND=uuidgen
elif [ $(command -v uuid) ]; then
UUID_COMMAND=uuid
fi
if [ -z $UUID_COMMAND ]; then
echo 'Cannot find a valid uuid generator'
echo 'Please install one or correctly set CCC_UUID in this script'
exit 1
else
echo "Setting CCC_UUID to $UUID_COMMAND"
echo 'This should also be changed in this script'
export CCC_UUID=$UUID_COMMAND
fi
fi
# (EDITED) ___common_environment.sh
export ICI_PLUGIN_VERBOSE=1
export ICI_VERBOSE=1
export ICI_PROG_FEAT_PASS=fre
#set cTuning web-service parameters
export CCC_CTS_URL=cTuning.org/wiki/index.php/Special:CDatabase?request=
#export CCC_CTS_URL=localhost/cTuning/wiki/index.php/Special:CDatabase?request=
export CCC_CTS_DB=fursinne_coptcasestest
#set cTuning username (self-register at http://cTuning.org/wiki/index.php/Special:UserLogin)
#export CCC_CTS_USER=gfursin
#set user compiler (currently gcc, but can be used with any other
# compiler such as LLVM, ICC, XL, ROSE, Open64, etc)
export CTUNING_COMPILER_CC=gcc
export CTUNING_COMPILER_CPP=g++
export CTUNING_COMPILER_FORTRAN=gfortran
#misc parameters - don't change unless you understand what you do!
#compiler which was used to extract features for all programs to keep at cTuning.org
#do not change it unless you understand what you do ;) ...
export CCC_COMPILER_FEATURES_ID=129504539516446542
#use architecture flags from cTuning
export CCC_OPT_ARCH_USE=0
#retrieve opt cases only when execution time > TIME_THRESHOLD
export TIME_THRESHOLD=0.3
#retrieve opt cases only with specific notes
#export NOTES=
#retrieve opt cases only when profile info is !=""
#export PG_USE=1
#retrieve opt cases only when execution output is correct (or not if =0)
export OUTPUT_CORRECT=1
#check user or total execution time
#export RUN_TIME=RUN_TIME_USER
export RUN_TIME=RUN_TIME
#Sort optimization case by speedup (0 - ex. time, 1 - code size, 2 - comp time)
export SORT=012
echo "SORT is set to $SORT"
echo "0 - ex. time, 1 - code size, 2 - comp time"
echo "Change? (y/N)"
read -e ANSWER
if [ "$ANSWER" == 'y' ]; then
echo "What should SORT be changed to?"
read -e SORT
fi
#produce additional optimization report including optimization space froniters
export CT_OPT_REPORT=1
#Produce optimization space frontier
#export DIM=01 (2D frontier)
#export DIM=02 (2D frontier)
#export DIM=12 (2D frontier)
#export DIM=012 (3D frontier)
#export DIM=012
#Cut cases when producing frontier (select cases when speedup 0,1 or 2 is more than some threshold)
#export CUT=0,0,1.2
#export CUT=1,0.80,1
#export CUT=0,0,1
#TODO: Change
#find similar cases from the following platform
export CCC_PLATFORM_ID=2111574609159278179
export CCC_ENVIRONMENT_ID=2781195477254972989
export CCC_COMPILER_ID=331350613878705696
export ICI_FILE_SELECT_FUNCTIONS=$PWD/_ctuning_select_functions.txt
while [ ! -f "$ICI_FILE_SELECT_FUNCTIONS" ]; do
echo "Cannot find a list of functions to select program features from"
echo "Would you like to specify the location of a list? (y/N)"
read -e ANSWER
if [ "$ANSWER" == 'y' ]; then
echo "Enter file location:"
read -e ICI_FILE_SELECT_FUNCTIONS
else
export ICI_FILE_SELECT_FUNCTIONS=
break
fi
done
export CTUNING_ANALYSIS_OPT_LEVEL=-O1
export ICI_FILE_REMOVE_OPT_FLAGS=$PWD/_ctuning_remove_opt_flags.txt
while [ ! -f "$ICI_FILE_REMOVE_OPT_FLAGS" ]; do
echo "Cannot find a list of optimization flags to remove"
echo "Would you like to specify the location of a list? (y/N)"
read -e ANSWER
if [ "$ANSWER" == 'y' ]; then
echo "Enter file location:"
read -e ICI_FILE_REMOVE_OPT_FLAGS
else
export ICI_FILE_REMOVE_OPT_FLAGS=
break
fi
done
# __clean.sh
# Clean up the directory from previous compiles
rm -f *.tmp
rm -f ici*
rm -f *.P
rm -f *.xwam
rm -f a.out
rm -f _ctuning_program_structure.txt
# End of __clean.sh
read -p "Enter cTuning.org username: " USER
export CCC_CTS_USER=$USER
read -s -p "Enter cTuning.org password: " PASS
export CCC_CTS_PASS=$PASS
echo ""
$@ || { echo "Failed!"; exit 1; }
echo "Finished!"