diff --git a/configure.ac b/configure.ac index 811047bb1..c0ed13132 100644 --- a/configure.ac +++ b/configure.ac @@ -80,12 +80,26 @@ AC_CHECK_DECLS([be64toh],[], [], [[#include ]]) AC_CHECK_LIB([m],[cos]) AC_CHECK_LIB([stdc++],[abort]) -############## SLATE +############## SLATE (+ BLAS++ / LAPACK++, which SLATE's headers include) +# All three may live in different prefixes (e.g. Frontier: site blaspp under +# /sw, self-built lapackpp/slate under spack); blaspp/lapackpp default to the +# slate prefix. Both lib and lib64 are searched (spack uses lib on macOS, +# lib64 on Frontier). AC_ARG_WITH([slate], [AS_HELP_STRING([--with-slate=prefix], [try this for a non-standard install prefix of the SLATE library])], [AM_CXXFLAGS="-I$with_slate/include $AM_CXXFLAGS"] - [AM_LDFLAGS="-L$with_slate/lib64 $AM_LDFLAGS"]) + [AM_LDFLAGS="-L$with_slate/lib -L$with_slate/lib64 $AM_LDFLAGS"]) +AC_ARG_WITH([blaspp], + [AS_HELP_STRING([--with-blaspp=prefix], + [install prefix of BLAS++ (default: the SLATE prefix)])], + [AM_CXXFLAGS="-I$with_blaspp/include $AM_CXXFLAGS"] + [AM_LDFLAGS="-L$with_blaspp/lib -L$with_blaspp/lib64 $AM_LDFLAGS"]) +AC_ARG_WITH([lapackpp], + [AS_HELP_STRING([--with-lapackpp=prefix], + [install prefix of LAPACK++ (default: the SLATE prefix)])], + [AM_CXXFLAGS="-I$with_lapackpp/include $AM_CXXFLAGS"] + [AM_LDFLAGS="-L$with_lapackpp/lib -L$with_lapackpp/lib64 $AM_LDFLAGS"]) ############### GMP and MPFR AC_ARG_WITH([gmp], @@ -415,11 +429,33 @@ AC_SEARCH_LIBS([fftw_execute], [fftw3], [AC_DEFINE([HAVE_FFTW], [1], [Define to 1 if you have the `FFTW' library])] [have_fftw=true]) -AC_SEARCH_LIBS([slate_init], [slate], - [AC_SEARCH_LIBS([slate_init], [slate], [], - [AC_MSG_ERROR("SLATE library not found")])] - [AC_DEFINE([HAVE_SLATE], [1], [Define to 1 if you have the `SLATE' library])] - [have_slate=true]) +############### SLATE +# libslate exports no C-linkage symbols (all mangled C++), so AC_SEARCH_LIBS +# cannot probe it. Link a real C++ call, slate::version(), with the full +# -lslate -llapackpp -lblaspp chain; MPI comes from CXX=mpicxx. +# Only attempted when --with-slate is given: SLATE is optional and heavy. +have_slate=false +if test "x$with_slate" != "x"; then + AC_MSG_CHECKING([for SLATE (slate::version)]) + ac_save_LIBS="$LIBS" + ac_save_CXXFLAGS="$CXXFLAGS" + ac_save_LDFLAGS="$LDFLAGS" + LIBS="-lslate -llapackpp -lblaspp $LIBS" + CXXFLAGS="$AM_CXXFLAGS $CXXFLAGS" + LDFLAGS="$AM_LDFLAGS $LDFLAGS" + AC_LINK_IFELSE( + [AC_LANG_PROGRAM([[#include ]], + [[return slate::version() > 0 ? 0 : 1;]])], + [have_slate=true + AC_DEFINE([HAVE_SLATE], [1], [Define to 1 if you have the SLATE library]) + AC_MSG_RESULT([yes])], + [LIBS="$ac_save_LIBS" + AC_MSG_RESULT([no]) + AC_MSG_ERROR([--with-slate given but SLATE (with BLAS++/LAPACK++) failed to link; check --with-blaspp/--with-lapackpp])]) + CXXFLAGS="$ac_save_CXXFLAGS" + LDFLAGS="$ac_save_LDFLAGS" +fi +AM_CONDITIONAL(BUILD_SLATE, [ test "${have_slate}X" == "trueX" ]) AC_SEARCH_LIBS([limeCreateReader], [lime], [AC_DEFINE([HAVE_LIME], [1], [Define to 1 if you have the `LIME' library])] @@ -899,6 +935,7 @@ GMP : `if test "x$have_gmp" = xtrue; then echo yes; else LAPACK : ${ac_LAPACK} FFTW : `if test "x$have_fftw" = xtrue; then echo yes; else echo no; fi` LIME (ILDG support) : `if test "x$have_lime" = xtrue; then echo yes; else echo no; fi` +SLATE : `if test "x$have_slate" = xtrue; then echo yes; else echo no; fi` HDF5 : `if test "x$have_hdf5" = xtrue; then echo yes; else echo no; fi` build DOXYGEN documentation : `if test "$DX_FLAG_doc" = '1'; then echo yes; else echo no; fi` Sp2n : ${ac_ENABLE_SP} diff --git a/tests/debug/Test_schur2d_vs_slate.cc b/tests/debug/Test_schur2d_vs_slate.cc index d76d2d366..cefbbdd39 100644 --- a/tests/debug/Test_schur2d_vs_slate.cc +++ b/tests/debug/Test_schur2d_vs_slate.cc @@ -40,9 +40,9 @@ Author: Peter Boyle // LU with partial pivoting then getri; Grid is pivot-free recursive Schur. // // Build: needs SLATE (spack load slate) and -// CXXFLAGS += -DGRID_HAVE_SLATE -I$SLATE_ROOT/include +// CXXFLAGS += -DHAVE_SLATE -I$SLATE_ROOT/include // LDFLAGS += -L$SLATE_ROOT/lib -lslate -lblaspp -llapackpp -// Without GRID_HAVE_SLATE the SLATE leg reports itself as not built and the +// Without HAVE_SLATE the SLATE leg reports itself as not built and the // Grid leg still runs, so the binary is always usable. // // MPI threading: the SLATE build initialises MPI at MPI_THREAD_MULTIPLE before @@ -61,7 +61,7 @@ Author: Peter Boyle #include #include #include -#ifdef GRID_HAVE_SLATE +#ifdef HAVE_SLATE #include #endif @@ -104,7 +104,7 @@ static double Certify(GridBase *grid, BlockCyclicMatrix &A0, BlockCyclicMatrix & int main(int argc, char **argv) { -#ifdef GRID_HAVE_SLATE +#ifdef HAVE_SLATE // SLATE issues MPI calls from concurrent OpenMP tasks and needs // MPI_THREAD_MULTIPLE. Grid (GridStd.h #undef GRID_COMMS_THREADS) only asks // for MPI_THREAD_SERIALIZED, which reproducibly gives Bus errors inside @@ -170,7 +170,7 @@ int main(int argc, char **argv) //////////////////////////////////////////////////////////////////////// // LEG 2: SLATE, every layout step timed and charged. //////////////////////////////////////////////////////////////////////// -#ifdef GRID_HAVE_SLATE +#ifdef HAVE_SLATE { typedef std::complex scalar_t; acceleratorCopyToDevice(&h[0], &rows1d[0], h.size()*sizeof(ComplexD)); @@ -233,7 +233,7 @@ int main(int argc, char **argv) << " certificate " << cert << std::endl; } #else - std::cout << GridLogMessage << "SLATE : leg not built (compile with -DGRID_HAVE_SLATE and link -lslate -lblaspp -llapackpp)" << std::endl; + std::cout << GridLogMessage << "SLATE : leg not built (compile with -DHAVE_SLATE and link -lslate -lblaspp -llapackpp)" << std::endl; #endif Grid_finalize();