-
Notifications
You must be signed in to change notification settings - Fork 60
/
configure.ac
3379 lines (3046 loc) · 117 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
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# This file is part of SWIFT.
# Copyright (C) 2012 [email protected].
# 2016 [email protected].
#
# This program 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.
#
# This program 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 this program. If not, see <http://www.gnu.org/licenses/>.
# Init the project.
AC_INIT([SWIFT],[1.0.0],[https://gitlab.cosma.dur.ac.uk/swift/swiftsim])
swift_config_flags="$*"
AC_COPYRIGHT
AC_CONFIG_SRCDIR([src/space.c])
AC_CONFIG_AUX_DIR([.])
AM_INIT_AUTOMAKE([subdir-objects])
# Add local macro collection.
AC_CONFIG_MACRO_DIR([m4])
# Stop default CFLAGS from anyone except the environment.
: ${CFLAGS=""}
# Generate header file.
AC_CONFIG_HEADERS([config.h])
# Find and test the compiler.
AX_CHECK_ENABLE_DEBUG
# Enable POSIX and platform extension preprocessor macros.
AC_USE_SYSTEM_EXTENSIONS
AC_PROG_CC
AM_PROG_CC_C_O
# We need this for compilation hints and possibly FFTW.
AX_OPENMP
# If debug is selected then we also define SWIFT_DEVELOP_MODE to control
# any developer code options.
if test "x$ax_enable_debug" != "xno"; then
AC_DEFINE([SWIFT_DEVELOP_MODE],1,[Enable developer code options])
fi
# C++ in GCC 6 and above has an issue with undefined the min() and max()
# macros. This hack works around that.
AC_DEFINE([_GLIBCXX_INCLUDE_NEXT_C_HEADERS],1,[Hack for min() and max() using g++ 6+])
# Enable POSIX and platform extension preprocessor macros.
AC_USE_SYSTEM_EXTENSIONS
# Check for C compiler version and vendor.
AX_COMPILER_VENDOR
AX_COMPILER_VERSION
# Check whether we have a recent enough GCC
if test "$ax_cv_c_compiler_vendor" = "gnu"; then
AX_COMPARE_VERSION([$ax_cv_c_compiler_version], [ge], [8.1.0],
[gcc_handles_avx512="yes"],
[gcc_handles_avx512="no"])
fi
# Restrict support.
AC_C_RESTRICT
# CSDS
AC_ARG_ENABLE([csds],
[AS_HELP_STRING([--enable-csds],
[enable the Continuous Simulation Data Stream]
)],
[with_csds="${enableval}"],
[with_csds="no"]
)
if test "$with_csds" = "yes"; then
AC_DEFINE([WITH_CSDS], 1, [csds enabled])
# Ensure that the submodule is initialized
${srcdir}/tools/update-modules csds
# The csds requires that long long is a 64bit type, let's
# check that.
AC_CHECK_SIZEOF([long long int])
if test "$ac_cv_sizeof_long_long_int" != "8"; then
AC_MSG_ERROR([The CSDS requires that 'long long int' has size 8 bytes])
fi
AC_CONFIG_SUBDIRS([csds])
CFLAGS="$CFLAGS $OPENMP_CFLAGS"
fi
AM_CONDITIONAL([HAVECSDS],[test $with_csds = "yes"])
# Use best known optimization for the current architecture. Actual optimization
# happens later so we can avoid any issues it introduces with the compiler,
# but we need to know if that will happen now.
AC_ARG_ENABLE([optimization],
[AS_HELP_STRING([--enable-optimization],
[Enable compile time optimization flags for host @<:@yes/no@:>@]
)],
[enable_opt="$enableval"],
[enable_opt="yes"]
)
# Interprocedural optimization support. Can need special handling for linking
# and archiving as well as compilation. Needs to be done before libtool is
# configured so we use the correct LD. It can give good improvements for
# clang based compilers, so the default is enabled, but we make that
# disabled when not optimizing or debugging support is enabled.
enable_ipo_default="yes";
if test "x$ax_enable_debug" = "xyes" -o "x$enable_opt" != "xyes"; then
enable_ipo_default="no";
AC_MSG_WARN([Interprocedural optimization support default is changed to false])
fi
AC_ARG_ENABLE([ipo],
[AS_HELP_STRING([--enable-ipo],
[Enable interprocedural optimization [default=yes unless debugging]]
)],
[enable_ipo="$enableval"],
[enable_ipo="$enable_ipo_default"]
)
if test "$enable_ipo" = "yes"; then
if test "$ax_cv_c_compiler_vendor" = "intel"; then
CFLAGS="$CFLAGS -ip -ipo"
LDFLAGS="$LDFLAGS -ipo"
AC_CHECK_PROGS([AR], [xiar])
AC_CHECK_PROGS([LD], [xild])
AC_MSG_RESULT([added Intel interprocedural optimization support])
elif test "$ax_cv_c_compiler_vendor" = "oneapi"; then
CFLAGS="$CFLAGS -ipo"
LDFLAGS="$LDFLAGS -ipo"
AC_CHECK_PROGS([AR], [xiar])
AC_CHECK_PROGS([RANLIB], [llvm-ranlib])
AC_MSG_RESULT([added oneapi interprocedural optimization support])
elif test "$ax_cv_c_compiler_vendor" = "gnu"; then
CFLAGS="$CFLAGS -flto"
LDFLAGS="$LDFLAGS -flto"
AX_COMPARE_VERSION($ax_cv_c_compiler_version, [ge], [5.0.0],
[
AC_CHECK_PROGS([AR], [gcc-ar])
AC_CHECK_PROGS([RANLIB], [gcc-ranlib])
], [:] )
AC_MSG_RESULT([added GCC interprocedural optimization support])
elif test "$ax_cv_c_compiler_vendor" = "clang"; then
CFLAGS="$CFLAGS -flto"
LDFLAGS="$LDFLAGS -flto"
AC_CHECK_PROGS([RANLIB], [llvm-ranlib])
AC_MSG_RESULT([added LLVM interprocedural optimization support])
else
AC_MSG_WARN([Compiler does not support interprocedural optimization])
fi
fi
# Check for MPI. Need to do this before characterising the compiler (C99 mode),
# as this changes the compiler.
# We should consider using AX_PROG_CC_MPI to replace AC_PROG_CC when compiling
# whole applications. There are issues with mixing compilers when using this
# macro. See
# http://lists.gnu.org/archive/html/autoconf-archive-maintainers/2011-05/msg00004.html.
AC_ARG_ENABLE([mpi],
[AS_HELP_STRING([--enable-mpi],
[Compile with functionality for distributed-memory parallelism using MPI @<:@yes/no@:>@]
)],
[enable_mpi="$enableval"],
[enable_mpi="yes"]
)
# Use extra flags set by AC_PROG_CC as part of $CC. Currently undocumented as ac_cv_prog_cc_stdc,
# so could change.
good_mpi="yes"
if test "$enable_mpi" = "yes"; then
AX_MPI([CC="$MPICC $ac_cv_prog_cc_stdc" AC_DEFINE(HAVE_MPI, 1, [Define if you have the MPI library.]) ], [enable_mpi="no"])
MPI_LIBRARY="Unknown MPI"
# Various MPI implementations require additional libraries when also using
# threads. Use mpirun (on PATH) as that seems to be only command with
# version flag, allow MPIRUN to override for systems that insist on
# a non-standard name (PRACE).
: ${MPIRUN='mpirun'}
if test "$MPIRUN" = "mpirun"; then
AC_PATH_PROG([MPIRUN],[mpirun],[notfound])
fi
if test "$MPIRUN" = "notfound"; then
# This may not be fatal (some systems do not allow mpirun on
# development nodes)., so push on.
AC_MSG_WARN([Cannot find mpirun command on PATH, thread support may not be correct])
else
# Special options we know about.
# Intel: -mt_mpi
# PLATFORM: -lmtmpi
# OpenMPI: nothing, but library should be built correctly.
# Set MPI_THREAD_LIBS and add to linker commands as necessary.
AC_MSG_CHECKING([MPI threads options])
version=`$MPIRUN -version 2>&1`
case "$version" in
*Intel*MPI*)
MPI_THREAD_LIBS="-mt_mpi"
MPI_LIBRARY="Intel MPI"
AC_MSG_RESULT([Intel MPI])
;;
*Platform*)
MPI_THREAD_LIBS="-lmtmpi"
MPI_LIBRARY="PLATFORM MPI"
AC_MSG_RESULT([PLATFORM MPI])
;;
*"Open MPI"*)
MPI_THREAD_LIBS=""
MPI_LIBRARY="Open MPI"
AC_MSG_RESULT([Open MPI])
# OpenMPI should be 1.8.6 or later, if not complain.
# Version is last word on first line of -version output.
revision=`mpirun -version 2>&1 | grep "Open MPI" | awk '{print $NF}'`
AX_COMPARE_VERSION( $revision, [ge], [1.8.6],,[good_mpi="no"] )
if test "$good_mpi" = "no"; then
AC_MSG_WARN([
Open MPI version should be at least 1.8.6 (is $revision)])
enable_mpi="yes (but with warning)"
fi
;;
*)
MPI_THREAD_LIBS=""
AC_MSG_RESULT([unknown])
;;
esac
AC_SUBST([MPI_THREAD_LIBS])
fi
AC_DEFINE_UNQUOTED([SWIFT_MPI_LIBRARY], ["$MPI_LIBRARY"], [The MPI library name, if known.])
fi
AM_CONDITIONAL([HAVEMPI],[test $enable_mpi = "yes"])
# Indicate that MPIRUN can be modified by an environment variable
AC_ARG_VAR(MPIRUN, Path to the mpirun command if non-standard)
# Add libtool support (now that CC is defined). Disable shared libraries by default.
LT_INIT([disable-shared])
# Need C99 and inline support. Only for autoconfs to version 2.69.
m4_version_prereq([2.71], [], [AC_PROG_CC_C99])
# Need inline support.
AC_C_INLINE
# If debugging try to show inlined functions.
if test "x$ax_enable_debug" = "xyes"; then
# Show inlined functions.
if test "$ax_cv_c_compiler_vendor" = "gnu"; then
# Would like to use -gdwarf and let the compiler pick a good version
# but that doesn't always work.
AX_CHECK_COMPILE_FLAG([-gdwarf -fvar-tracking-assignments],
[inline_EXTRA_FLAGS="-gdwarf -fvar-tracking-assignments"],
[inline_EXTRA_FLAGS="-gdwarf-2 -fvar-tracking-assignments"])
CFLAGS="$CFLAGS $inline_EXTRA_FLAGS"
elif test "$ax_cv_c_compiler_vendor" = "intel"; then
CFLAGS="$CFLAGS -debug inline-debug-info"
elif test "$ax_cv_c_compiler_vendor" = "oneapi"; then
CFLAGS="$CFLAGS -debug inline-debug-info"
fi
fi
# Are we using the regular tasks (with atomics and no task conflicts) or
# are we using the atomic-free task-conflicting (slower) version?
AC_ARG_ENABLE([atomics-within-tasks],
[AS_HELP_STRING([--disable-atomics-within-tasks],
[Disable the use of atomic operations within tasks. This creates more task conflicts
but allows for atomic-free and lock-free code within the tasks. This likely slows down
the code @<:@yes/no@:>@]
)],
[enable_atomics_within_tasks="$enableval"],
[enable_atomics_within_tasks="yes"]
)
AS_IF([test "x$enable_atomics_within_tasks" != "xno"],
, # Note: atomics are allowed by default, we define the macro if we don't want them.
[AC_DEFINE([SWIFT_TASKS_WITHOUT_ATOMICS],1,[Makes SWIFT use atomic-free and lock-free tasks.])
])
# Check if task debugging is on.
AC_ARG_ENABLE([task-debugging],
[AS_HELP_STRING([--enable-task-debugging],
[Store extra information for generating task dump files @<:@yes/no@:>@]
)],
[enable_task_debugging="$enableval"],
[enable_task_debugging="no"]
)
if test "$enable_task_debugging" = "yes"; then
AC_DEFINE([SWIFT_DEBUG_TASKS],1,[Enable task debugging])
fi
# Check if threadpool debugging is on.
AC_ARG_ENABLE([threadpool-debugging],
[AS_HELP_STRING([--enable-threadpool-debugging],
[Store threadpool mapper timing information and generate threadpool dump files @<:@yes/no@:>@]
)],
[enable_threadpool_debugging="$enableval"],
[enable_threadpool_debugging="no"]
)
if test "$enable_threadpool_debugging" = "yes"; then
AC_DEFINE([SWIFT_DEBUG_THREADPOOL],1,[Enable threadpool debugging])
LDFLAGS="$LDFLAGS -rdynamic -ldl"
fi
# Check if the general timers are switched on.
AC_ARG_ENABLE([timers],
[AS_HELP_STRING([--enable-timers],
[Activate the basic timers @<:@yes/no@:>@]
)],
[enable_timers="$enableval"],
[enable_timers="no"]
)
if test "$enable_timers" = "yes"; then
AC_DEFINE([SWIFT_USE_TIMERS],1,[Enable individual timers])
fi
# Check if expensive debugging is on.
AC_ARG_ENABLE([debugging-checks],
[AS_HELP_STRING([--enable-debugging-checks],
[Activate expensive consistency checks @<:@yes/no@:>@]
)],
[enable_debugging_checks="$enableval"],
[enable_debugging_checks="no"]
)
if test "$enable_debugging_checks" = "yes"; then
AC_DEFINE([SWIFT_DEBUG_CHECKS],1,[Enable expensive debugging])
fi
# Check if cell graph is on.
AC_ARG_ENABLE([cell-graph],
[AS_HELP_STRING([--enable-cell-graph],
[Activate the cell graph @<:@yes/no@:>@]
)],
[enable_cell_graph="$enableval"],
[enable_cell_graph="no"]
)
if test "$enable_cell_graph" = "yes"; then
AC_DEFINE([SWIFT_CELL_GRAPH],1,[Enable cell graph])
fi
# Check if using our custom icbrtf is enabled.
AC_ARG_ENABLE([custom-icbrtf],
[AS_HELP_STRING([--enable-custom-icbrtf],
[Use SWIFT's custom icbrtf function instead of the system cbrtf @<:@yes/no@:>@]
)],
[enable_custom_icbrtf="$enableval"],
[enable_custom_icbrtf="no"]
)
if test "$enable_custom_icbrtf" = "yes"; then
AC_DEFINE([WITH_ICBRTF],1,[Enable custom icbrtf])
fi
# Check whether we want to default to naive cell interactions
AC_ARG_ENABLE([naive-interactions],
[AS_HELP_STRING([--enable-naive-interactions],
[Activate use of naive cell interaction functions @<:@yes/no@:>@]
)],
[enable_naive_interactions="$enableval"],
[enable_naive_interactions="no"]
)
if test "$enable_naive_interactions" = "yes"; then
AC_DEFINE([SWIFT_USE_NAIVE_INTERACTIONS],1,[Enable use of naive cell interaction functions])
fi
# Check whether we want to default to naive cell interactions (stars)
AC_ARG_ENABLE([naive-interactions-stars],
[AS_HELP_STRING([--enable-naive-interactions-stars],
[Activate use of naive cell interaction functions for stars @<:@yes/no@:>@]
)],
[enable_naive_interactions_stars="$enableval"],
[enable_naive_interactions_stars="no"]
)
if test "$enable_naive_interactions_stars" = "yes"; then
AC_DEFINE([SWIFT_USE_NAIVE_INTERACTIONS_STARS],1,[Enable use of naive cell interaction functions for stars])
fi
# Check whether we want to default to naive cell interactions (stars)
AC_ARG_ENABLE([naive-interactions-rt],
[AS_HELP_STRING([--enable-naive-interactions-rt],
[Activate use of naive cell interaction functions for stars in RT tasks@<:@yes/no@:>@]
)],
[enable_naive_interactions_rt="$enableval"],
[enable_naive_interactions_rt="no"]
)
if test "$enable_naive_interactions_rt" = "yes"; then
AC_DEFINE([SWIFT_USE_NAIVE_INTERACTIONS_RT],1,[Enable use of naive cell interaction functions for stars in RT tasks])
fi
# Check if gravity force checks are on for some particles.
AC_ARG_ENABLE([gravity-force-checks],
[AS_HELP_STRING([--enable-gravity-force-checks=<N>],
[Activate expensive brute-force gravity checks for a fraction 1/N of all particles @<:@N@:>@]
)],
[gravity_force_checks="$enableval"],
[gravity_force_checks="no"]
)
if test "$gravity_force_checks" = "yes"; then
AC_MSG_ERROR(Need to specify the fraction of particles to check when using --enable-gravity-force-checks!)
elif test "$gravity_force_checks" != "no"; then
AC_DEFINE_UNQUOTED([SWIFT_GRAVITY_FORCE_CHECKS], [$enableval] ,[Enable gravity brute-force checks])
fi
# Check if hydro density checks are on for some particles.
AC_ARG_ENABLE([hydro-density-checks],
[AS_HELP_STRING([--enable-hydro-density-checks],
[Activate expensive brute-force hydro density checks for a fraction 1/N of all particles @<:@N@:>@]
)],
[hydro_density_checks="$enableval"],
[hydro_density_checks="no"]
)
if test "$hydro_density_checks" = "yes"; then
AC_MSG_ERROR(Need to specify the fraction of particles to check when using --enable-hydro-density-checks!)
elif test "$hydro_density_checks" != "no"; then
AC_DEFINE_UNQUOTED([SWIFT_HYDRO_DENSITY_CHECKS], [$enableval] ,[Enable hydro density brute-force checks])
fi
# Check if stars density checks are on for some particles.
AC_ARG_ENABLE([stars-density-checks],
[AS_HELP_STRING([--enable-stars-density-checks],
[Activate expensive brute-force stars density checks for a fraction 1/N of all particles @<:@N@:>@]
)],
[stars_density_checks="$enableval"],
[stars_density_checks="no"]
)
if test "$stars_density_checks" = "yes"; then
AC_MSG_ERROR(Need to specify the fraction of particles to check when using --enable-stars-density-checks!)
elif test "$stars_density_checks" != "no"; then
AC_DEFINE_UNQUOTED([SWIFT_STARS_DENSITY_CHECKS], [$enableval] ,[Enable stars density brute-force checks])
fi
# Check if ghost statistics are enabled
AC_ARG_ENABLE([ghost-statistics],
[AS_HELP_STRING([--enable-ghost-statistics],
[Gather statistics about the ghost iterations for hydro, stars and black holes in N bins @<:@N@:>@]
)],
[ghost_stats="$enableval"],
[ghost_stats="no"]
)
if test "$ghost_stats" == "yes"; then
AC_MSG_ERROR(Need to specify the number of bins when using --enable-ghost-statistics!)
elif test "$ghost_stats" != "no"; then
AC_DEFINE_UNQUOTED([SWIFT_GHOST_STATS], [$enableval] ,[Enable ghost statistics for hydro, stars and black holes])
fi
# Check whether we want to switch on glass making
AC_ARG_ENABLE([glass-making],
[AS_HELP_STRING([--enable-glass-making],
[Activate the glass-making procedure by reversing the sign of gravity @<:@yes/no@:>@]
)],
[gravity_glass_making="$enableval"],
[gravity_glass_making="no"]
)
if test "$gravity_glass_making" = "yes"; then
AC_DEFINE([SWIFT_MAKE_GRAVITY_GLASS], 1, [Make the code run in a way to produce a glass file for gravity/cosmology])
fi
# Check if we want to zero the gravity forces for all particles below some ID.
AC_ARG_ENABLE([no-gravity-below-id],
[AS_HELP_STRING([--enable-no-gravity-below-id=<N>],
[Zeros the gravitational acceleration of all particles with an ID smaller than @<:@N@:>@]
)],
[no_gravity_below_id="$enableval"],
[no_gravity_below_id="no"]
)
if test "$no_gravity_below_id" = "yes"; then
AC_MSG_ERROR(Need to specify the ID below which particles get zero forces when using --enable-no-gravity-below-id!)
elif test "$no_gravity_below_id" != "no"; then
AC_DEFINE_UNQUOTED([SWIFT_NO_GRAVITY_BELOW_ID], [$enableval] ,[Particles with smaller ID than this will have zero gravity forces])
fi
# Check if we want to use boundary particles.
AC_ARG_ENABLE([boundary-particles],
[AS_HELP_STRING([--enable-boundary-particles=<N>],
[Set all particles with an ID smaller than @<:@N@:>@ as boundary particles (i.e. receive zero gravity + hydro forces).]
)],
[boundary_particles="$enableval"],
[boundary_particles="no"]
)
if test "$boundary_particles" = "yes"; then
AC_MSG_ERROR(Need to specify the ID below which particles get zero forces when using --enable-boundary-particles!)
elif test "$boundary_particles" != "no"; then
AC_DEFINE_UNQUOTED([SWIFT_NO_GRAVITY_BELOW_ID], [$enableval] ,[Particles with smaller ID than this will have zero gravity forces])
AC_DEFINE_UNQUOTED([SWIFT_BOUNDARY_PARTICLES], [$enableval] ,[Particles with smaller ID than this will be considered as boundaries.])
fi
# Check if we want to use fixed boundary particles.
AC_ARG_ENABLE([fixed-boundary-particles],
[AS_HELP_STRING([--enable-fixed-boundary-particles=<N>],
[Set all particles with an ID smaller than @<:@N@:>@ as fixed boundary particles (i.e. receive zero gravity + hydro forces + zero velocity), this mode enables also --enable-boundary-particles and --enable-no-gravity-below-id.]
)],
[fixed_boundary_particles="$enableval"],
[fixed_boundary_particles="no"]
)
if test "$fixed_boundary_particles" = "yes"; then
AC_MSG_ERROR(Need to specify the ID below which particles get zero forces when using --enable-boundary-particles!)
elif test "$fixed_boundary_particles" != "no"; then
AC_DEFINE_UNQUOTED([SWIFT_NO_GRAVITY_BELOW_ID], [$enableval] ,[Particles with smaller ID than this will have zero gravity forces])
AC_DEFINE_UNQUOTED([SWIFT_BOUNDARY_PARTICLES], [$enableval] ,[Particles with smaller ID than this will be considered as boundaries.])
AC_DEFINE_UNQUOTED([SWIFT_FIXED_BOUNDARY_PARTICLES], [$enableval] ,[Particles with smaller ID than this will be considered as boundaries.])
fi
# Check if fixed entropy is on for settling planetary initial conditions
AC_ARG_ENABLE([planetary-fixed-entropy],
[AS_HELP_STRING([--enable-planetary-fixed-entropy],
[Force entropies to stay fixed for settling planetary initial conditions @<:@yes/no@:>@]
)],
[planetary_fixed_entropy="$enableval"],
[planetary_fixed_entropy="no"]
)
if test "$planetary_fixed_entropy" = "yes"; then
AC_DEFINE([PLANETARY_FIXED_ENTROPY],1,[Enable planetary fixed entropy])
fi
# Check whether we have any of the ARM v8.1 tick timers
AX_ASM_ARM_PMCCNTR
AX_ASM_ARM_CNTVCT
# See if we want memuse reporting.
AC_ARG_ENABLE([memuse-reports],
[AS_HELP_STRING([--enable-memuse-reports],
[Output reports about significant memory allocations@<:@yes/no@:>@]
)],
[enable_memuse_reports="$enableval"],
[enable_memuse_reports="no"]
)
if test "$enable_memuse_reports" = "yes"; then
AC_DEFINE([SWIFT_MEMUSE_REPORTS],1,[Enable memory usage reports])
fi
# The system memory report depends on the presence of /proc/self/statm, i.e.
# a linux OS, check for that.
if test -f "/proc/self/statm"; then
AC_DEFINE([SWIFT_MEMUSE_STATM],1,[Have /proc/self/statm capability])
fi
# Check if we want to make the dumper thread active.
AC_ARG_ENABLE([dumper],
[AS_HELP_STRING([--enable-dumper],
[Dump active tasks and memory use (if configured)@<:@yes/no@:>@]
)],
[enable_dumper="$enableval"],
[enable_dumper="no"]
)
if test "$enable_dumper" = "yes"; then
AC_DEFINE([SWIFT_DUMPER_THREAD],1,[Enable dumper thread])
fi
# See if we want mpi reporting.
AC_ARG_ENABLE([mpiuse-reports],
[AS_HELP_STRING([--enable-mpiuse-reports],
[Output reports about MPI tasks requests@<:@yes/no@:>@]
)],
[enable_mpiuse_reports="$enableval"],
[enable_mpiuse_reports="no"]
)
if test "$enable_mpiuse_reports" = "yes"; then
AC_DEFINE([SWIFT_MPIUSE_REPORTS],1,[Enable MPI task reports])
fi
# Define HAVE_POSIX_MEMALIGN if it works.
AX_FUNC_POSIX_MEMALIGN
# Disable vectorisation for known compilers. This switches off optimizations
# that could be enabled above, so in general should be appended. Slightly odd
# implementation as want to describe as --disable-vec, but macro is enable
# (there is no enable action).
AC_ARG_ENABLE([vec],
[AS_HELP_STRING([--disable-vec],
[Disable vectorization]
)],
[enable_vec="$enableval"],
[enable_vec="yes"]
)
# Disable hand written vectorisation. Slightly odd implementation as want
# to describe as --disable-hand-vec, but macro is enable (there is no enable action).
AC_ARG_ENABLE([hand-vec],
[AS_HELP_STRING([--disable-hand-vec],
[Disable intrinsic vectorization]
)],
[enable_hand_vec="$enableval"],
[enable_hand_vec="yes"]
)
HAVEVECTORIZATION=0
# Only optimize if allowed, otherwise assume user will set CFLAGS as
# appropriate. Note argument check is done earlier so we can configure
# other options related to optimization.
if test "$enable_opt" = "yes" ; then
# Choose the best flags for this compiler and architecture
ac_test_CFLAGS="no"
AX_CC_MAXOPT
ac_test_CFLAGS="yes"
# Choose the best flags for the gravity sub-library on this compiler and
# architecture. Note we use OpenMP as a compiler hints for loop vectorization.
GRAVITY_CFLAGS="$GRAVITY_CFLAGS $OPENMP_CFLAGS"
if test "$ax_cv_c_compiler_vendor" = "intel"; then
case "$icc_flags" in
*CORE-AVX512*)
GRAVITY_CFLAGS="$GRAVITY_CFLAGS -qopt-zmm-usage=high"
;;
*)
AC_MSG_NOTICE([No additional flags needed for gravity on this platform])
;;
esac
elif test "$ax_cv_c_compiler_vendor" = "oneapi"; then
case "$icc_flags" in
*CORE-AVX512*)
GRAVITY_CFLAGS="$GRAVITY_CFLAGS -qopt-zmm-usage=high"
;;
*)
AC_MSG_NOTICE([No additional flags needed for gravity on this platform])
;;
esac
elif test "$ax_cv_c_compiler_vendor" = "gnu"; then
if test "$gcc_handles_avx512" = "yes"; then
case "$ax_cv_gcc_archflag" in
*skylake-avx512*)
GRAVITY_CFLAGS="$GRAVITY_CFLAGS -mprefer-vector-width=512"
;;
*)
AC_MSG_NOTICE([No additional flags needed for gravity on this platform])
;;
esac
else
AC_MSG_NOTICE([No additional flags needed for gravity on this platform])
fi
elif test "$ax_cv_c_compiler_vendor" = "clang"; then
# Could be a number of compilers. Check for aocc specific flags we want
# to use.
AX_CHECK_COMPILE_FLAG("-zopt", [GRAVITY_CFLAGS="$GRAVITY_CFLAGS -fvectorize -zopt"])
case "$ax_cv_gcc_archflag" in
*skylake-avx512*)
GRAVITY_CFLAGS="$GRAVITY_CFLAGS -mprefer-vector-width=512"
;;
*znver[[4-9]])
GRAVITY_CFLAGS="$GRAVITY_CFLAGS -mprefer-vector-width=512"
;;
*)
:
;;
esac
else
AC_MSG_WARN([Do not know what best gravity vectorization flags to choose for this compiler])
fi
AC_ARG_VAR([GRAVITY_CFLAGS], [C compiler flags added to the basic CFLAGS to compile
the gravity-related files.])
# Check SSE & AVX support (some overlap with AX_CC_MAXOPT).
# Don't use the SIMD_FLAGS result with Intel compilers. The -x<code>
# value from AX_CC_MAXOPT should be sufficient.
AX_EXT
if test "$SIMD_FLAGS" != ""; then
if test "$ax_cv_c_compiler_vendor" != "intel"; then
CFLAGS="$CFLAGS $SIMD_FLAGS"
fi
fi
if test "$enable_vec" = "no"; then
if test "$ax_cv_c_compiler_vendor" = "intel"; then
CFLAGS="$CFLAGS -no-vec -no-simd"
AC_MSG_RESULT([disabled Intel vectorization])
elif test "$ax_cv_c_compiler_vendor" = "oneapi"; then
CFLAGS="$CFLAGS -no-vec"
AC_MSG_RESULT([disabled oneAPI vectorization])
elif test "$ax_cv_c_compiler_vendor" = "gnu"; then
CFLAGS="$CFLAGS -fno-tree-vectorize"
AC_MSG_RESULT([disabled GCC vectorization])
elif test "$ax_cv_c_compiler_vendor" = "clang"; then
CFLAGS="$CFLAGS -fno-vectorize -fno-slp-vectorize"
AC_MSG_RESULT([disabled clang vectorization])
else
AC_MSG_WARN([Do not know how to disable vectorization for this compiler])
fi
elif test "$enable_hand_vec" = "yes"; then
AC_DEFINE([WITH_VECTORIZATION],1,[Enable hand-written vectorization])
HAVEVECTORIZATION=1
fi
fi
AM_CONDITIONAL([HAVEVECTORIZATION],[test -n "$HAVEVECTORIZATION"])
# Add address sanitizer options to flags, if requested. Only useful for GCC
# version 4.8 and later and clang.
AC_ARG_ENABLE([sanitizer],
[AS_HELP_STRING([--enable-sanitizer],
[Enable memory error detection using address sanitizer @<:@no/yes@:>@]
)],
[enable_san="$enableval"],
[enable_san="no"]
)
if test "$enable_san" = "yes"; then
if test "$ax_cv_c_compiler_vendor" = "gnu"; then
AX_COMPARE_VERSION( $ax_cv_c_compiler_version, [ge], [4.8.0],
[enable_san="yes"], [enable_san="no"] )
elif test "$ax_cv_c_compiler_vendor" = "clang"; then
AX_COMPARE_VERSION( $ax_cv_c_compiler_version, [ge], [3.2.0],
[enable_san="yes"], [enable_san="no"] )
fi
if test "$enable_san" = "yes"; then
CFLAGS="$CFLAGS -fsanitize=address -fno-omit-frame-pointer"
AC_MSG_RESULT([Adding address sanitizer support... yes])
# Check if we have access to the __lsan_ignore_object() call for
# marking memory allocations as deliberately leaked.
AC_LINK_IFELSE([AC_LANG_SOURCE([[
#include <stdlib.h>
#include <sanitizer/lsan_interface.h>
int main(int argc, char *argv[]) {
void *p = malloc(1);
__lsan_ignore_object(p);
return 0;
}]])],
[AC_DEFINE(HAVE_LSAN_IGNORE_OBJECT, 1, [Have __lsan_ignore_object() call])],
[AC_MSG_WARN([Sanitizer enabled but no __lsan_ignore_object()])])
else
AC_MSG_WARN([Compiler does not support address sanitizer option])
fi
fi
# Add the undefined sanitizer option to flags. Only useful for GCC
# version 4.9 and later and clang to detected undefined code behaviour
# such as integer overflow and memory alignment issues.
AC_ARG_ENABLE([undefined-sanitizer],
[AS_HELP_STRING([--enable-undefined-sanitizer],
[Enable detection of code that causes undefined behaviour @<:@no/yes@:>@]
)],
[enable_ubsan="$enableval"],
[enable_ubsan="no"]
)
if test "$enable_ubsan" = "yes"; then
if test "$ax_cv_c_compiler_vendor" = "gnu"; then
AX_COMPARE_VERSION( $ax_cv_c_compiler_version, [ge], [4.9.0],
[enable_ubsan="yes"], [enable_ubsan="no"] )
elif test "$ax_cv_c_compiler_vendor" = "clang"; then
AX_COMPARE_VERSION( $ax_cv_c_compiler_version, [ge], [3.7.0],
[enable_ubsan="yes"], [enable_ubsan="no"] )
fi
if test "$enable_ubsan" = "yes"; then
CFLAGS="$CFLAGS -fsanitize=undefined"
AC_MSG_RESULT([added undefined sanitizer support])
else
AC_MSG_WARN([Compiler does not support undefined sanitizer option])
fi
fi
# MPI mesh gravity
AC_ARG_ENABLE([mpi-mesh-gravity],
[AS_HELP_STRING([--enable-mpi-mesh-gravity],
[enable parallel mesh gravity (requires FFTW MPI library) @<:@no/yes@:>@]
)],
[with_mpi_mesh_gravity="${enableval}"],
[with_mpi_mesh_gravity="no"]
)
# Autoconf stuff.
AC_PROG_INSTALL
AC_PROG_MAKE_SET
AC_PROG_EGREP
# Check for the libraries we will need.
AC_CHECK_LIB(m,sqrt,,AC_MSG_ERROR(something is wrong with the math library!))
# Check for GSL. We test for this in the standard directories by default,
# and only disable if using --with-gsl=no or --without-gsl. When a value
# is given GSL must be found.
have_gsl="no"
AC_ARG_WITH([gsl],
[AS_HELP_STRING([--with-gsl=PATH],
[root directory where GSL is installed @<:@yes/no@:>@]
)],
[with_gsl="$withval"],
[with_gsl="test"]
)
if test "x$with_gsl" != "xno"; then
if test "x$with_gsl" != "xyes" -a "x$with_gsl" != "xtest" -a "x$with_gsl" != "x"; then
GSL_LIBS="-L$with_gsl/lib -lgsl -lgslcblas"
GSL_INCS="-I$with_gsl/include"
else
GSL_LIBS="-lgsl -lgslcblas"
GSL_INCS=""
fi
# GSL is not specified, so just check if we have it.
if test "x$with_gsl" = "xtest"; then
AC_CHECK_LIB([gslcblas],[cblas_dgemm],[have_gsl="yes"],[have_gsl="no"],$GSL_LIBS)
if test "x$have_gsl" != "xno"; then
AC_DEFINE([HAVE_LIBGSLCBLAS],1,[The GSL CBLAS library appears to be present.])
AC_CHECK_LIB([gsl],[gsl_integration_qag],
AC_DEFINE([HAVE_LIBGSL],1,[The GSL library appears to be present.]),
[have_gsl="no"],$GSL_LIBS)
fi
else
AC_CHECK_LIB([gslcblas],[cblas_dgemm],
AC_DEFINE([HAVE_LIBGSLCBLAS],1,[The GSL CBLAS library appears to be present.]),
AC_MSG_ERROR(something is wrong with the GSL CBLAS library!), $GSL_LIBS)
AC_CHECK_LIB([gsl],[gsl_integration_qag],
AC_DEFINE([HAVE_LIBGSL],1,[The GSL library appears to be present.]),
AC_MSG_ERROR(something is wrong with the GSL library!), $GSL_LIBS)
have_gsl="yes"
fi
if test "$have_gsl" = "no"; then
GSL_LIBS=""
GSL_INCS=""
fi
fi
AC_SUBST([GSL_LIBS])
AC_SUBST([GSL_INCS])
AM_CONDITIONAL([HAVEGSL],[test -n "$GSL_LIBS"])
# Check for GMP. We test for this in the standard directories by default,
# and only disable if using --with-gmp=no or --without-gmp. When a value
# is given GMP must be found.
have_gmp="no"
AC_ARG_WITH([gmp],
[AS_HELP_STRING([--with-gmp=PATH],
[root directory where GMP is installed @<:@yes/no@:>@]
)],
[with_gmp="$withval"],
[with_gmp="test"]
)
if test "x$with_gmp" != "xno"; then
if test "x$with_gmp" != "xyes" -a "x$with_gmp" != "xtest" -a "x$with_gmp" != "x"; then
GMP_LIBS="-L$with_gmp/lib -lgmp"
else
GMP_LIBS="-lgmp"
fi
# GMP is not specified, so just check if we have it.
if test "x$with_gmp" = "xtest"; then
AC_CHECK_LIB([gmp],[__gmpz_inits],[have_gmp="yes"],[have_gmp="no"],$GMP_LIBS)
if test "x$have_gmp" != "xno"; then
AC_DEFINE([HAVE_LIBGMP],1,[The GMP library appears to be present.])
fi
else
AC_CHECK_LIB([gmp],[__gmpz_inits],
AC_DEFINE([HAVE_LIBGMP],1,[The GMP library appears to be present.]),
AC_MSG_ERROR(something is wrong with the GMP library!), $GMP_LIBS)
have_gmp="yes"
fi
if test "$have_gmp" = "no"; then
GMP_LIBS=""
fi
fi
AC_SUBST([GMP_LIBS])
AM_CONDITIONAL([HAVEGMP],[test -n "$GMP_LIBS"])
# Check for pthreads.
AX_PTHREAD([LIBS="$PTHREAD_LIBS $LIBS" CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
CC="$PTHREAD_CC" LDFLAGS="$LDFLAGS $PTHREAD_LIBS $LIBS"],
AC_MSG_ERROR([Could not find a working version of
the pthread library. Make sure you have the library and header files installed
or use CPPFLAGS and LDFLAGS if the library is installed in a
non-standard location.]))
# Check whether POSIX thread barriers are implemented (e.g. OSX does not have them)
have_pthread_barrier="no"
AC_CHECK_LIB(pthread, pthread_barrier_init,
have_pthread_barrier="yes",
AC_MSG_WARN(POSIX implementation does not have barriers. SWIFT will use home-made ones.))
if test "x$have_pthread_barrier" = "xyes"; then
AC_DEFINE([HAVE_PTHREAD_BARRIERS], [1], [The posix library implements barriers])
fi
# Check whether POSIX file allocation functions exist (e.g. OSX does not have them)
AC_CHECK_LIB(pthread, posix_fallocate,
AC_DEFINE([HAVE_POSIX_FALLOCATE], [1], [The posix library implements file allocation functions.]),
AC_MSG_WARN(POSIX implementation does not have file allocation functions.))
# Check for METIS.
have_metis="no"
AC_ARG_WITH([metis],
[AS_HELP_STRING([--with-metis=PATH],
[root directory where METIS is installed @<:@yes/no@:>@]
)],
[with_metis="$withval"],
[with_metis="no"]
)
METIS_LIBS=""
if test "x$with_metis" != "xno"; then
# Check if we have METIS.
if test "x$with_metis" != "xyes" -a "x$with_metis" != "x"; then
METIS_LIBS="-L$with_metis/lib -lmetis"
METIS_INCS="-I$with_metis/include"
else
METIS_LIBS="-lmetis"
METIS_INCS=""
fi
AC_CHECK_LIB([metis],[METIS_PartGraphKway], [have_metis="yes"],
[have_metis="no"], $METIS_LIBS)
# Recent METIS releases have an external GKlib, test for that before
# giving up. Assume sane and in the same directories.
if test "x$have_metis" = "xno"; then
if test "x$with_metis" != "xyes" -a "x$with_metis" != "x"; then
METIS_LIBS="-L$with_metis/lib -lmetis -lGKlib"
METIS_INCS="-I$with_metis/include"
else
METIS_LIBS="-lmetis -lGKlib"
METIS_INCS=""
fi
AC_CHECK_LIB([metis],[METIS_PartGraphRecursive], [have_metis="yes"],
[have_metis="no"], $METIS_LIBS)
fi
if test "$have_metis" = "yes"; then
AC_DEFINE([HAVE_METIS],1,[The METIS library is present.])
else
AC_MSG_ERROR("Failed to find a METIS library")
fi
fi
AC_SUBST([METIS_LIBS])
AC_SUBST([METIS_INCS])
AM_CONDITIONAL([HAVEMETIS],[test -n "$METIS_LIBS"])
# Check for ParMETIS note we can have both as ParMETIS uses METIS.
have_parmetis="no"
AC_ARG_WITH([parmetis],
[AS_HELP_STRING([--with-parmetis=PATH],
[root directory where ParMETIS is installed @<:@yes/no@:>@]
)],
[with_parmetis="$withval"],
[with_parmetis="no"]
)
if test "x$with_parmetis" != "xno"; then
# Check if we have ParMETIS.
if test "x$with_parmetis" != "xyes" -a "x$with_parmetis" != "x"; then
PARMETIS_LIBS="-L$with_parmetis/lib -lparmetis"
PARMETIS_INCS="-I$with_parmetis/include"
else
PARMETIS_LIBS="-lparmetis"
PARMETIS_INCS=""
fi
AC_CHECK_LIB([parmetis],[ParMETIS_V3_RefineKway], [have_parmetis="yes"],
[have_parmetis="no"], $PARMETIS_LIBS)
# A build may use an external METIS library, check for that.
if test "$have_parmetis" = "no"; then
if test "x$with_parmetis" != "xyes" -a "x$with_parmetis" != "x"; then
PARMETIS_LIBS="-L$with_parmetis/lib -lparmetis -lmetis"
PARMETIS_INCS="-I$with_parmetis/include"
else
PARMETIS_LIBS="-lparmetis -lmetis"
PARMETIS_INCS=""
fi
# Note use different function to avoid caching of first check.
AC_CHECK_LIB([parmetis],[ParMETIS_V3_PartKway], [have_parmetis="yes"],
[have_parmetis="no"], [$METIS_LIBS $PARMETIS_LIBS])
fi
# A build may use an external GKlib in later releases...
if test "$have_parmetis" = "no"; then
if test "x$with_parmetis" != "xyes" -a "x$with_parmetis" != "x"; then
PARMETIS_LIBS="-L$with_parmetis/lib -lparmetis -lGKlib"
PARMETIS_INCS="-I$with_parmetis/include"
else
PARMETIS_LIBS="-lparmetis -lGKlib"
PARMETIS_INCS=""
fi
# Note use different function to avoid caching of first check.
AC_CHECK_LIB([parmetis],[ParMETIS_V3_PartGeom], [have_parmetis="yes"],
[have_parmetis="no"], [$METIS_LIBS $PARMETIS_LIBS])
fi
if test "$have_parmetis" = "yes"; then
AC_DEFINE([HAVE_PARMETIS],1,[The ParMETIS library is present.])
else
AC_MSG_ERROR("Failed to find a ParMETIS library")
fi
fi
AC_SUBST([PARMETIS_LIBS])
AC_SUBST([PARMETIS_INCS])
AM_CONDITIONAL([HAVEPARMETIS],[test -n "$PARMETIS_LIBS"])
# METIS fixed width integer printing can require this, so define. Only needed
# for some non C99 compilers, i.e. C++ pre C++11.
AH_VERBATIM([__STDC_FORMAT_MACROS],
[/* Needed to get PRIxxx macros from stdint.h when not using C99 */
#ifndef __STDC_FORMAT_MACROS
#define __STDC_FORMAT_MACROS 1
#endif])
# Check for FFTW. We test for this in the standard directories by default,
# and only disable if using --with-fftw=no or --without-fftw. When a value
# is given FFTW must be found.