-
Notifications
You must be signed in to change notification settings - Fork 17
/
configure.ac
436 lines (393 loc) · 15.1 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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.59])
AC_INIT([P3DFFT], [2.7.4], [dmitry@sdsc.edu])
AM_INIT_AUTOMAKE([no-dependencies])
AC_CONFIG_SRCDIR([build/module.F90])
AC_CONFIG_HEADER([config.h])
# initialize array index
N="0"
N1="0"
# save arguments passed in as a string
AC_DEFINE_UNQUOTED([CONFIGURE_ARGS],["$ac_configure_args"],[arguments passed to configure script])
# check whether to compile using IBM
AC_MSG_CHECKING([whether to use IBM compiler])
AC_ARG_ENABLE(ibm, [AC_HELP_STRING([--enable-ibm], [compile P3DFFT using IBM compiler])], enableibm=$enableval, enableibm=no)
AC_MSG_RESULT([$enableibm])
if test "$enableibm" = "yes"; then
AC_DEFINE(IBM, 1, [Define if you want to compile P3DFFT using IBM compiler])
AC_DEFINE(CC, "mpfort", [overriding mpicc to link C programs (only for IBM)])
eval "ARRAY${N}='-DIBM'"
N=`expr $N + 1`
AC_SUBST(CCLD,"$FC")
compiler="ibm"
fi
# check whether to compile using Intel
AC_MSG_CHECKING([whether to use Intel compiler])
AC_ARG_ENABLE(intel, [AC_HELP_STRING([--enable-intel], [compile P3DFFT using Intel compiler])], enableintel=$enableval, enableintel=no)
AC_MSG_RESULT([$enableintel])
if test "$enableintel" = "yes"; then
AC_DEFINE(INTEL, 1, [Define if you want to compile P3DFFT using Intel compiler])
eval "ARRAY${N}='-DINTEL'"
N=`expr $N + 1`
AC_SUBST(CCLD,"$CC")
compiler="intel"
fi
# check whether to compile using PGI
AC_MSG_CHECKING([whether to use PGI compiler])
AC_ARG_ENABLE(pgi, [AC_HELP_STRING([--enable-pgi], [compile P3DFFT using PGI compiler])], enablepgi=$enableval, enablepgi=no)
AC_MSG_RESULT([$enablepgi])
if test "$enablepgi" = "yes"; then
# AC_SUBST(LDFLAGS,"$LDFLAGS -pgf90libs")
AC_DEFINE(PGI, 1, [Define if you want to compile P3DFFT using PGI compiler])
eval "ARRAY${N}='-DPGI'"
N=`expr $N + 1`
AC_SUBST(CCLD,"$CC")
compiler="pgi"
fi
# check whether to compile using Cray
AC_MSG_CHECKING([whether to use Cray compiler])
AC_ARG_ENABLE(cray, [AC_HELP_STRING([--enable-cray], [compile P3DFFT using CRAY compiler])], enablecray=$enableval, enablecray=no)
AC_MSG_RESULT([$enablecray])
if test "$enablecray" = "yes"; then
AC_DEFINE(CRAY, 1, [Define if you want to compile P3DFFT using CRAY compiler])
eval FCFLAGS="\$FCFLAGS' -em -ef'"
eval "ARRAY${N}='-DCRAY'"
N=`expr $N + 1`
FORTRAN_LIB=""
AC_SUBST(CCLD,"$CC")
compiler="cray"
fi
# check whether to compile using GNU
AC_MSG_CHECKING([whether to use GNU compiler])
AC_ARG_ENABLE(gnu, [AC_HELP_STRING([--enable-gnu], [compile P3DFFT using GNU compiler])], enablegnu=$enableval, enablegnu=no)
AC_MSG_RESULT([$enablegnu])
if test "$enablegnu" = "yes"; then
AC_DEFINE(GNU, 1, [Define if you want to compile P3DFFT using GNU compiler])
eval "ARRAY${N}='-DGNU'"
N=`expr $N + 1`
if (( `echo $HOSTNAME | grep -c "mira\|cetus\|vesta"` > 0 )); then
AC_SUBST(CCLD,"$FC")
else
AC_SUBST(CCLD,"$CC")
fi
compiler="gnu"
fi
# check whether to use OpenMPI
AC_MSG_CHECKING([whether to use OpenMPI])
AC_ARG_ENABLE(openmpi, [AC_HELP_STRING([--enable-openmpi], [use the OpenMPI MPI implementation])], ok=$enableval, ok=no)
AC_MSG_RESULT([$ok])
case $compiler in
ibm)
;;
intel)
if test "$ok" = "yes"; then
AC_SUBST(FORTRAN_LIB,"-lmpi_mpifh -limf -lifcore")
else
AC_SUBST(FORTRAN_LIB,"-limf -lifcore") #-lmpichf90
fi
;;
pgi)
if test "$ok" = "yes"; then
AC_SUBST(FORTRAN_LIB,"-lmpi_mpifh -pgf90libs")
else
AC_SUBST(FORTRAN_LIB,"-pgf90libs") #-lmpichf90
fi
;;
cray)
;;
gnu)
if test "$ok" = "yes"; then
AC_SUBST(FORTRAN_LIB,"-lmpi_mpifh -lgfortran")
else
AC_SUBST(FORTRAN_LIB,"-lgfortran")
fi
;;
*)
esac
# check whether to use OpenMP
AC_MSG_CHECKING([whether to use OpenMP library])
AC_ARG_ENABLE(openmp, [AC_HELP_STRING([--enable-openmp], [for using the OpenMP library (disabled by default)])], ok=$enableval, ok=no)
AC_MSG_RESULT([$ok])
if test "$ok" = "yes"; then
AC_DEFINE(OPENMP, 1, [Define if you want to use the OpenMP library])
eval "ARRAY${N}='-DOPENMP'"
N=`expr $N + 1`
case $compiler in
ibm)
if test "$ok" = "yes"; then
eval "ARRAY1${N1}='-qsmp=omp'"
N1=`expr $N1 + 1`
CFLAGS=$CFLAGS" -qsmp=omp"
fi
;;
intel)
if test "$ok" = "yes"; then
eval "ARRAY${N}='-qopenmp'"
N=`expr $N + 1`
CFLAGS=$CFLAGS" -qopenmp"
fi
;;
pgi)
if test "$ok" = "yes"; then
eval "ARRAY${N}='-mp'"
N=`expr $N + 1`
CFLAGS=$CFLAGS" -mp"
fi
;;
cray)
;;
gnu)
if test "$ok" = "yes"; then
eval "ARRAY${N}='-fopenmp'"
N=`expr $N + 1`
CFLAGS=$CFLAGS" -fopenmp"
fi
;;
*)
esac
else
case $compiler in
cray)
if test "$ok" = "no"; then
eval "ARRAY${N}='-h noomp'"
N=`expr $N + 1`
CFLAGS=$CFLAGS" -h noomp"
fi
;;
*)
esac
fi
# check whether to enable single precision
AC_MSG_CHECKING([whether to enable single precision])
AC_ARG_ENABLE(single, [AC_HELP_STRING([--enable-single], [compile P3DFFT in single precision (default is double precision)])], spval=$enableval, spval=no)
AC_MSG_RESULT([$spval])
if test "$spval" = "yes"; then
AC_DEFINE(SINGLE_PREC, 1, [Define if you want to compile P3DFFT in single precision])
eval "ARRAY${N}='-DSINGLE_PREC'"
N=`expr $N + 1`
fi
# check whether to enable 1D decomposition
AC_MSG_CHECKING([whether to enable 1D decomposition])
AC_ARG_ENABLE(oned, [AC_HELP_STRING([--enable-oned], [for 1D decomposition (default is 2D but it can be made 1D through setting up grid 1 x n when running the code) ])], ok=$enableval, ok=no)
AC_MSG_RESULT([$ok])
if test "$ok" = "yes"; then
AC_DEFINE(ONED, 1, [Define if you want 1D decomposition])
eval "ARRAY${N}='-DONED'"
N=`expr $N + 1`
fi
# check whether to enable estimation
AC_MSG_CHECKING([whether to enable estimation])
AC_ARG_ENABLE(estimate, [AC_HELP_STRING([--enable-estimate], [If this argument is passed, the FFTW library will not use run-time tuning to select the fastest algorithm for computing FFTs (this option only goes with --enable-fftw) .])], ok=$enableval, ok=no)
AC_MSG_RESULT([$ok])
if test "$ok" = "yes"; then
AC_DEFINE(ESTIMATE, 1, [Define whether you want to enable estimation])
eval "ARRAY${N}='-DESTIMATE'"
N=`expr $N + 1`
fi
# check whether to enable the measure algorithm
AC_MSG_CHECKING([whether to enable the measure algorithm])
AC_ARG_ENABLE(measure, [AC_HELP_STRING([--enable-measure], [for search-once-for-the-fast-algorithm (takes more time on p3dfft_setup()); this option only goes with --enable-fftw.])], ok=$enableval, ok=yes)
AC_MSG_RESULT([$ok])
if test "$ok" = "yes"; then
AC_DEFINE(MEASURE, 1, [Define if you want to enable the measure algorithm])
eval "ARRAY${N}='-DMEASURE'"
N=`expr $N + 1`
fi
# check whether to enable the patient algorithm
AC_MSG_CHECKING([whehter to enable the patient algorithm])
AC_ARG_ENABLE(patient, [AC_HELP_STRING([--enable-patient], [for search-once-for-the-fastest-algorithm (takes much more time on p3dfft_setup()); this option only goes with --enable-fftw.])], ok=$enableval, ok=no)
AC_MSG_RESULT([$ok])
if test "$ok" = "yes"; then
AC_DEFINE(PATIENT, 1, [Define if you want to enable the patient algorithm])
eval "ARRAY${N}='-DPATIENT'"
N=`expr $N + 1`
fi
# check whether to enable C convention for processor dimensions
AC_MSG_CHECKING([whether to enable C convention for processor dimensions])
AC_ARG_ENABLE(dimsc, [AC_HELP_STRING([--enable-dimsc], [to assign processor rows and columns according to C convention, rather than "Fortran", which is default.])], ok=$enableval, ok=no)
AC_MSG_RESULT([$ok])
if test "$ok" = "yes"; then
AC_DEFINE(DIMS_C, 1, [Define if you want to enable C convention for processor dimensions])
eval "ARRAY${N}='-DDIMS_C'"
N=`expr $N + 1`
fi
# check whether to use MPI_Alltoall instead of MPI_Alltotallv
AC_MSG_CHECKING([whether to use MPI_Alltoall instead of MPI_Alltotallv])
AC_ARG_ENABLE(useeven, [AC_HELP_STRING([--enable-useeven], [for using MPI_Alltoall instead of MPI_Alltotallv. This method pads the send buffers with zeros to make them equal size. This options is not needed on most architectures.])], ok=$enableval, ok=no)
AC_MSG_RESULT([$ok])
if test "$ok" = "yes"; then
AC_DEFINE(USE_EVEN, 1, [Define if you want to MPI_Alltoall instead of MPI_Alltotallv])
eval "ARRAY${N}='-DUSE_EVEN'"
N=`expr $N + 1`
fi
# check whether to enable stride-1 data structures
AC_MSG_CHECKING([whether to enable stride-1 data structures])
AC_ARG_ENABLE(stride1, [AC_HELP_STRING([--enable-stride1], [to enable stride-1 data structures on output (this may in some cases give some advantage in performance). You can define loop blocking factors NBL_X and NBL_Y to experiment, otherwise they are set to default values.])], ok=$enableval, ok=no)
AC_MSG_RESULT([$ok])
if test "$ok" = "yes"; then
AC_DEFINE(STRIDE1, 1, [Define if you want to enable stride-1 data structures])
eval "ARRAY${N}='-DSTRIDE1'"
N=`expr $N + 1`
fi
# check whether to override default value of the NBL_X
AC_MSG_CHECKING([whether to override default value of NBL_X])
AC_ARG_ENABLE(nblx, [AC_HELP_STRING([--enable-nblx], [to define loop blocking factor NBL_X])], nblval=$enableval, nblval="")
if test "$nblval" != ""; then
AC_MSG_RESULT([yes])
AC_DEFINE(NBL_X, $nblval, [Define if you want to override the default value of NBL_X])
eval "ARRAY${N}='-DNBL_X=$nblval'"
N=`expr $N + 1`
else
AC_MSG_RESULT([no])
fi
# check whether to override default value of NBL_Y1
AC_MSG_CHECKING([whether to override the default value of NBL_Y1])
AC_ARG_ENABLE(nbly1, [AC_HELP_STRING([--enable-nbly1], [to define loop blocking factor NBL_Y1])], nblval=$enableval, nblval="")
if test "$nblval" != ""; then
AC_MSG_RESULT([yes])
AC_DEFINE(NBL_Y1, $nblval, [Define if you want to override the default value of NBL_Y1])
eval "ARRAY${N}='-DNBL_Y1=$nblval'"
N=`expr $N + 1`
else
AC_MSG_RESULT([no])
fi
# check whether to override default value of NBL_Y2
AC_MSG_CHECKING([whether to override the default value of NBL_Y2])
AC_ARG_ENABLE(nbly2, [AC_HELP_STRING([--enable-nbly2], [to define loop blocking factor NBL_Y2])], nblval=$enableval, nblval="")
if test "$nblval" != ""; then
AC_MSG_RESULT([yes])
AC_DEFINE(NBL_Y2, $nblval, [Define if you want to override the default value of NBL_Y2])
eval "ARRAY${N}='-DNBL_Y2=$nblval'"
N=`expr $N + 1`
else
AC_MSG_RESULT([no])
fi
# check whether to override default value of NBL_Z
AC_MSG_CHECKING([whether to override the default value of NBL_Z])
AC_ARG_ENABLE(nblz, [AC_HELP_STRING([--enable-nblz], [to define loop blocking factor NBL_Z])], nblval=$enableval, nblval="")
if test "$nblval" != ""; then
AC_MSG_RESULT([yes])
AC_DEFINE(NBL_Z, $nblval, [Define if you want to override the default value of NBL_Z])
eval "ARRAY${N}='-DNBL_Z=$nblval'"
N=`expr $N + 1`
else
AC_MSG_RESULT([no])
fi
# check whether to use FFTW
AC_MSG_CHECKING([whether to use FFTW library])
AC_ARG_ENABLE(fftw, [AC_HELP_STRING([--enable-fftw], [for using the FFTW library])], fftwval=$enableval, fftwval=no)
AC_MSG_RESULT([$fftwval])
if test "$fftwval" = "yes"; then
AC_DEFINE(FFTW, 1, [Define if you want to use the FFTW library])
eval "ARRAY${N}='-DFFTW'"
N=`expr $N + 1`
fi
# check whether to use ESSL
AC_MSG_CHECKING([whether to use ESSL library])
AC_ARG_ENABLE(essl, [AC_HELP_STRING([--enable-essl], [for using ESSL (on IBM) in 1D FFTs.])], esslval=$enableval, esslval=no)
AC_MSG_RESULT([$esslval])
if test "$esslval" = "yes"; then
AC_DEFINE(ESSL, 1, [Define if you want to use the ESSL library instead of FFTW])
# AC_SUBST(LDFLAGS,"$LDFLAGS -lessl")
eval "ARRAY${N}='-DESSL'"
N=`expr $N + 1`
fi
# check to see if FFTW or ESSL has been selected
if test "$fftwval" == "no" && test "$esslval" == "no"; then
AC_MSG_ERROR([You must choose to use either ESSL or FFTW!])
fi
# check to see if FFTW and ESSL have both been selected
if test "$fftwval" == "yes" && test "$esslval" == "yes"; then
AC_MSG_ERROR([You must only choose either ESSL or FFTW!])
fi
# check for fftw3
AC_MSG_CHECKING([FFTW directory])
AC_ARG_WITH(fftw, [AC_HELP_STRING([--with-fftw], [path to location of FFTW library])], withfftw=$withval, withfftw="")
if test "$withfftw" != "yes" && test "$withfftw" != ""; then
AC_MSG_RESULT([$withfftw])
if test -e [$withfftw/lib/libfftw3.a ]; then
AC_SUBST(FFTW_INC, "-I$withfftw/include")
AC_SUBST(FFTW_LIB, "$withfftw/lib/libfftw3.a")
elif test -e [$withfftw/lib64/libfftw3.a ]; then
AC_SUBST(FFTW_INC, "-I$withfftw/include")
AC_SUBST(FFTW_LIB, "$withfftw/lib64/libfftw3.a")
else
AC_MSG_ERROR([libfftw3.a was not found in given location!])
fi
if test "$spval" == "yes"; then
AC_SUBST(FFTWF, "$withfftw/lib/libfftw3f.a")
fi
else
AC_MSG_RESULT([none])
if test "$fftwval" == "yes"; then
AC_MSG_ERROR([location to FFTW was not given!])
fi
fi
# check for essl
AC_MSG_CHECKING([ESSL directory])
AC_ARG_WITH(essl, [AC_HELP_STRING([--with-essl], [path to location of ESSL library])], withessl=$withval, withessl="")
if test "$withessl" != "yes" && test "$withessl" != ""; then
AC_MSG_RESULT([$withessl])
if [[ -d $withessl/lib64 ]]; then
AC_SUBST(ESSL_INC, "-I$withessl/include")
AC_SUBST(ESSL_LIB, "-L$withessl/lib64 -lesslbg -L$IBM_MAIN_DIR/xlf_r/bg/14.1/lib64")
else
AC_MSG_ERROR([essl library was not found in given location!])
fi
else
AC_MSG_RESULT([none])
if test "$esslval" == "yes"; then
AC_MSG_ERROR([location to ESSL was not given!])
fi
fi
# construct compiler flags
N=`expr $N - 1`
TMP0=
eval TMP0="\$ARRAY0"
for i in $(seq 1 $N)
do
eval TMP0="\$TMP0' '\$ARRAY${i}"
done
# set C compiler flags
AC_SUBST(CDFLAGS, $TMP0)
# create a new set of flags if compiler is IBM
if test "$enableibm" != "yes"; then
AC_SUBST(FDFLAGS, $TMP0)
else
TMP1=
eval TMP1="-WF,-P"
for i in $(seq 0 $N)
do
eval TMP1="\$TMP1','\$ARRAY${i}"
done
for i in $(seq 0 $N1)
do
eval TMP1="\$TMP1' '\$ARRAY1${i}"
done
AC_SUBST(FDFLAGS, $TMP1)
fi
# Custom strings
AC_SUBST(SUCCESS, "Build successful!")
# Checks for programs.
AC_PROG_FC(mpif90)
AC_CHECK_PROGS(CC, mpicc, $CC)
AC_PROG_RANLIB
AC_PROG_INSTALL
AC_PROG_MAKE_SET
# Checks for libraries.
# Checks for header files.
AC_HEADER_STDC
AC_CHECK_HEADERS([stdlib.h])
# Checks for typedefs, structures, and compiler characteristics.
# Checks for library functions.
AC_FUNC_MALLOC
AC_CONFIG_FILES([Makefile
build/Makefile
sample/Makefile
sample/C/Makefile
sample/FORTRAN/Makefile])
AC_SUBST(TESTLIBS, $TESTLIBS)
AC_OUTPUT()
cp config.h include/config.h
AC_MSG_NOTICE([configure script complete!])