From 0b2326a50d2eb8eaa3b062e2fd5f499555c85f5f Mon Sep 17 00:00:00 2001 From: "Peter W. Draper" <p.w.draper@durham.ac.uk> Date: Fri, 27 Jan 2023 15:25:27 +0000 Subject: [PATCH] Add checks for OpenMP FFTW when pthread version is not found --- configure.ac | 31 ++++++++++++++++++++++++++++--- 1 file changed, 28 insertions(+), 3 deletions(-) diff --git a/configure.ac b/configure.ac index b1bfe7f2fb..d5d6045bf5 100644 --- a/configure.ac +++ b/configure.ac @@ -872,10 +872,11 @@ AH_VERBATIM([__STDC_FORMAT_MACROS], # 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. -# If FFTW is found, we check whether this is the threaded version. +# If FFTW is found, we check whether this is the threaded or openmp version. have_fftw="no" have_mpi_fftw="no" have_threaded_fftw="no" +have_openmp_fftw="no" AC_ARG_WITH([fftw], [AS_HELP_STRING([--with-fftw=PATH], [root directory where fftw is installed @<:@yes/no@:>@] @@ -928,7 +929,7 @@ if test "x$with_fftw" != "xno"; then # Verify that the library is threaded AC_CHECK_LIB([fftw3],[fftw_init_threads],[have_threaded_fftw="yes"], - [have_threaded_fftw="no"], $FFTW_THREADED_LIBS) + [have_threaded_fftw="no"], $FFTW_THREADED_LIBS) # If found, update things if test "x$have_threaded_fftw" = "xyes"; then @@ -936,7 +937,31 @@ if test "x$with_fftw" != "xno"; then FFTW_LIBS=$FFTW_THREADED_LIBS FFTW_INCS=$FFTW_THREADED_INCS + else + + # Same checks for OpenMP if preferred threaded failed. + if test "x$with_fftw" != "xyes" -a "x$with_fftw" != "xtest" -a "x$with_fftw" != "x"; then + FFTW_OPENMP_LIBS="-L$with_fftw/lib -lfftw3_omp -lfftw3" + FFTW_OPENMP_INCS="-I$with_fftw/include" + else + FFTW_OPENMP_LIBS="-lfftw3_omp -lfftw3" + FFTW_OPENMP_INCS="" + fi + + # Verify that the library works. Note requires AC_OPENMP called above. + 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. + 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 + fi fi + fi # If MPI mesh gravity is not disabled, check whether we have the MPI version of FFTW @@ -2946,7 +2971,7 @@ AC_MSG_RESULT([ - parallel : $have_parallel_hdf5 METIS/ParMETIS : $have_metis / $have_parmetis FFTW3 enabled : $have_fftw - - threaded : $have_threaded_fftw + - threaded/openmp : $have_threaded_fftw / $have_openmp_fftw - MPI : $have_mpi_fftw - ARM : $have_arm_fftw GSL enabled : $have_gsl -- GitLab