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

make support for threaded FFTW3 consistent and incorporate it into CMake

This now also includes threaded FFTW3 for regular FFTs, not only KOKKOS.
parent cf11804c
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -661,4 +661,9 @@ if(PKG_KSPACE)
  else()
    message(STATUS "Using double precision FFTs")
  endif()
  if(FFT_THREADS)
    message(STATUS "Using threaded FFTs")
  else()
    message(STATUS "Using non-threaded FFTs")
  endif()
endif()
+9 −6
Original line number Diff line number Diff line
@@ -3,18 +3,21 @@
#
#  FFTW3_INCLUDE_DIRS  - where to find fftw3.h, etc.
#  FFTW3_LIBRARIES     - List of libraries when using fftw3.
#  FFTW3_OMP_LIBRARIES - List of libraries when using fftw3.
#  FFTW3_FOUND         - True if fftw3 found.
#  FFTW3_OMP_FOUND     - True if fftw3_omp found.
#

find_package(PkgConfig)

pkg_check_modules(PC_FFTW3 fftw3)
find_path(FFTW3_INCLUDE_DIR fftw3.h HINTS ${PC_FFTW3_INCLUDE_DIRS})

find_library(FFTW3_LIBRARY NAMES fftw3 HINTS ${PC_FFTW3_LIBRARY_DIRS})
find_library(FFTW3_OMP_LIBRARY NAMES fftw3_omp HINTS ${PC_FFTW3_LIBRARY_DIRS})

set(FFTW3_LIBRARIES ${FFTW3_LIBRARY})
set(FFTW3_INCLUDE_DIRS ${FFTW3_INCLUDE_DIR})
set(FFTW3_LIBRARIES ${FFTW3_LIBRARY})
set(FFTW3_OMP_LIBRARIES ${FFTW3_OMP_LIBRARY})

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set FFTW3_FOUND to TRUE
@@ -22,4 +25,4 @@ include(FindPackageHandleStandardArgs)

find_package_handle_standard_args(FFTW3 DEFAULT_MSG FFTW3_LIBRARY FFTW3_INCLUDE_DIR)

mark_as_advanced(FFTW3_INCLUDE_DIR FFTW3_LIBRARY )
mark_as_advanced(FFTW3_INCLUDE_DIR FFTW3_LIBRARY FFTW3_OMP_LIBRARY)
+6 −5
Original line number Diff line number Diff line
# - Find fftw3f
# Find the native FFTW3F headers and libraries.
# Find the native single precision FFTW3 headers and libraries.
#
#  FFTW3F_INCLUDE_DIRS - where to find fftw3f.h, etc.
#  FFTW3F_LIBRARIES    - List of libraries when using fftw3f.
#  FFTW3F_OMP_LIBRARIES - List of libraries when using fftw3.
#  FFTW3F_FOUND        - True if fftw3f found.
#

@@ -10,11 +10,12 @@ find_package(PkgConfig)

pkg_check_modules(PC_FFTW3F fftw3f)
find_path(FFTW3F_INCLUDE_DIR fftw3.h HINTS ${PC_FFTW3F_INCLUDE_DIRS})

find_library(FFTW3F_LIBRARY NAMES fftw3f HINTS ${PC_FFTW3F_LIBRARY_DIRS})
find_library(FFTW3F_OMP_LIBRARY NAMES fftw3f_omp HINTS ${PC_FFTW3F_LIBRARY_DIRS})

set(FFTW3F_LIBRARIES ${FFTW3F_LIBRARY})
set(FFTW3F_INCLUDE_DIRS ${FFTW3F_INCLUDE_DIR})
set(FFTW3F_LIBRARIES ${FFTW3F_LIBRARY})
set(FFTW3F_OMP_LIBRARIES ${FFTW3F_OMP_LIBRARY})

include(FindPackageHandleStandardArgs)
# handle the QUIETLY and REQUIRED arguments and set FFTW3F_FOUND to TRUE
+3 −1
Original line number Diff line number Diff line
@@ -27,7 +27,9 @@ if(PKG_KOKKOS)
                         ${KOKKOS_PKG_SOURCES_DIR}/modify_kokkos.cpp)

  if(PKG_KSPACE)
    list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/gridcomm_kokkos.cpp)
    list(APPEND KOKKOS_PKG_SOURCES ${KOKKOS_PKG_SOURCES_DIR}/fft3d_kokkos.cpp
                                   ${KOKKOS_PKG_SOURCES_DIR}/gridcomm_kokkos.cpp
                                   ${KOKKOS_PKG_SOURCES_DIR}/remap_kokkos.cpp)
  endif()

  set_property(GLOBAL PROPERTY "KOKKOS_PKG_SOURCES" "${KOKKOS_PKG_SOURCES}")
+22 −0
Original line number Diff line number Diff line
@@ -21,14 +21,36 @@ if(PKG_KSPACE)
    add_definitions(-DFFT_FFTW3)
    include_directories(${${FFTW}_INCLUDE_DIRS})
    list(APPEND LAMMPS_LINK_LIBS ${${FFTW}_LIBRARIES})
    if(FFTW3_OMP_LIBRARY OR FFTW3F_OMP_LIBRARY)
      option(FFT_THREADS "Use threaded FFT library" ON)
    else()
      option(FFT_THREADS "Use threaded FFT library" OFF)
    endif()

    if(FFT_THREADS)
      if(FFTW3_OMP_LIBRARY OR FFTW3F_OMP_LIBRARY)
        add_definitions(-DFFT_FFTW_THREADS)
        list(APPEND LAMMPS_LINK_LIBS ${${FFTW}_OMP_LIBRARIES})
      else()
        message(FATAL_ERROR "Need OpenMP enabled FFTW3 library for FFT_THREADS")
      endif()
    endif()
  elseif(FFT STREQUAL "MKL")
    find_package(MKL REQUIRED)
    option(FFT_THREADS "Use threaded FFT library" OFF)
    add_definitions(-DFFT_MKL)
    include_directories(${MKL_INCLUDE_DIRS})
    list(APPEND LAMMPS_LINK_LIBS ${MKL_LIBRARIES})
    if (FFT_THREADS)
      message(FATAL_ERROR "FFT_THREADS not supported with FFT from MKL")
    endif()
  else()
    # last option is KISSFFT
    option(FFT_THREADS "Use threaded FFT library" OFF)
    add_definitions(-DFFT_KISS)
    if (FFT_THREADS)
      message(FATAL_ERROR "FFT_THREADS not supported with KISSFFT")
    endif()
  endif()

  set(FFT_PACK "array" CACHE STRING "Optimization for FFT")
Loading