Unverified Commit cf11804c authored by Axel Kohlmeyer's avatar Axel Kohlmeyer
Browse files

refactor FFT handling in CMake module for KSPACE.

This also improves the FFT info output in the PPPM styles

# Conflicts:
#	cmake/Modules/Packages/KSPACE.cmake
parent 94cb1a8a
Loading
Loading
Loading
Loading
+6 −1
Original line number Diff line number Diff line
@@ -655,5 +655,10 @@ if(PKG_KOKKOS)
  message(STATUS "Kokkos Arch: ${KOKKOS_ARCH}")
endif()
if(PKG_KSPACE)
  message(STATUS "Using ${FFT} as FFT")
  message(STATUS "Using ${FFT} as primary FFT library")
  if(FFT_SINGLE)
    message(STATUS "Using single precision FFTs")
  else()
    message(STATUS "Using double precision FFTs")
  endif()
endif()
+16 −12
Original line number Diff line number Diff line
if(PKG_KSPACE)
  option(FFT_SINGLE "Use single precision FFT instead of double" OFF)
  option(FFT_SINGLE "Use single precision FFTs instead of double precision FFTs" OFF)
  set(FFTW "FFTW3")
  if(FFT_SINGLE)
    set(FFTW "FFTW3F")
@@ -7,26 +7,30 @@ if(PKG_KSPACE)
  endif()
  find_package(${FFTW} QUIET)
  if(${FFTW}_FOUND)
    set(FFT "${FFTW}" CACHE STRING "FFT library for KSPACE package")
    set(FFT "FFTW3" CACHE STRING "FFT library for KSPACE package")
  else()
    set(FFT "KISS" CACHE STRING "FFT library for KSPACE package")
  endif()
  set(FFT_VALUES KISS ${FFTW} MKL CUFFT)
  set(FFT_VALUES KISS FFTW3 MKL)
  set_property(CACHE FFT PROPERTY STRINGS ${FFT_VALUES})
  validate_option(FFT FFT_VALUES)
  string(TOUPPER ${FFT} FFT)
  if(NOT FFT STREQUAL "KISS")
    find_package(${FFT} REQUIRED)
    if(NOT FFT STREQUAL "FFTW3F")
      add_definitions(-DFFT_FFTW)
    else()
      add_definitions(-DFFT_${FFT})
    endif()
    include_directories(${${FFT}_INCLUDE_DIRS})
    list(APPEND LAMMPS_LINK_LIBS ${${FFT}_LIBRARIES})

  if(FFT STREQUAL "FFTW3")
    find_package(${FFTW} REQUIRED)
    add_definitions(-DFFT_FFTW3)
    include_directories(${${FFTW}_INCLUDE_DIRS})
    list(APPEND LAMMPS_LINK_LIBS ${${FFTW}_LIBRARIES})
  elseif(FFT STREQUAL "MKL")
    find_package(MKL REQUIRED)
    add_definitions(-DFFT_MKL)
    include_directories(${MKL_INCLUDE_DIRS})
    list(APPEND LAMMPS_LINK_LIBS ${MKL_LIBRARIES})
  else()
    # last option is KISSFFT
    add_definitions(-DFFT_KISS)
  endif()

  set(FFT_PACK "array" CACHE STRING "Optimization for FFT")
  set(FFT_PACK_VALUES array pointer memcpy)
  set_property(CACHE FFT_PACK PROPERTY STRINGS ${FFT_PACK_VALUES})
+2 −8
Original line number Diff line number Diff line
@@ -306,12 +306,6 @@ void PPPMKokkos<DeviceType>::init()

  if (me == 0) {

#ifdef FFT_SINGLE
    const char fft_prec[] = "single";
#else
    const char fft_prec[] = "double";
#endif

    if (screen) {
      fprintf(screen,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(screen,"  grid = %d %d %d\n",nx_pppm,ny_pppm,nz_pppm);
@@ -320,7 +314,7 @@ void PPPMKokkos<DeviceType>::init()
              estimated_accuracy);
      fprintf(screen,"  estimated relative force accuracy = %g\n",
              estimated_accuracy/two_charge_force);
      fprintf(screen,"  using %s precision FFTs\n",fft_prec);
      fprintf(screen,"  using " LMP_FFT_PREC " precision " LMP_FFT_LIB "\n");
      fprintf(screen,"  3d grid and FFT values/proc = %d %d\n",
              ngrid_max,nfft_both_max);
    }
@@ -332,7 +326,7 @@ void PPPMKokkos<DeviceType>::init()
              estimated_accuracy);
      fprintf(logfile,"  estimated relative force accuracy = %g\n",
              estimated_accuracy/two_charge_force);
      fprintf(logfile,"  using %s precision FFTs\n",fft_prec);
      fprintf(logfile,"  using " LMP_FFT_PREC " precision " LMP_FFT_LIB "\n");
      fprintf(logfile,"  3d grid and FFT values/proc = %d %d\n",
              ngrid_max,nfft_both_max);
    }
+2 −8
Original line number Diff line number Diff line
@@ -350,12 +350,6 @@ void PPPM::init()

  if (me == 0) {

#ifdef FFT_SINGLE
    const char fft_prec[] = "single";
#else
    const char fft_prec[] = "double";
#endif

    if (screen) {
      fprintf(screen,"  G vector (1/distance) = %g\n",g_ewald);
      fprintf(screen,"  grid = %d %d %d\n",nx_pppm,ny_pppm,nz_pppm);
@@ -364,7 +358,7 @@ void PPPM::init()
              estimated_accuracy);
      fprintf(screen,"  estimated relative force accuracy = %g\n",
              estimated_accuracy/two_charge_force);
      fprintf(screen,"  using %s precision FFTs\n",fft_prec);
      fprintf(screen,"  using " LMP_FFT_PREC " precision " LMP_FFT_LIB "\n");
      fprintf(screen,"  3d grid and FFT values/proc = %d %d\n",
              ngrid_max,nfft_both_max);
    }
@@ -376,7 +370,7 @@ void PPPM::init()
              estimated_accuracy);
      fprintf(logfile,"  estimated relative force accuracy = %g\n",
              estimated_accuracy/two_charge_force);
      fprintf(logfile,"  using %s precision FFTs\n",fft_prec);
      fprintf(logfile,"  using " LMP_FFT_PREC " precision " LMP_FFT_LIB "\n");
      fprintf(logfile,"  3d grid and FFT values/proc = %d %d\n",
              ngrid_max,nfft_both_max);
    }
+11 −0
Original line number Diff line number Diff line
@@ -23,11 +23,22 @@ KSpaceStyle(pppm,PPPM)
#include "lmptype.h"
#include <mpi.h>

#if defined(FFT_FFTW3)
#define LMP_FFT_LIB "FFTW3"
#elif defined(FFT_MKL)
#define LMP_FFT_LIB "MKL FFT"
#else
#define LMP_FFT_LIB "KISS FFT"
#endif

#ifdef FFT_SINGLE
typedef float FFT_SCALAR;
#define LMP_FFT_PREC "single"
#define MPI_FFT_SCALAR MPI_FLOAT
#else

typedef double FFT_SCALAR;
#define LMP_FFT_PREC "double"
#define MPI_FFT_SCALAR MPI_DOUBLE
#endif

Loading