diff --git a/cmake/CMakeLists.txt b/cmake/CMakeLists.txt index 8e3e38570b..37cb498595 100644 --- a/cmake/CMakeLists.txt +++ b/cmake/CMakeLists.txt @@ -971,38 +971,53 @@ if(PKG_KOKKOS) endif() endif() if(PKG_KSPACE) - message(STATUS "<<< FFT settings >>> --- Primary FFT lib: ${FFT}") - if(FFT_SINGLE) - message(STATUS "Using single precision FFTs") - else() - message(STATUS "Using double precision FFTs") - endif() - if(FFT_FFTW_THREADS OR FFT_MKL_THREADS) - message(STATUS "Using threaded FFTs") - else() - message(STATUS "Using non-threaded FFTs") - endif() - if (FFT_HEFFTE) - message(STATUS "Using distributed algorithms from heFTTe") - else() - message(STATUS "Using builtin distributed algorithms") - endif() - if(PKG_KOKKOS) - if(Kokkos_ENABLE_CUDA) - if(FFT STREQUAL "KISS") - message(STATUS "Kokkos FFT: KISS") - else() - message(STATUS "Kokkos FFT: cuFFT") - endif() - elseif(Kokkos_ENABLE_HIP) - if(FFT STREQUAL "KISS") - message(STATUS "Kokkos FFT: KISS") - else() - message(STATUS "Kokkos FFT: hipFFT") - endif() + if (LMP_HEFFTE) + message(STATUS "<<< FFT settings >>> +-- Primary FFT lib: heFFTe") + if (HEFFTE_BACKEND) + message(STATUS "heFFTe backend: ${HEFFTE_BACKEND}") else() - message(STATUS "Kokkos FFT: ${FFT}") + message(STATUS "heFFTe backend: stock (not intended for production)") + endif() + if(FFT_SINGLE) + message(STATUS "Using single precision FFTs") + else() + message(STATUS "Using double precision FFTs") + endif() + else() + message(STATUS "<<< FFT settings >>> +-- Primary FFT lib: ${FFT}") + if(FFT_SINGLE) + message(STATUS "Using single precision FFTs") + else() + message(STATUS "Using double precision FFTs") + endif() + if(FFT_FFTW_THREADS OR FFT_MKL_THREADS) + message(STATUS "Using threaded FFTs") + else() + message(STATUS "Using non-threaded FFTs") + endif() + if (FFT_HEFFTE) + message(STATUS "Using distributed algorithms from heFTTe") + else() + message(STATUS "Using builtin distributed algorithms") + endif() + if(PKG_KOKKOS) + if(Kokkos_ENABLE_CUDA) + if(FFT STREQUAL "KISS") + message(STATUS "Kokkos FFT: KISS") + else() + message(STATUS "Kokkos FFT: cuFFT") + endif() + elseif(Kokkos_ENABLE_HIP) + if(FFT STREQUAL "KISS") + message(STATUS "Kokkos FFT: KISS") + else() + message(STATUS "Kokkos FFT: hipFFT") + endif() + else() + message(STATUS "Kokkos FFT: ${FFT}") + endif() endif() endif() endif() diff --git a/cmake/Modules/Packages/KSPACE.cmake b/cmake/Modules/Packages/KSPACE.cmake index 7eb04f8f19..202009678a 100644 --- a/cmake/Modules/Packages/KSPACE.cmake +++ b/cmake/Modules/Packages/KSPACE.cmake @@ -46,17 +46,21 @@ else() target_compile_definitions(lammps PRIVATE -DFFT_KISS) endif() -option(FFT_HEFFTE "Use heFFTe as the distributed FFT engine." OFF) -if(FFT_HEFFTE) +option(LMP_HEFFTE "Use heFFTe as the distributed FFT engine, supersedes the FFT option." OFF) +if(LMP_HEFFTE) # if FFT_HEFFTE is enabled, switch the builtin FFT engine with Heffte - if(FFT STREQUAL "FFTW3") # respect the backend choice, FFTW or MKL + set(HEFFTE_BACKEND_VALUES FFTW MKL) + set(HEFFTE_BACKEND "" CACHE STRING "Select heFFTe backend, e.g., FFTW or MKL") + set_property(CACHE HEFFTE_BACKEND PROPERTY STRINGS ${HEFFTE_BACKEND_VALUES}) + + if(HEFFTE_BACKEND STREQUAL "FFTW") # respect the backend choice, FFTW or MKL set(HEFFTE_COMPONENTS "FFTW") set(Heffte_ENABLE_FFTW "ON" CACHE BOOL "Enables FFTW backend for heFFTe") - elseif(FFT STREQUAL "MKL") + elseif(HEFFTE_BACKEND STREQUAL "MKL") set(HEFFTE_COMPONENTS "MKL") set(Heffte_ENABLE_MKL "ON" CACHE BOOL "Enables MKL backend for heFFTe") else() - message(FATAL_ERROR "Using -DFFT_HEFFTE=ON, requires FFT either FFTW or MKL") + message(WARNING "HEFFTE_BACKEND not selected, defaulting to 'stock' backend, which is not intended for production") endif() find_package(Heffte 2.3.0 QUIET COMPONENTS ${HEFFTE_COMPONENTS}) @@ -72,7 +76,7 @@ if(FFT_HEFFTE) set_target_properties(lammps PROPERTIES INSTALL_RPATH "${CMAKE_INSTALL_PREFIX}/lib") endif() - target_compile_definitions(lammps PRIVATE -DHEFFTE) + target_compile_definitions(lammps PRIVATE -DLMP_HEFFTE "-DHEFFTE_${HEFFTE_BACKEND}") target_link_libraries(lammps PRIVATE Heffte::Heffte) endif() diff --git a/src/KSPACE/fft3d_wrap.cpp b/src/KSPACE/fft3d_wrap.cpp index a6b4167d71..c79ba8a780 100644 --- a/src/KSPACE/fft3d_wrap.cpp +++ b/src/KSPACE/fft3d_wrap.cpp @@ -27,7 +27,7 @@ FFT3d::FFT3d(LAMMPS *lmp, MPI_Comm comm, int nfast, int nmid, int nslow, int out_klo, int out_khi, int scaled, int permute, int *nbuf, int usecollective) : Pointers(lmp) { - #ifndef HEFFTE + #ifndef LMP_HEFFTE plan = fft_3d_create_plan(comm,nfast,nmid,nslow, in_ilo,in_ihi,in_jlo,in_jhi,in_klo,in_khi, out_ilo,out_ihi,out_jlo,out_jhi,out_klo,out_khi, @@ -56,7 +56,7 @@ FFT3d::FFT3d(LAMMPS *lmp, MPI_Comm comm, int nfast, int nmid, int nslow, FFT3d::~FFT3d() { - #ifndef HEFFTE + #ifndef LMP_HEFFTE fft_3d_destroy_plan(plan); #endif } @@ -65,7 +65,7 @@ FFT3d::~FFT3d() void FFT3d::compute(FFT_SCALAR *in, FFT_SCALAR *out, int flag) { - #ifndef HEFFTE + #ifndef LMP_HEFFTE fft_3d((FFT_DATA *) in,(FFT_DATA *) out,flag,plan); #else if (flag == 1) @@ -86,7 +86,7 @@ void FFT3d::compute(FFT_SCALAR *in, FFT_SCALAR *out, int flag) void FFT3d::timing1d(FFT_SCALAR *in, int nsize, int flag) { - #ifndef HEFFTE + #ifndef LMP_HEFFTE fft_1d_only((FFT_DATA *) in,nsize,flag,plan); #endif } diff --git a/src/KSPACE/fft3d_wrap.h b/src/KSPACE/fft3d_wrap.h index f34680d682..505b4b195c 100644 --- a/src/KSPACE/fft3d_wrap.h +++ b/src/KSPACE/fft3d_wrap.h @@ -17,16 +17,18 @@ #include "fft3d.h" // IWYU pragma: export #include "pointers.h" -#ifdef HEFFTE +#ifdef LMP_HEFFTE #include "heffte.h" // select the backend -#if defined(FFT_FFTW3) +#if defined(HEFFTE_FFTW) using heffte_backend = heffte::backend::fftw; -#elif defined(FFT_MKL) +#elif defined(HEFFTE_MKL) using heffte_backend = heffte::backend::mkl; +#elif defined(HEFFTE_) +using heffte_backend = heffte::backend::stock; #endif -#endif // HEFFTE +#endif // LMP_HEFFTE namespace LAMMPS_NS { @@ -41,7 +43,7 @@ class FFT3d : protected Pointers { void timing1d(FFT_SCALAR *, int, int); private: - #ifdef HEFFTE + #ifdef LMP_HEFFTE // the heFFTe plan supersedes the internal fft_plan_3d std::unique_ptr> heffte_plan; std::vector> heffte_workspace;