-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
456 lines (392 loc) · 12.4 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
AC_INIT([tci],[1.0],[[email protected]],[tblis],[http://www.github.com/devinamatthews/tci])
AM_INIT_AUTOMAKE([foreign silent-rules subdir-objects])
AM_SILENT_RULES([yes])
AM_MAINTAINER_MODE([disable])
AC_CONFIG_MACRO_DIR([m4])
AC_PROG_CC([icc gcc clang])
AC_PROG_CXX([icpc g++ clang++])
LT_INIT
#
# Get user preferences
#
AC_ARG_ENABLE([mutex], AS_HELP_STRING([--enable-mutex=type],
[use a mutex of the specified type, one of auto, pthread_mutex, \
pthread_spinlock, osx_spinlock, os_unfair_lock, omp_lock, atomic_spinlock @<:@default=auto@:>@]),
[mutex_type=$enable_mutex], [mutex_type=auto])
AC_ARG_ENABLE([barrier], AS_HELP_STRING([--enable-barrier=type],
[use a barrier of the specified type, one of auto, pthread_barrier, \
spin_barrier @<:@default=auto@:>@]),
[barrier_type=$enable_barrier], [barrier_type=auto])
AC_ARG_ENABLE([thread-model], AS_HELP_STRING([--enable-thread-model@<:@=model@:>@],
[enable threading with the specified model, one of none, auto, task, \
openmp, pthreads, tbb, omptask, winthreads, ppl, or dispatch @<:@default=auto@:>@]),
[thread_model=$enable_thread_model], [thread_model=auto])
AC_ARG_ENABLE([threading], AS_HELP_STRING([--enable-threading=@<:@=model@:>@],
[alias for --enable-thread-model]), [thread_model=$enable_threading], [])
if test x"$thread_model" = xno; then
thread_model=none
fi
#
# Check for pthreads
#
AX_PTHREAD([have_pthreads=yes], [have_pthreads=no])
have_pthread_mutex=no
have_pthread_spin=no
have_pthread_barrier=no
if test x$have_pthreads = xyes; then
LIBS_save="$LIBS"
CFLAGS_save="$CFLAGS"
LIBS="$LIBS $PTHREAD_LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
AC_CHECK_FUNCS([pthread_spin_init pthread_mutex_init pthread_barrier_init])
if test x"$ac_cv_header_pthread_h" = xyes -a \
x"$ac_cv_func_pthread_mutex_init" = xyes; then
have_pthread_mutex=yes
fi
if test x"$ac_cv_header_pthread_h" = xyes -a \
x"$ac_cv_func_pthread_spin_init" = xyes; then
have_pthread_spin=yes
fi
if test x"$ac_cv_header_pthread_h" = xyes -a \
x"$ac_cv_func_pthread_barrier_init" = xyes; then
have_pthread_barrier=yes
fi
LIBS="$LIBS_save"
CFLAGS="$CFLAGS_save"
fi
#
# Check for OpenMP
#
AX_OPENMP
CFLAGS_save="$CFLAGS"
CFLAGS="$CFLAGS $OPENMP_CFLAGS"
AC_COMPILE_IFELSE([AC_LANG_SOURCE([[
#include "omp.h"
#ifndef _OPENMP
#error
#endif
]])], [have_openmp="yes"], [have_openmp="no"])
CFLAGS="$CFLAGS_save"
#
# Check for TBB
#
AC_LANG_PUSH([C++])
LIBS_save="$LIBS"
AC_CHECK_HEADERS([tbb/tbb.h])
AC_SEARCH_LIBS([TBB_runtime_interface_version], [tbb])
if test x"$ac_cv_header_tbb_tbb_h" = xyes && \
test x"$ac_cv_search_TBB_runtime_interface_version" != xno; then
have_tbb=yes
if test x"$ac_cv_search_TBB_runtime_interface_version" != "xnone required"; then
TBB_LIBS="$ac_cv_search_TBB_runtime_interface_version"
fi
else
have_tbb=no
fi
LIBS="$LIBS_save"
AC_LANG_POP
#
# Check for libdispatch
#
LIBS_save="$LIBS"
AC_CHECK_HEADERS([dispatch/dispatch.h])
AC_SEARCH_LIBS([dispatch_async_f], [dispatch])
if test x"$ac_cv_header_dispatch_dispatch_h" = xyes && \
test x"$ac_cv_search_dispatch_async_f" != xno; then
have_gcd=yes
if test x"$ac_cv_search_dispatch_async_f" != "xnone required"; then
DISPATCH_LIBS="$ac_cv_search_dispatch_async_f"
fi
else
have_gcd=no
fi
LIBS="$LIBS_save"
#
# Check for Windows
#
AC_CHECK_HEADERS([windows.h])
if test x"$ac_cv_header_windows_h" = xyes; then
have_windows=yes
else
have_windows=no
fi
#
# Check for PPL
#
LIBS_save="$LIBS"
AC_CHECK_HEADERS([ppl.h])
if test x"$ac_cv_header_ppl_h" = xyes; then
have_ppl=yes
else
have_ppl=no
fi
#
# Check for os_unfair_lock
#
AC_CHECK_HEADER([os/lock.h])
AC_CHECK_FUNCS([os_unfair_lock_lock])
if test x"$ac_cv_header_os_lock_h" = xyes -a \
x"$ac_cv_func_os_unfair_lock_lock" = xyes; then
have_os_unfair_lock=yes
else
have_os_unfair_lock=no
fi
#
# Check for OSSpinLock
#
AC_CHECK_HEADER([libkern/OSAtomic.h])
AC_CHECK_FUNCS([OSSpinLockLock])
if test x"$ac_cv_header_libkern_OSAtomic_h" = xyes -a \
x"$ac_cv_func_OSSpinLockLock" = xyes; then
have_osx_spinlock=yes
else
have_osx_spinlock=no
fi
#
# Check for __atomic builtins
#
AX_GCC_BUILTIN(__atomic_load_n)
AX_GCC_BUILTIN(__atomic_load)
AX_GCC_BUILTIN(__atomic_store_n)
AX_GCC_BUILTIN(__atomic_store)
AX_GCC_BUILTIN(__atomic_exchange_n)
AX_GCC_BUILTIN(__atomic_exchange)
AX_GCC_BUILTIN(__atomic_compare_exchange_n)
AX_GCC_BUILTIN(__atomic_compare_exchange)
AX_GCC_BUILTIN(__atomic_add_fetch)
AX_GCC_BUILTIN(__atomic_sub_fetch)
AX_GCC_BUILTIN(__atomic_and_fetch)
AX_GCC_BUILTIN(__atomic_xor_fetch)
AX_GCC_BUILTIN(__atomic_or_fetch)
AX_GCC_BUILTIN(__atomic_nand_fetch)
AX_GCC_BUILTIN(__atomic_fetch_add)
AX_GCC_BUILTIN(__atomic_fetch_sub)
AX_GCC_BUILTIN(__atomic_fetch_and)
AX_GCC_BUILTIN(__atomic_fetch_xor)
AX_GCC_BUILTIN(__atomic_fetch_or)
AX_GCC_BUILTIN(__atomic_fetch_nand)
AX_GCC_BUILTIN(__atomic_test_and_set)
AX_GCC_BUILTIN(__atomic_clear)
AX_GCC_BUILTIN(__atomic_thread_fence)
AX_GCC_BUILTIN(__atomic_signal_fence)
AX_GCC_BUILTIN(__atomic_always_lock_free)
AX_GCC_BUILTIN(__atomic_is_lock_free)
if test x"$ax_cv_have___atomic_load_n" = xno -o \
x"$ax_cv_have___atomic_load" = xno -o \
x"$ax_cv_have___atomic_store_n" = xno -o \
x"$ax_cv_have___atomic_store" = xno -o \
x"$ax_cv_have___atomic_exchange_n" = xno -o \
x"$ax_cv_have___atomic_exchange" = xno -o \
x"$ax_cv_have___atomic_compare_exchange_n" = xno -o \
x"$ax_cv_have___atomic_compare_exchange" = xno -o \
x"$ax_cv_have___atomic_add_fetch" = xno -o \
x"$ax_cv_have___atomic_sub_fetch" = xno -o \
x"$ax_cv_have___atomic_and_fetch" = xno -o \
x"$ax_cv_have___atomic_xor_fetch" = xno -o \
x"$ax_cv_have___atomic_or_fetch" = xno -o \
x"$ax_cv_have___atomic_nand_fetch" = xno -o \
x"$ax_cv_have___atomic_fetch_add" = xno -o \
x"$ax_cv_have___atomic_fetch_sub" = xno -o \
x"$ax_cv_have___atomic_fetch_and" = xno -o \
x"$ax_cv_have___atomic_fetch_xor" = xno -o \
x"$ax_cv_have___atomic_fetch_or" = xno -o \
x"$ax_cv_have___atomic_fetch_nand" = xno -o \
x"$ax_cv_have___atomic_test_and_set" = xno -o \
x"$ax_cv_have___atomic_clear" = xno -o \
x"$ax_cv_have___atomic_thread_fence" = xno -o \
x"$ax_cv_have___atomic_signal_fence" = xno -o \
x"$ax_cv_have___atomic_always_lock_free" = xno -o \
x"$ax_cv_have___atomic_is_lock_free" = xno; then
AC_MSG_ERROR([__atomic builtins required])
fi
#
# Check for libatomic
#
AC_SEARCH_LIBS([__atomic_compare_exchange_16], [atomic])
#
# Determine mutex type
#
if test x"$mutex_type" = xauto; then
if test x"$have_os_unfair_lock" = xyes; then
mutex_type=os_unfair_lock
elif test x"$have_osx_spinlock" = xyes; then
mutex_type=osx_spinlock
elif test x"$have_pthread_spinlock" = xyes; then
mutex_type=pthread_spinlock
else
mutex_type=atomic_spinlock
fi
fi
USE_PTHREAD_MUTEX=0
USE_PTHREAD_SPINLOCK=0
USE_OS_UNFAIR_LOCK=0
USE_OSX_SPINLOCK=0
USE_OMP_LOCK=0
USE_ATOMIC_SPINLOCK=0
AC_MSG_CHECKING([mutex type])
if test x"$mutex_type" = xpthread_mutex; then
if test x"$have_pthread_mutex" = xno; then
AC_MSG_ERROR([pthread mutex requested but not available])
fi
USE_PTHREAD_MUTEX=1
elif test x"$mutex_type" = xpthread_spinlock; then
if test x"$have_pthread_spinlock" = xno; then
AC_MSG_ERROR([pthread spinlock requested but not available])
fi
USE_PTHREAD_SPINLOCK=1
elif test x"$mutex_type" = xos_unfair_lock; then
if test x"$have_os_unfair_lock" = xno; then
AC_MSG_ERROR([macOS os_unfair_lock requested but not available])
fi
USE_OS_UNFAIR_LOCK=1
elif test x"$mutex_type" = xosx_spinlock; then
if test x"$have_osx_spinlock" = xno; then
AC_MSG_ERROR([OSX OSSpinLock requested but not available])
fi
USE_OSX_SPINLOCK=1
elif test x"$mutex_type" = xomp_lock; then
if test x"$have_openmp" = xno; then
AC_MSG_ERROR([omp_lock requested but not available])
fi
USE_OMP_LOCK=1
elif test x"$mutex_type" = xatomic_spinlock; then
USE_ATOMIC_SPINLOCK=1
else
AC_MSG_ERROR([invalid mutex type specified])
fi
AC_MSG_RESULT([$mutex_type])
AC_SUBST([USE_PTHREAD_MUTEX])
AC_SUBST([USE_PTHREAD_SPINLOCK])
AC_SUBST([USE_OS_UNFAIR_LOCK])
AC_SUBST([USE_OSX_SPINLOCK])
AC_SUBST([USE_OMP_LOCK])
AC_SUBST([USE_ATOMIC_SPINLOCK])
#
# Determine barrier type
#
if test x"$barrier_type" = xauto; then
barrier_type=spin_barrier
fi
USE_PTHREAD_BARRIER=0
USE_SPIN_BARRIER=0
AC_MSG_CHECKING([barrier type])
if test x"$barrier_type" = xpthread_barrier; then
if test x"$have_pthread_barrier" = xno; then
AC_MSG_ERROR([pthread barrier requested but not available])
fi
USE_PTHREAD_BARRIER=1
elif test x"$barrier_type" = xspin_barrier; then
USE_SPIN_BARRIER=1
else
AC_MSG_ERROR([invalid barrier type specified])
fi
AC_MSG_RESULT([$barrier_type])
AC_SUBST([USE_PTHREAD_BARRIER])
AC_SUBST([USE_SPIN_BARRIER])
#
# Determine thread model
#
if test x"$thread_model" = xauto; then
if test x"$have_openmp" = xyes; then
thread_model=openmp
elif test x"$have_pthreads" = xyes; then
thread_model=pthread
elif test x"$have_windows" = xyes; then
thread_model=windows
elif test x"$have_tbb" = xyes; then
thread_model=tbb
elif test x"$have_ppl" = xyes; then
thread_model=ppl
elif test x"$have_dispatch" = xyes; then
thread_model=dispatch
else
thread_model=none
fi
elif test x"$thread_model" = xtask; then
if test x"$have_tbb" = xyes; then
thread_model=tbb
elif test x"$have_ppl" = xyes; then
thread_model=ppl
elif test x"$have_dispatch" = xyes; then
thread_model=dispatch
elif test x"$have_openmp" = xyes; then
thread_model=omptask
else
thread_model=none
fi
fi
USE_OPENMP_THREADS=0
USE_PTHREADS_THREADS=0
USE_TBB_THREADS=0
USE_DISPATCH_THREADS=0
USE_WINDOWS_THREADS=0
USE_PPL_THREADS=0
USE_OMPTASK_THREADS=0
AC_MSG_CHECKING([thread model])
if test x"$thread_model" = xopenmp; then
if test x"$have_openmp" = xno; then
AC_MSG_ERROR([openmp requested but not available])
fi
USE_OPENMP_THREADS=1
CFLAGS="$CFLAGS $OPENMP_CFLAGS"
CXXFLAGS="$CXXFLAGS $OPENMP_CFLAGS"
elif test x"$thread_model" = xomptask; then
if test x"$have_openmp" = xno; then
AC_MSG_ERROR([omptask requested but not available])
fi
USE_OMPTASK_THREADS=1
CFLAGS="$CFLAGS $OPENMP_CFLAGS"
CXXFLAGS="$CXXFLAGS $OPENMP_CFLAGS"
elif test x"$thread_model" = xpthread || \
test x"$thread_model" = xpthreads; then
if test x"$have_pthreads" = xno; then
AC_MSG_ERROR([pthreads requested but not available])
fi
USE_PTHREADS_THREADS=1
LIBS="$LIBS $PTHREAD_LIBS"
CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
elif test x"$thread_model" = xtbb; then
if test x"$have_tbb" = xno; then
AC_MSG_ERROR([tbb requested but not available])
fi
USE_TBB_THREADS=1
LIBS="$LIBS $TBB_LIBS"
elif test x"$thread_model" = xdispatch || \
test x"$thread_model" = xlibdispatch || \
test x"$thread_model" = xgcd; then
if test x"$have_dispatch" = xno; then
AC_MSG_ERROR([dispatch requested but not available])
fi
USE_DISPATCH_THREADS=1
LIBS="$LIBS $DISPATCH_LIBS"
elif test x"$thread_model" = xwindows || \
test x"$thread_model" = xwinthreads; then
if test x"$have_windows" = xno; then
AC_MSG_ERROR([winthreads requested but not available])
fi
USE_WINDOWS_THREADS=1
elif test x"$thread_model" = xppl; then
if test x"$have_windows" = xno || \
test x"$have_ppl" = xno; then
AC_MSG_ERROR([ppl requested but not available])
fi
USE_PPL_THREADS=1
elif test x"$thread_model" != xnone; then
AC_MSG_ERROR([Invalid threading model specified.])
fi
AC_MSG_RESULT([$thread_model])
AC_SUBST([USE_OPENMP_THREADS])
AC_SUBST([USE_OMPTASK_THREADS])
AC_SUBST([USE_PTHREADS_THREADS])
AC_SUBST([USE_TBB_THREADS])
AC_SUBST([USE_PPL_THREADS])
AC_SUBST([USE_WINDOWS_THREADS])
AC_SUBST([USE_DISPATCH_THREADS])
AM_CONDITIONAL([CPLUSPLUS], [test x$USE_TBB_THREADS = x1 || \
test x$USE_PPL_THREADS = x1])
if test x$USE_TBB_THREADS = x1 || \
test x$USE_PPL_THREADS = x1; then
AX_CXX_COMPILE_STDCXX([17], [noext])
fi
AC_CONFIG_FILES([Makefile tci/tci_config.h])
AC_OUTPUT