-
Notifications
You must be signed in to change notification settings - Fork 131
/
configure.ac
443 lines (397 loc) · 13.7 KB
/
configure.ac
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
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
#####################################################
# \file configure.ac
# \brief autoconf file for HiFiLES
# \author - Original code: SD++ developed by Patrice Castonguay, Antony Jameson,
# Peter Vincent, David Williams (alphabetical by surname).
# - Current development: Aerospace Computing Laboratory (ACL)
# Aero/Astro Department. Stanford University.
# \version 0.1.0
#
# High Fidelity Large Eddy Simulation (HiFiLES) Code.
# Copyright (C) 2014 Aerospace Computing Laboratory (ACL).
#
# HiFiLES is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# HiFiLES is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with HiFiLES. If not, see <http://www.gnu.org/licenses/>.
#####################################################
AC_INIT([HiFiLES], [0.1], [HiFiLES-dev@lists.stanford.edu],
[HiFiLES], [http://hifiles.stanford.edu])
AC_PREREQ([2.59])
AC_CONFIG_MACRO_DIR([m4])
AM_INIT_AUTOMAKE([subdir-objects foreign])
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES(yes)])
top_dir=`pwd`
AC_SUBST([top_dir])
# --------------------------------------------------------------
# optional bindings
# --------------------------------------------------------------
AC_ARG_WITH(CUDA,
AS_HELP_STRING([--with-CUDA[=ARG]], [Build GPU version with NVidia CUDA compiler, ARG = CUDA compiler]),
[with_CUDA=$withval], [with_CUDA="NO"])
AC_ARG_WITH(CUDA-lib,
AS_HELP_STRING([--with-CUDA-lib[=ARG]], [CUDA library directory, ARG = path to libcuda.a]),
[with_CUDA_lib=$withval], [with_CUDA_lib="NO"])
AC_ARG_WITH(CUDA-include,
AS_HELP_STRING([--with-CUDA-include[=ARG]], [CUDA include directory, ARG = path to cuda.h]),
[with_CUDA_include=$withval], [with_CUDA_include="NO"])
AC_ARG_WITH(CUDA-arch,
AS_HELP_STRING([--with-CUDA-arch[=ARG]], [CUDA device architecture, compute_xx (default: 20)]),
[with_CUDA_arch=$withval], [with_CUDA_arch=20])
AC_ARG_WITH(MPI,
AS_HELP_STRING([--with-MPI[=ARG]], [Build parallel version with MPI tools, ARG = MPI C++ compiler]),
[with_MPI=$withval], [with_MPI="NO"])
AC_ARG_WITH(MPI-include,
AS_HELP_STRING([--with-MPI-include[=ARG]], [MPI include directory, ARG = path to mpi.h, needed for METIS]),
[with_MPI_include=$withval], [with_MPI_include="NO"])
AC_ARG_WITH(Tecio-lib,
AS_HELP_STRING([--with-Tecio-lib[=ARG]], [Tecio library directory, ARG = path to libtecio.a]),
[with_Tecio_lib=$withval], [with_Tecio_lib="NO"])
AC_ARG_WITH(Tecio-include,
AS_HELP_STRING([--with-Tecio-include[=ARG]], [Tecio include directory, ARG = path to TECIO.h]),
[with_Tecio_include=$withval], [with_Tecio_include="NO"])
AC_ARG_WITH(ParMetis-lib,
AS_HELP_STRING([--with-ParMetis-lib[=ARG]], [ParMetis library directory, ARG = path to libparmetis.a]),
[with_ParMetis_lib=$withval], [with_ParMetis_lib="NO"])
AC_ARG_WITH(ParMetis-include,
AS_HELP_STRING([--with-ParMetis-include[=ARG]], [ParMetis include directory, ARG = path to parmetis.h]),
[with_ParMetis_include=$withval], [with_ParMetis_include="NO"])
AC_ARG_WITH(Metis-lib,
AS_HELP_STRING([--with-Metis-lib[=ARG]], [Metis library directory, ARG = path to libmetis.a]),
[with_Metis_lib=$withval], [with_Metis_lib="NO"])
AC_ARG_WITH(Metis-include,
AS_HELP_STRING([--with-Metis-include[=ARG]], [Metis include directory, ARG = path to metis.h]),
[with_Metis_include=$withval], [with_Metis_include="NO"])
AC_ARG_WITH(BLAS,
AS_HELP_STRING([--with-BLAS[=ARG]], [Build using support for a BLAS variant, ARG = BLAS library to use]),
[with_BLAS=$withval], [with_BLAS="NO"])
AC_ARG_WITH(BLAS-lib,
AS_HELP_STRING([--with-BLAS-lib[=ARG]], [BLAS library directory, ARG = path to libcblas.a]),
[with_BLAS_lib=$withval], [with_BLAS_lib="NO"])
AC_ARG_WITH(BLAS-include,
AS_HELP_STRING([--with-BLAS-include[=ARG]], [BLAS include directory, ARG = path to cblas.h]),
[with_BLAS_include=$withval], [with_BLAS_include="NO"])
AC_ARG_WITH(CXX,
AS_HELP_STRING([--with-CXX[=ARG]], [Optional: Specify C++ compiler, ARG = C++ compiler]), [with_CXX=$withval], [with_CXX="GCC"])
AC_ARG_ENABLE(release,
AS_HELP_STRING([--enable-release[=ARG]], [Optional: Specify whether to compile for DEBUG (default) or RELEASE]),
[code_type=$enableval], [code_type="DEBUG"])
# -------------------------------------------------------------
# Specify whether to build debug or release version of the code
# -------------------------------------------------------------
if test "$code_type" == "RELEASE" ; then
CXXFLAGS="-O3"
else
CXXFLAGS="-g -O2"
fi
# --------------------------------------------------------------
# Build up contributed packages that we will build from source
# --------------------------------------------------------------
hifiles_externals_INCLUDES=""
hifiles_externals_LIBS=""
# Metis
CONFIGURE_METIS
if (test $with_MPI != "NO")
then
if (test $enablemetis = "YES")
then
hifiles_externals_INCLUDES="$METIS_INCLUDE $hifiles_externals_INCLUDES"
hifiles_externals_LIBS="$METIS_LIB $hifiles_externals_LIBS"
AC_CONFIG_FILES([lib/parmetis-4.0.2/Makefile])
AC_CONFIG_FILES([lib/parmetis-4.0.2/metis/Makefile])
AM_CONDITIONAL(BUILD_METIS, test $enablemetis = "YES")
else
hifiles_externals_INCLUDES="-DNO_METIS $hifiles_externals_INCLUDES"
AM_CONDITIONAL(BUILD_METIS, test $enablemetis = "YES")
fi
else
AM_CONDITIONAL(BUILD_METIS, test $with_MPI != "NO")
fi
AC_SUBST([hifiles_externals_INCLUDES])
AC_SUBST([hifiles_externals_LIBS])
########################### CUDA (GPU-Enabled)
# check if we're building GPU or CPU version
# first, check for [a] CUDA library in the given directory
CUDAlib=libcublas.so
CUDAheader=cuda.h
have_CUDA="NO"
if test "$with_CUDA" != "NO"
then
AC_CHECK_FILE([$with_CUDA_lib/$CUDAlib],[have_CUDA="YES"],[have_CUDA="NO"])
if test "$have_CUDA" == "NO"
then
AC_MSG_ERROR([GPU build requested but CUDA library files not found.])
fi
fi
# next, check for CUDA header
if test "$have_CUDA" != "NO"
then
if test "$with_CUDA_include" != "NO"
then
AC_CHECK_FILE([$with_CUDA_include/$CUDAheader],[have_CUDA="YES"],[have_CUDA="NO"])
if test "$have_CUDA" == "NO"
then
AC_MSG_ERROR([GPU build requested but CUDA header file not found.])
fi
else
have_CUDA="NO"
fi
fi
if test "$have_CUDA" != "NO"
then
AM_CONDITIONAL(BUILD_GPU,true)
NVCCFLAGS="-D_GPU -I"$with_CUDA_include
CUDA_CXX="-D_GPU -I"$with_CUDA_include
ARCH=`uname -m`
if [[ $ARCH == "x86_64" ]];
then
SUFFIX="64"
else
SUFFIX=""
fi
CUDA_LDFLAGS="-L$with_CUDA_lib"
CUDA_LIBS="-lcudart -lcublas -lcusparse -lm"
CUDA_ARCH="-gencode=arch=compute_$with_CUDA_arch,code=sm_$with_CUDA_arch"
NVCC=$with_CUDA
else
AM_CONDITIONAL(BUILD_GPU,false)
CUDA_CXX="-D_CPU"
CUDA_LDFLAGS=
CUDA_LIBS=
CUDA_ARCH=
fi
AC_SUBST([NVCC])
AC_SUBST([CUDA_LIBS])
AC_SUBST([CUDA_LDFLAGS])
AC_SUBST([CUDA_CXX])
AC_SUBST([CUDA_ARCH])
AC_SUBST([NVCCFLAGS])
########################### ParMETIS
# check for lib
ParMETISlib=libparmetis.a
ParMETISheader=parmetis.h
METISlib=libmetis.a
METISheader=metis.h
ParMETISversion=
have_ParMetis="NO"
# If not building from lib folder, link to given libraries
if test $enablemetis != "YES"
then
if test "$with_ParMetis_lib" != "NO"
then
# Optional value for separate Metis library file location
if test "$with_Metis_lib" == "NO"
then
with_Metis_lib=$with_ParMetis_lib
fi
AC_CHECK_FILE([$with_ParMetis_lib/$ParMETISlib],[have_ParMetis="YES"],[have_ParMetis="NO"])
if test "$have_ParMetis" == "NO"
then
AC_MSG_ERROR([ParMETIS requested but library file not found.])
fi
AC_CHECK_FILE([$with_Metis_lib/$METISlib],[have_ParMetis="YES"],[have_ParMetis="NO"])
if test "$have_ParMetis" == "NO"
then
AC_MSG_ERROR([ParMETIS requested but METIS library file not found.])
fi
fi
# check for header
if test "$have_ParMetis" != "NO"
then
if test "$with_ParMetis_include" != "NO"
then
# Optional value for separate Metis header file location
if test "$with_Metis_include" == "NO"
then
with_Metis_include=$with_ParMetis_include
fi
AC_CHECK_FILE([$with_ParMetis_include/$ParMETISheader],[have_ParMetis="YES"],[have_ParMetis="NO"])
if test "$have_ParMetis" == "NO"
then
AC_MSG_ERROR([ParMETIS requested but header file not found.])
fi
AC_CHECK_FILE([$with_Metis_include/$METISheader],[have_ParMetis="YES"],[have_ParMetis="NO"])
if test "$have_ParMetis" == "NO"
then
AC_MSG_ERROR([ParMETIS requested but METIS header file not found.])
fi
else
have_ParMetis="NO"
fi
fi
if test "$have_ParMetis" != "NO"
then
AM_CONDITIONAL(BUILD_PARMETIS,true)
PARMETIS_CXX="-I$with_Metis_include -I$with_ParMetis_include"
PARMETIS_LD="$with_ParMetis_lib/$ParMETISlib $with_Metis_lib/$METISlib"
else
AM_CONDITIONAL(BUILD_PARMETIS,false)
PARMETIS_CXX=-DNO_PARMETIS
PARMETIS_LD=
fi
else
AM_CONDITIONAL(BUILD_PARMETIS,false)
PARMETIS_CXX=-DNO_PARMETIS
PARMETIS_LD=
fi
AC_SUBST([PARMETIS_CXX])
AC_SUBST([PARMETIS_LD])
########################### Tecplot
Teciolib=libtecio.a
Tecioheader=TECIO.h
have_Tecio="NO"
# check for lib
if test "$with_Tecio_lib" != "NO"
then
AC_CHECK_FILE([$with_Tecio_lib/$Teciolib],[have_Tecio="YES"],[have_Tecio="NO"])
if test "$have_Tecio" == "NO"
then
Teciolib=libtecio.a
AC_CHECK_FILE([$with_Tecio_lib/$Teciolib],[have_Tecio="YES"],[have_Tecio="NO"])
fi
if test "$have_Tecio" == "NO"
then
AC_MSG_ERROR([Tecplot linking requested but library file not found.])
fi
fi
# check for header
if test "$have_Tecio" != "NO"
then
if test "$with_Tecio_include" != "NO"
then
AC_CHECK_FILE([$with_Tecio_include/$Tecioheader],[have_Tecio="YES"],[have_Tecio="NO"])
if test "$have_Tecio" == "NO"
then
AC_MSG_ERROR([Tecplot linking requested but header file not found.])
fi
else
have_Tecio="NO"
fi
fi
if test "$have_Tecio" != "NO"
then
AM_CONDITIONAL(BUILD_TECIO,true)
TECIO_CXX="-I"$with_Tecio_include
TECIO_LD=$with_Tecio_lib"/"$Teciolib
else
AM_CONDITIONAL(BUILD_TECIO,false)
TECIO_CXX=-DNO_TECIO
TECIO_LD=
fi
AC_SUBST([TECIO_CXX])
AC_SUBST([TECIO_LD])
########################### MPI
have_MPI="NO"
if test "$with_MPI" != "NO"
then
AC_CHECK_FILE([$with_MPI_include/mpi.h],[have_MPI="YES"],[have_MPI="NO"])
if test "$have_MPI" == "YES"
then
CXX="$with_MPI"
have_MPI="YES"
CXXFLAGS=$CXXFLAGS" -D_MPI"
MPI_INCLUDE="-I$with_MPI_include"
AM_CONDITIONAL(BUILD_MPI,true)
# Add MPI flag to CUDA flag if needed
if test "$have_CUDA" != "NO"
then
NVCCFLAGS=$NVCCFLAGS" -D_MPI $MPI_INCLUDE"
fi
else
AC_MSG_ERROR([MPI requested but header file not found.])
fi
else
MPI_INCLUDE=
AM_CONDITIONAL(BUILD_MPI,false)
fi
AC_SUBST([MPI_INCLUDE])
########################### BLAS
if test "$with_BLAS" == "ACCELERATE"
then
BLAS_CXX=" -flax-vector-conversions -D_ACCELERATE_BLAS"
BLAS_LDFLAGS=" -framework Accelerate"
BLAS_LD=
elif test "$with_BLAS" == "STANDARD"
then
AC_CHECK_FILE([$with_BLAS_lib/libcblas.a],[have_BLAS="YES"],[have_BLAS="NO"])
if test "$have_BLAS" != "NO"
then
BLAS_CXX="-I $with_BLAS_include -D_STANDARD_BLAS"
BLAS_LD="$with_BLAS_lib/libcblas.a"
BLAS_LDFLAGS=
fi
if test "$have_BLAS" == "NO"
then
AC_MSG_ERROR([BLAS linking requested but library file not found (libcblas.a).])
fi
elif test "$with_BLAS" == "ATLAS"
then
AC_CHECK_FILE([$with_BLAS_lib/libcblas.a],[have_BLAS="YES"],[have_BLAS="NO"])
if test "$have_BLAS" != "NO"
then
AC_CHECK_FILE([$with_BLAS_lib/libatlas.a],[have_BLAS="YES"],[have_BLAS="NO"])
fi
if test "$have_BLAS" != "NO"
then
BLAS_CXX="-I $with_BLAS_include -D_STANDARD_BLAS"
BLAS_LD="$with_BLAS_lib/libcblas.a $with_BLAS_lib/libatlas.a"
BLAS_LDFLAGS=
else
AC_MSG_ERROR([BLAS linking requested but library files not found (libcblas.a, libatlas.a).])
fi
# needs more work here (not terribly familiar with our MKL usage)
elif test "$with_BLAS" == "MKL"
then
if test "$CXX" == "icpc"
then
BLAS_CXX="-mkl=parallel -D_MKL_BLAS"
BLAS_LD=
BLAS_INCLUDE=
BLAS_LDFLAGS=
fi
elif [test "$with_BLAS" == "NO"] || [test "$with_BLAS" == "NO"]
then
BLAS_CXX="-D_NO_BLAS"
BLAS_LD=
BLAS_LDFLAGS=
have_BLAS="NO"
fi
AC_SUBST([BLAS_CXX])
AC_SUBST([BLAS_LDFLAGS])
AC_SUBST([BLAS_LD])
###########################
# AC_CONFIG_HEADERS([config.h])
AC_PROG_CXX
AC_PROG_CC
AM_PROG_CC_C_O
AM_PROG_LIBTOOL
AC_OUTPUT(Makefile \
lib/Makefile \
obj/Makefile)
abs_srcdir=`(cd $srcdir && pwd)`
abs_prefix=`(cd $prefix && pwd)`
AC_MSG_RESULT([
Build Configuration Summary:
Source code location: ${abs_srcdir}
Install location: ${abs_prefix}
Version: ${VERSION}
Code Type: ${code_type}
Compiler: ${CXX}
Preprocessor flags: ${CPPFLAGS} ${BLAS_CXX} ${PARMETIS_CXX} ${CUDA_CXX} ${MPI_INCLUDE}
Compiler flags: ${CXXFLAGS} ${NVCCFLAGS}
Linker flags: ${LDFLAGS} ${BLAS_LDFLAGS} ${CUDA_LDFLSGS}
Libraries: ${BLAS_LD} ${PARMETIS_LD} ${CUDA_LIBS}
BLAS support: $have_BLAS
MPI support: $have_MPI
CUDA support: $have_CUDA $CUDA_ARCH
TecIO support: $have_Tecio
Additionally, don't forget to set the environment variable HIFILES_HOME
])