From 2a1fdc1cc4d1e17f02c57cd63bf320145a457694 Mon Sep 17 00:00:00 2001 From: "Peter W. Draper" <p.w.draper@durham.ac.uk> Date: Fri, 27 Oct 2023 12:54:47 +0100 Subject: [PATCH] When moving from AC_OPENMP and AX_OPENMP we stopped AC_SUBST of OPENMP_CFLAGS and these haven't been used since. Fix that, but do that by only using the OPENMP_CFLAGS as needed, that is as compiler hints for vectorizing some loops in the gravity interactions and only requiring the OpenMP runtime when linking against an OpenMP FFTW library. --- Makefile.am | 2 +- configure.ac | 21 +++++++++++++++------ src/Makefile.am | 2 +- tests/Makefile.am | 2 +- 4 files changed, 18 insertions(+), 9 deletions(-) diff --git a/Makefile.am b/Makefile.am index 3ca9fd5e74..b5ede6fd97 100644 --- a/Makefile.am +++ b/Makefile.am @@ -37,7 +37,7 @@ MYFLAGS = # Add the source directory and the non-standard paths to the included library headers to CFLAGS AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/argparse $(HDF5_CPPFLAGS) \ - $(GSL_INCS) $(FFTW_INCS) $(NUMA_INCS) $(GRACKLE_INCS) $(OPENMP_CFLAGS) \ + $(GSL_INCS) $(FFTW_INCS) $(NUMA_INCS) $(GRACKLE_INCS) \ $(CHEALPIX_CFLAGS) AM_LDFLAGS = $(HDF5_LDFLAGS) diff --git a/configure.ac b/configure.ac index 62c0b3a7b5..19d76cd001 100644 --- a/configure.ac +++ b/configure.ac @@ -40,6 +40,8 @@ AX_CHECK_ENABLE_DEBUG 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 @@ -579,14 +581,16 @@ if test "$enable_opt" = "yes" ; then AX_CC_MAXOPT ac_test_CFLAGS="yes" - # Choose the best flags for the gravity sub-library on this compiler and architecture + # 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_WARN([No additional flags needed for gravity on this platform]) + AC_MSG_NOTICE([No additional flags needed for gravity on this platform]) ;; esac elif test "$ax_cv_c_compiler_vendor" = "gnu"; then @@ -596,11 +600,11 @@ if test "$enable_opt" = "yes" ; then GRAVITY_CFLAGS="$GRAVITY_CFLAGS -mprefer-vector-width=512" ;; *) - AC_MSG_WARN([No additional flags needed for gravity on this platform]) + AC_MSG_NOTICE([No additional flags needed for gravity on this platform]) ;; esac else - AC_MSG_WARN([No additional flags needed for gravity on this platform]) + AC_MSG_NOTICE([No additional flags needed for gravity on this platform]) fi else AC_MSG_WARN([Do not know what best gravity vectorization flags to choose for this compiler]) @@ -961,17 +965,22 @@ if test "x$with_fftw" != "xno"; then FFTW_OPENMP_INCS="" fi - # Verify that the library works. Note requires AC_OPENMP called above. + # Verify that the library works. Note requires AX_OPENMP called above. + old_CFLAGS=$CFLAGS + CFLAGS="$CFLAGS $OPENMP_CFLAGS" AC_CHECK_LIB([fftw3],[fftw_init_threads],[have_openmp_fftw="yes"], [have_openmp_fftw="no"], $FFTW_OPENMP_LIBS) # If found, update things if test "x$have_openmp_fftw" = "xyes"; then - # Note OpenMP and pthreads use mostly the same calls, so define both. + # Note OpenMP and pthreads use mostly the same calls, so define both. AC_DEFINE([HAVE_THREADED_FFTW],1,[The threaded OpenMP FFTW library appears to be present.]) AC_DEFINE([HAVE_OPENMP_FFTW],1,[The OpenMP FFTW library appears to be present.]) FFTW_LIBS=$FFTW_OPENMP_LIBS FFTW_INCS=$FFTW_OPENMP_INCS + else + # Put CFLAGS back. + CFLAGS=$old_CFLAGS fi fi diff --git a/src/Makefile.am b/src/Makefile.am index 92640cac8c..fe5f5a910a 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -16,7 +16,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # Add the non-standard paths to the included library headers -AM_CFLAGS = $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS) $(NUMA_INCS) $(GRACKLE_INCS) $(SUNDIALS_INCS) $(OPENMP_CFLAGS) $(CHEALPIX_CFLAGS) +AM_CFLAGS = $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS) $(NUMA_INCS) $(GRACKLE_INCS) $(SUNDIALS_INCS) $(CHEALPIX_CFLAGS) # Assign a "safe" version number AM_LDFLAGS = $(HDF5_LDFLAGS) $(FFTW_LIBS) diff --git a/tests/Makefile.am b/tests/Makefile.am index 53fce13c93..78c38600fa 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -15,7 +15,7 @@ # along with this program. If not, see <http://www.gnu.org/licenses/>. # Add the source directory and the non-standard paths to the included library headers to CFLAGS -AM_CFLAGS = -I$(top_srcdir)/src $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS) $(NUMA_INCS) $(OPENMP_CFLAGS) $(CHEALPIX_CFLAGS) +AM_CFLAGS = -I$(top_srcdir)/src $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS) $(NUMA_INCS) $(CHEALPIX_CFLAGS) AM_LDFLAGS = ../src/.libs/libswiftsim.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(FFTW_LIBS) $(NUMA_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(GRACKLE_LIBS) $(GSL_LIBS) $(PROFILER_LIBS) $(CHEALPIX_LIBS) -- GitLab