-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
469 lines (420 loc) · 16.5 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
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.69])
########################################
# Generate releaes version
########################################
m4_include([maint/version.m4])
dnl 2nd arg is intentionally underquoted
AC_INIT([OSHMPI],
OSHMPI_VERSION_m4,
[oshmpi],
[https://github.com/pmodels/oshmpi])
# build info
CONFIGURE_ARGS_CLEAN=`echo $* | tr '"' ' '`
# these values come from the m4_include above
OSHMPI_VERSION=OSHMPI_VERSION_m4
AC_SUBST(OSHMPI_VERSION)
OSHMPI_RELEASE_DATE="OSHMPI_RELEASE_DATE_m4"
AC_SUBST(OSHMPI_RELEASE_DATE)
if test -z "$OSHMPI_VERSION" ; then
AC_MSG_ERROR([OSHMPI_VERSION is empty, check maint/version.m4 for errors])
fi
# Produce a numeric version assuming the following format:
# Version: [MAJ].[MIN].[REV][EXT][EXT_NUMBER]
# Example: 1.0.7rc1 has
# MAJ = 1
# MIN = 0
# REV = 7
# EXT = rc
# EXT_NUMBER = 1
#
# Converting to numeric version will convert EXT to a format number:
# ALPHA (a) = 0
# BETA (b) = 1
# RC (rc) = 2
# PATCH (p) = 3
# Regular releases are treated as patch 0
#
# Numeric version will have 1 digit for MAJ, 2 digits for MIN,
# 2 digits for REV, 1 digit for EXT and 2 digits for EXT_NUMBER.
changequote(<<,>>)
V1=`expr $OSHMPI_VERSION : '\([0-9]*\)\.[0-9]*\.*[0-9]*[a-zA-Z]*[0-9]*'`
V2=`expr $OSHMPI_VERSION : '[0-9]*\.\([0-9]*\)\.*[0-9]*[a-zA-Z]*[0-9]*'`
V3=`expr $OSHMPI_VERSION : '[0-9]*\.[0-9]*\.*\([0-9]*\)[a-zA-Z]*[0-9]*'`
V4=`expr $OSHMPI_VERSION : '[0-9]*\.[0-9]*\.*[0-9]*\([a-zA-Z]*\)[0-9]*'`
V5=`expr $OSHMPI_VERSION : '[0-9]*\.[0-9]*\.*[0-9]*[a-zA-Z]*\([0-9]*\)'`
changequote([,])
if test "$V2" -le 9 ; then V2=0$V2 ; fi
if test "$V3" = "" ; then V3=0; fi
if test "$V3" -le 9 ; then V3=0$V3 ; fi
if test "$V4" = "a" ; then
V4=0
elif test "$V4" = "b" ; then
V4=1
elif test "$V4" = "rc" ; then
V4=2
elif test "$V4" = "" ; then
V4=3
V5=0
elif test "$V4" = "p" ; then
V4=3
fi
if test "$V5" -le 9 ; then V5=0$V5 ; fi
OSHMPI_NUMVERSION=`expr $V1$V2$V3$V4$V5 + 0`
AC_SUBST(OSHMPI_NUMVERSION)
########################################
# Check and configure setup
########################################
AC_CONFIG_AUX_DIR(confdb)
AC_CONFIG_MACRO_DIR(confdb)
# needed by hwloc in embedded mode. Must come very early to avoid
# bizarre expansion ordering warnings
AC_CANONICAL_TARGET
AC_ARG_PROGRAM
# also needed by hwloc in embedded mode, must also come early for expansion
# ordering reasons
AC_USE_SYSTEM_EXTENSIONS
AM_INIT_AUTOMAKE([-Wall -Werror -Wno-portability-recursive silent-rules foreign 1.12.3 subdir-objects])
# Bug in libtool adds -O2 and -g by default
PAC_PUSH_FLAG([CFLAGS])
AC_PROG_CC(mpicc)
PAC_POP_FLAG([CFLAGS])
# suppress default "-g -O2" from AC_PROG_CXX
: ${CXXFLAGS=""}
# Bug in automake always check dependency even AC_PROG_CXX is conditionally checked.
AC_PROG_CXX(mpicxx)
AM_PROG_AR
LT_PREREQ([2.2.6])
# Set the appropriate macro for different platform
AS_CASE([$host_os],
[darwin*],
[AC_DEFINE(USE_OSX,1,[Define on Apple OSX.])],
[linux*],
[AC_DEFINE(USE_LINUX,1,[Define on Linux.])],
[freebsd*],
[AC_DEFINE(USE_FREEBSD,1,[Define on FreeBSD.])],
[AC_MSG_ERROR([Unsupported operating system.])]
)
AC_CONFIG_HEADER([include/oshmpiconf.h])
# Bug in libtool adds -O2 and -g by default
PAC_PUSH_FLAG([CFLAGS])
LT_INIT()
PAC_POP_FLAG([CFLAGS])
CONFIGURE_ARGS_CLEAN="$CONFIGURE_ARGS_CLEAN CC=$CC CFLAGS=$CFLAGS "
CONFIGURE_ARGS_CLEAN="$CONFIGURE_ARGS_CLEAN LDFLAGS=$LDFLAGS LIBS=$LIBS CPPFLAGS=$CPPFLAGS "
CONFIGURE_ARGS_CLEAN="$CONFIGURE_ARGS_CLEAN $BUILD_INFO LT_SYS_LIBRARY_PATH=$LT_SYS_LIBRARY_PATH CPP=$CPP"
AC_SUBST(CONFIGURE_ARGS_CLEAN)
## Check for C99
AC_PROG_CC_C99
if test "$ac_cv_prog_cc_c99" = "no" ; then
AC_ERROR([C99 not supported by the compiler])
fi
# Checks for header files.
AC_CHECK_HEADERS([stdlib.h mpi.h])
# Checks for library functions.
AC_CHECK_FUNCS([memset memcpy atol atexit])
# Non-verbose make
m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
# Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_C_RESTRICT
AC_C_INLINE
# Get top srcdir
# This test is complicated by the fact that top_srcdir is not set until
# the very end of configure. Instead, we get it ourselves
if test -z "$top_srcdir" ; then
oshmpi_top_srcdir=$srcdir
else
oshmpi_top_srcdir=$top_srcdir
fi
if test -z "$oshmpi_top_srcdir" ; then
# This needs to be an absolute pathname
case "$oshmpi_top_srcdir" in
/*) ;;
*)
oshmpi_top_srcdir=`(cd $oshmpi_top_srcdir && pwd)`
;;
esac
fi
# Get the directory that we're running in...
if test -z "$oshmpi_top_builddir" ; then
oshmpi_top_builddir="`pwd`"
fi
# Check MPI version support
AC_DEFUN([UD_CHECK_MPI_VERSION], [
AC_MSG_CHECKING(if MPI_VERSION=$1 defined)
AC_RUN_IFELSE(
[AC_LANG_SOURCE([
#include <stdlib.h>
#include "mpi.h"
int main (int argc, char **argv) {
if(MPI_VERSION != $1) exit (-1);
}])],
AC_MSG_RESULT(yes)
have_mpi$1=yes,
AC_MSG_RESULT(no)
have_mpi$1=no
AC_MSG_ERROR([MPI-$1 is required.]))
])
UD_CHECK_MPI_VERSION(3)
AC_CHECK_FUNCS([MPI_Ibarrier MPI_Ibcast MPI_Iallreduce MPI_Ialltoall MPI_Iallgather MPI_Iallgatherv])
## Fast build (statically disable debug messages, disable assert)
AC_ARG_ENABLE(fast, AC_HELP_STRING([--enable-fast],[Enable fast execution of OSHMPI implementation.
It disables runtime control of debug message and disables all internal
error checking [default=no]]),
[ enable_fast=$enableval ],
[ enable_fast=no ])
AC_MSG_CHECKING(fast build support)
AC_MSG_RESULT($enable_fast)
if test "$enable_fast" = "yes"; then
CFLAGS="-O2 -DOSHMPI_ENABLE_FAST" # Overwrite default -g -O2
fi
## Debugging support
AC_ARG_ENABLE(g, AC_HELP_STRING([--enable-g],[Turn on debugging [default=no]]),
[ enable_debug=$enableval ],
[ enable_debug=no ])
AC_MSG_CHECKING(debugging support)
AC_MSG_RESULT($enable_debug)
# always disable debug if enable_fast is set
if test "$enable_fast" = "no"; then
if test "$enable_debug" = "yes"; then
CFLAGS="-g -O0 -DOSHMPI_ENABLE_DBG" # Overwrite default -g -O2
fi
fi
# Check for enabling strict
PAC_ARG_STRICT
# Check for support for weak symbols.
AC_ARG_ENABLE(weak-symbols, AC_HELP_STRING([--enable-weak-symbols],
[Use weak symbols to implement PSHMEM routines [default=yes]]),,
enable_weak_symbols=yes)
if test $enable_weak_symbols = yes ; then
# Turn off weak symbols if they aren't available
PAC_PROG_C_WEAK_SYMBOLS(,enable_weak_symbols=no)
fi
if test $enable_weak_symbols = "yes" ; then
AC_DEFINE(USE_WEAK_SYMBOLS,1,[Define if weak symbols should be used])
# Check for the ability to support multiple weak symbols
if test "$pac_cv_prog_c_weak_symbols" = "pragma weak" ; then
PAC_PROG_C_MULTIPLE_WEAK_SYMBOLS(AC_DEFINE(HAVE_MULTIPLE_PRAGMA_WEAK,1,[Define if multiple weak symbols may be defined]))
fi
fi
# Check for C++ binding
AC_ARG_ENABLE(cxx, AC_HELP_STRING([--enable-cxx],
[Enable C++ bindings [default=yes]]),,
enable_cxx=yes)
if test $enable_cxx = "yes" ; then
AC_MSG_CHECKING(if mpicxx is provided)
AC_LANG_PUSH([C++])
AC_COMPILE_IFELSE([AC_LANG_SOURCE([
#include <mpi.h>
])],
AC_MSG_RESULT(yes),
AC_MSG_RESULT(no)
AC_MSG_ERROR([mpicxx is required.]))
AC_LANG_POP([C++])
AC_DEFINE(OSHMPI_HAVE_CXX,1,[Define if C++ binding is enabled])
fi
AM_CONDITIONAL([OSHMPI_HAVE_CXX], [test "$enable_cxx" == "yes" ])
# Thread-safety
AC_ARG_ENABLE(threads,
[ --enable-threads=[option]
Choose OSHMPI thread safety level. Set multiple by default.
For program uses single/funneled/serialized thread levels, it is
recommanded to set lower thread-safety to avoid internal overhead
when possible. Supported options include:
single - No threads (SHMEM_THREAD_SINGLE)
funneled - Only the main thread calls SHMEM (SHMEM_THREAD_FUNNELED)
serialized - User serializes calls to SHMEM (SHMEM_THREAD_SERIALIZED)
multiple - Fully multi-threaded (SHMEM_THREAD_MULTIPLE)],
[ enable_threads=$enableval ],
[ enable_threads=multiple ])
AC_MSG_CHECKING(Thread safety support)
AC_MSG_RESULT($enable_threads)
case $enable_threads in
single)
AC_DEFINE(OSHMPI_ENABLE_THREAD_SINGLE,1,[Define if single thread safety is set at configure])
;;
funneled)
AC_DEFINE(OSHMPI_ENABLE_THREAD_FUNNELED,1,[Define if funneled thread safety is set at configure])
;;
serialized)
AC_DEFINE(OSHMPI_ENABLE_THREAD_SERIALIZED,1,[Define if serialized thread safety is set at configure])
;;
multiple)
AC_DEFINE(OSHMPI_ENABLE_THREAD_MULTIPLE,1,[Define if multiple thread safety is set at configure])
;;
*)
AC_MSG_ERROR([Unknown thread safety, $enable_threads.])
;;
esac
## Check for AMO method
AC_ARG_ENABLE(amo,
[ --enable-amo=[option]
Choose AMO implementing methods.
Because MPI-3 guanrantees atomicity only for same_op_no_op or same_op
accumulates, we cannot directly use MPI accumulates in OpenSHMEM AMO
which can be any_op. Instead, we have to fallback all AMOs to active
message in OSHMPI. However, OSHMPI accepts special user hints which provide
same restriction to same_op_no_op or same_op (see OSHMPI_AMO_OPS in README),
hence direct AMO can be enabled at runtime.
Supported options include:
auto - runtime chooses direct or am methods based on user hints (default)
direct - force direct amo where all atomics uses MPI accumulates
am - force active message based amo.],
[ enable_amo=$enableval ],
[ enable_amo=auto ])
AC_MSG_CHECKING(atomics method)
AC_MSG_RESULT($enable_amo)
case $enable_amo in
direct)
AC_DEFINE_UNQUOTED(OSHMPI_ENABLE_DIRECT_AMO,1,[Force to use direct atomics no matter whether MPI supports it])
;;
am)
AC_DEFINE_UNQUOTED(OSHMPI_ENABLE_AM_AMO,1,[Force to use active message based atomics])
;;
auto)
;;
*)
AC_MSG_ERROR([Unknown AMO implementation method, $enable_amo.])
;;
esac
## Async thread support
AC_ARG_ENABLE(async-thread,
[ --enable-async-thread=[option]
Enable asynchronous progress thread.
Supported options include:
yes - always enable asynchronous thread
no - disable asynchronous thread (default)
runtime - enable by setting envioronment variable OSHMPI_ENABLE_ASYNC_THREAD.],
[ enable_async_thread=$enableval ],
[ enable_async_thread=no ])
AC_MSG_CHECKING(asynchronous thread support)
AC_MSG_RESULT($enable_async_thread)
# enable async thread only when am AMO may be used
if test "$enable_amo" == "direct" ; then
enable_async_thread=no
fi
if test "$enable_async_thread" != "no" ; then
if test "$enable_threads" == "multiple"; then
case $enable_async_thread in
yes)
AC_DEFINE_UNQUOTED(OSHMPI_ENABLE_AMO_ASYNC_THREAD,1,[Enable asynchronous progress thread])
;;
runtime)
AC_DEFINE_UNQUOTED(OSHMPI_RUNTIME_AMO_ASYNC_THREAD,1,[Turn on runtime control of asynchronous progress thread])
;;
*)
AC_MSG_ERROR([Unknown asynchronous progress thread option, $enable_async_thread.])
;;
esac
else
AC_MSG_ERROR([To enable asynchronous thread, multiple thread safety is required, but $enable_threads is set.])
fi
fi
# OPA library used for thread atomic operations in multitheaded program
opasrcdir=""
AC_SUBST([opasrcdir])
opalibdir=""
AC_SUBST([opalibdir])
opalib=""
AC_SUBST([opalib])
if test "$enable_threads" == "multiple"; then
if test -e "${oshmpi_top_srcdir}/src/openpa" ; then
opasrcdir="src/openpa"
# only need header files
PAC_APPEND_FLAG([-I${oshmpi_top_srcdir}/${opasrcdir}/src],[CPPFLAGS])
PAC_APPEND_FLAG([-I${oshmpi_top_builddir}/${opasrcdir}/src],[CPPFLAGS])
# no need for libtool versioning when embedding OPA
opa_subdir_args="--disable-versioning --enable-embedded"
PAC_CONFIG_SUBDIR_ARGS([$opasrcdir],[$opa_subdir_args],[],[AC_MSG_ERROR([OpenPA configure failed])])
else
AC_MSG_ERROR([unable to find embedded OpenPA source in "src/openpa".])
fi
fi
# Thread package used in critical section and asynchronous thread
AC_ARG_WITH([thread-package],
[ --with-thread-package=posix|pthread
Thread package to implement internal critical section
when multiple threads are present. Supported thread
packages include:
posix or pthreads - POSIX threads (default)
],,with_thread_package=default)
AC_MSG_CHECKING(Thread package to implement critical section)
AC_MSG_RESULT($with_thread_package)
if test "$enable_threads" == "multiple"; then
THREAD_PACKAGE_NAME=NONE
case $with_thread_package in
default|posix|pthreads)
# check if pthread is supported (e.g., invalid on windows or solaris)
have_pthreads=no
AC_CHECK_HEADERS(pthread.h)
AC_CHECK_LIB([pthread],[pthread_create],have_lpthread=yes)
if test "$have_lpthread" = "yes" ; then
PAC_PREPEND_FLAG([-lpthread],[LIBS])
# this check should come after the AC_CHECK_LIB for -lpthread
AC_CHECK_FUNCS([pthread_mutex_lock],have_pthreads=yes,AC_MSG_ERROR([unable to find pthreads library.]))
fi
THREAD_PACKAGE_NAME=OSHMPI_THREAD_CS_LOCK__PTHREAD_MUTEX
;;
*)
AC_MSG_ERROR([The specified thread package, $with_thread_package, is not supported.])
;;
esac
AC_DEFINE_UNQUOTED(OSHMPI_THREAD_CS_LOCK,[$THREAD_PACKAGE_NAME],
[Thread package to implement critical section])
fi
# check for attribute support
PAC_C_GNU_ATTRIBUTE
AX_GCC_FUNC_ATTRIBUTE(noreturn)
# check noreturn attribute
PAC_PUSH_ALL_FLAGS
dnl This check requires removing -Wall and -Wextra first or it will fail. Just
dnl clear them all.
CFLAGS=""
AX_GCC_FUNC_ATTRIBUTE(noreturn)
PAC_POP_ALL_FLAGS
# Define corresponding MPI datatypes
# size_t is a unsigned integer type
AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(uint8_t)
AC_CHECK_SIZEOF(uint16_t)
AC_CHECK_SIZEOF(uint32_t)
AC_CHECK_SIZEOF(uint64_t)
# ptrdiff_t is a signed integer type
AC_CHECK_SIZEOF(ptrdiff_t)
AC_CHECK_SIZEOF(int8_t)
AC_CHECK_SIZEOF(int16_t)
AC_CHECK_SIZEOF(int32_t)
AC_CHECK_SIZEOF(int64_t)
if test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_uint8_t"; then
OSHMPI_MPI_SIZE_T=MPI_UINT8_T
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_uint16_t"; then
OSHMPI_MPI_SIZE_T=MPI_UINT16_T
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_uint32_t"; then
OSHMPI_MPI_SIZE_T=MPI_UINT32_T
elif test "$ac_cv_sizeof_size_t" = "$ac_cv_sizeof_uint64_t"; then
OSHMPI_MPI_SIZE_T=MPI_UINT64_T
else
AC_MSG_ERROR([size of size_t is $ac_cv_sizeof_size_t, cannot find corresponding MPI datatype.])
fi
AC_DEFINE_UNQUOTED(OSHMPI_MPI_SIZE_T,$OSHMPI_MPI_SIZE_T,[MPI datatype to use for size_t])
if test "$ac_cv_sizeof_ptrdiff_t" = "$ac_cv_sizeof_int8_t"; then
OSHMPI_MPI_PTRDIFF_T=MPI_INT8_T
elif test "$ac_cv_sizeof_ptrdiff_t" = "$ac_cv_sizeof_int16_t"; then
OSHMPI_MPI_PTRDIFF_T=MPI_INT16_T
elif test "$ac_cv_sizeof_ptrdiff_t" = "$ac_cv_sizeof_int32_t"; then
OSHMPI_MPI_PTRDIFF_T=MPI_INT32_T
elif test "$ac_cv_sizeof_ptrdiff_t" = "$ac_cv_sizeof_int64_t"; then
OSHMPI_MPI_PTRDIFF_T=MPI_INT64_T
else
AC_MSG_ERROR([size of ptrdiff_t is $ac_cv_sizeof_ptrdiff_t, cannot find corresponding MPI datatype.])
fi
AC_DEFINE_UNQUOTED(OSHMPI_MPI_PTRDIFF_T,$OSHMPI_MPI_PTRDIFF_T,[MPI datatype to use for ptrdiff_t])
AC_CONFIG_FILES([include/shmem.h
include/shmemx.h
include/shmemx.fh])
AC_CONFIG_FILES([Makefile])
AC_CONFIG_SUBDIRS([tests])
AC_OUTPUT