forked from ShadenSmith/splatt
-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure
executable file
·342 lines (275 loc) · 9.05 KB
/
configure
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
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
#!/bin/bash
# The MIT License (MIT)
#
# Copyright (c) 2014-2016, Dominique LaSalle and Shaden Smith
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
# SOFTWARE.
###############################################################################
# CONFIG VARIABLES ############################################################
###############################################################################
NAME="splatt"
###############################################################################
# FUNCTIONS ###################################################################
###############################################################################
die() {
echo "ERROR: ${@}" 1>&2
exit 1
}
abspath() {
if [[ "${@::1}" == "/" ]]; then
echo "${@}"
else
echo "${PWD}/${@}"
fi
}
show_help() {
echo "USAGE: configure [options]"
echo ""
echo "COMPILATION OPTIONS"
echo "==================="
echo " --build-dir=<dir>"
echo " Set the build directory (default: ./build/<arch>/)."
echo " --cc=<cc>"
echo " Set the C compiler."
#echo " --cxx=<cxx>"
#echo " Set the C++ compiler."
echo ""
echo " --max-modes=<#>"
echo " Set the maxmimum number of tensor modes (default: 8)."
echo ""
echo " --with-index-size={32,64}"
echo " Use 32 or 64 bit integers (default: 64)."
echo " --with-precision={single,double}"
echo " Use single or double precision floating point values (default: double)."
echo " --intel"
echo " Use the Intel compiler (icc), MKL, and possibly Intel-specific optimizations."
echo " --debug"
echo " Turn off optimizations and build with debugging symbols and assertions."
echo " --dev"
echo " Build in development mode. Warnings and extra logging enabled."
echo ""
echo "LIBRARY OPTIONS"
echo "==============="
# MPI
echo " --with-mpi"
echo " Build with MPI support. Let CMake auto-detect MPI environment."
echo " --with-mpicc=<cc>"
echo " Set the MPI C compiler. Other configuration options may be determined by CMake."
#echo " --with-mpicxx=<cxx>"
#echo " Set the MPI C++ compiler. Other configuration options may be determined by CMake."
echo ""
# BLAS/LAPACK
echo "If you are unhappy with the auto-detected BLAS/LAPACK libraries:"
echo " --with-blas-lib=<lib>"
echo " Set the BLAS library (e.g., /usr/.../libblas.so)."
echo " --with-lapack-lib=<lib>"
echo " Set the LAPACK library (e.g., /usr/.../liblapack.so)."
echo " --download-blas-lapack"
echo " Download generic BLAS/LAPACK libraries (possible performance loss)."
# Metis
echo "";
echo " --with-metis"
echo " Build with Metis support. Let CMake auto-detect Metis environment."
echo " --with-metis-lib=<lib>"
echo " Set the Metis library (e.g., /usr/.../libmetis.a)."
echo ""
echo "INSTALLATION OPTIONS:"
echo "====================:"
echo " --prefix=<prefix>"
echo " Set the installation prefix."
echo " --build-lib={static,shared}"
echo " Set the type of library to build (default: static)."
echo ""
echo "Please report bugs to <[email protected]>."
echo "SPLATT home page: <http://cs.umn.edu/~splatt/>."
}
###############################################################################
# OPTION PARSING ##############################################################
###############################################################################
#CONFIG_FLAGS="-DCMAKE_VERBOSE_MAKEFILE=1"
CONFIG_FLAGS=""
# default values
CMAKE="$(which cmake)"
BUILDDIR="build/$(uname -s)-$(uname -m)"
# parse arguments
for i in "${@}"; do
case "${i}" in
# help
-h|--help)
show_help
exit 0
;;
## COMPILE OPTIONS
# cc
--cc=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DCMAKE_C_COMPILER=${i#*=}"
;;
# cxx
--cxx=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DCMAKE_CXX_COMPILER=${i#*=}"
;;
--intel)
CONFIG_FLAGS="${CONFIG_FLAGS} -DINTEL_OPT=1"
CONFIG_FLAGS="${CONFIG_FLAGS} -DCMAKE_C_COMPILER=icc"
;;
# debug
--debug)
CONFIG_FLAGS="${CONFIG_FLAGS} -DDEBUG=1"
;;
# dev
--dev)
CONFIG_FLAGS="${CONFIG_FLAGS} -DDEV_MODE=1"
;;
--build-dir=*)
BUILDDIR="${i#*=}"
;;
--with-index-size=*)
IDX_WIDTH=${i#*=}
if [ "${IDX_WIDTH}" == "32" ]; then
CONFIG_FLAGS="${CONFIG_FLAGS} -DSPLATT_IDX_WIDTH=32"
elif [ "${IDX_WIDTH}" == "64" ]; then
CONFIG_FLAGS="${CONFIG_FLAGS} -DSPLATT_IDX_WIDTH=64"
else
die "Unknown index size: ${IDX_WIDTH}. Choose between {32,64}."
fi
;;
--with-precision=*)
PRECISION=${i#*=}
if [ "${PRECISION}" == "single" ]; then
CONFIG_FLAGS="${CONFIG_FLAGS} -DSPLATT_VAL_WIDTH=single"
elif [ "${PRECISION}" == "double" ]; then
CONFIG_FLAGS="${CONFIG_FLAGS} -DSPLATT_VAL_WIDTH=double"
else
die "Unknown precision: ${PRECISION}. Choose between {single,double}."
fi
;;
--max-modes=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DMAX_MODES=${i#*=}"
;;
## LIBRARY OPTIONS
# BLAS/LAPACK
--with-blas-dir=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DUSER_BLAS_DIR=${i#*=}"
;;
--with-blas-lib=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DUSER_BLAS_LIB=${i#*=}"
;;
--with-lapack-dir=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DUSER_LAPACK_DIR=${i#*=}"
;;
--with-lapack-lib=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DUSER_LAPACK_LIB=${i#*=}"
;;
--download-blas-lapack)
CONFIG_FLAGS="${CONFIG_FLAGS} -DDOWNLOAD_BLAS_LAPACK=TRUE"
;;
# MPI support
--with-mpi)
CONFIG_FLAGS="${CONFIG_FLAGS} -DUSE_MPI=1"
;;
--with-mpicc=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DMPICC=${i#*=}"
;;
--with-mpicxx=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DMPICXX=${i#*=}"
;;
# Metis
--with-metis)
CONFIG_FLAGS="${CONFIG_FLAGS} -DUSE_METIS=1"
;;
--with-metis-lib=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DUSER_METIS_LIB=${i#*=}"
;;
## INSTALL OPTIONS
# prefix
--prefix=*)
CONFIG_FLAGS="${CONFIG_FLAGS} -DCMAKE_INSTALL_PREFIX=${i#*=}"
;;
--build-lib=*)
LIBTYPE=${i#*=}
if [ "${LIBTYPE}" == "shared" ]; then
CONFIG_FLAGS="${CONFIG_FLAGS} -DBUILD_SHARED_LIBS=TRUE"
elif [ "${LIBTYPE}" == "static" ]; then
CONFIG_FLAGS="${CONFIG_FLAGS} -DBUILD_SHARED_LIBS=FALSE"
else
die "Unknown library type: ${LIBTYPE}. Choose between {static,shared}."
fi
;;
# deprecated
--mpi)
CONFIG_FLAGS="${CONFIG_FLAGS} -DUSE_MPI=1"
;;
--mtmetis)
CONFIG_FLAGS="${CONFIG_FLAGS} -DUSE_MTMETIS=1"
;;
--patoh)
CONFIG_FLAGS="${CONFIG_FLAGS} -DUSE_PATOH=1"
;;
--ashado)
CONFIG_FLAGS="${CONFIG_FLAGS} -DUSE_ASHADO=1"
;;
# bad argument
*)
die "Unknown option '${i}'"
;;
esac
done
# check if cmake exists
if [[ ! -x "${CMAKE}" ]]; then
die "Could not find usable cmake: '${CMAKE}'"
else
echo "Found CMAKE: '${CMAKE}'"
fi
# clean out build directory if it exists
if [[ -d "${BUILDDIR}" ]]; then
echo "Removing old build directory '${BUILDDIR}'..."
rm -rf "${BUILDDIR}"
fi
# create build directory
mkdir -vp "${BUILDDIR}" || \
die "Failed to create build directory: '${BUILDDIR}'"
###############################################################################
# RUN CMAKE ###################################################################
###############################################################################
ROOTDIR="${PWD}"
pushd "${BUILDDIR}"
echo "Calling cmake with arguments '${CONFIG_FLAGS}'"
"${CMAKE}" "${ROOTDIR}" ${CONFIG_FLAGS}
if [[ "$?" != "0" ]]; then
echo "CMake failed with '$?'" 1>&2
exit $?
fi
popd
# create proxy makefile
(
echo "#######################################################################"
echo "# Makefile generated by '$0' at $(date)"
echo "# Using flags:"
for d in ${CONFIG_FLAGS}; do
echo "# ${d}"
done
echo "#######################################################################"
echo ""
echo "all clean install uninstall:"
echo " make -C ${BUILDDIR} \$@ \$(MAKEFLAGS)"
echo ""
echo "distclean:"
echo " rm -rf ${BUILDDIR} Makefile"
echo ""
) > Makefile