Skip to content

Commit

Permalink
Merge pull request #47 from eth-cscs/release/v1.0.4
Browse files Browse the repository at this point in the history
Release v1.0.4
  • Loading branch information
AdhocMan authored Jul 2, 2021
2 parents 473cf75 + 16452d8 commit d862ebb
Show file tree
Hide file tree
Showing 8 changed files with 153 additions and 38 deletions.
7 changes: 4 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
cmake_minimum_required(VERSION 3.11 FATAL_ERROR) # 3.11 to avoid issues with OpenMP + CUDA
project(SpFFT LANGUAGES CXX VERSION 1.0.3)
project(SpFFT LANGUAGES CXX VERSION 1.0.4)
set(SPFFT_SO_VERSION 1)
set(SPFFT_VERSION ${PROJECT_VERSION})

Expand Down Expand Up @@ -200,8 +200,9 @@ endif()
if(NOT TARGET MKL::Sequential)
find_package(FFTW REQUIRED)
list(APPEND SPFFT_EXTERNAL_LIBS FFTW::FFTW)
if(SPFFT_SINGLE_PRECISION AND NOT FFTW_FLOAT_FOUND)
message(FATAL_ERROR "FFTW library with single precision support NOT FOUND. Disable SPFFT_SINGLE_PRECISION or provide path to library.")
if(SPFFT_SINGLE_PRECISION)
find_package(FFTWF REQUIRED)
list(APPEND SPFFT_EXTERNAL_LIBS FFTWF::FFTWF)
endif()
list(APPEND SPFFT_EXTERNAL_PKG_PACKAGES fftw3)
endif()
Expand Down
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Documentation can be found [here](https://spfft.readthedocs.io/en/latest/).
- C++ Compiler with C++11 support. Supported compilers are:
- GCC 6 and later
- Clang 5 and later
- ICC 18.0 and later
- ICC 19.0 and later
- CMake 3.11 and later
- Library providing a FFTW 3.x interface (FFTW3 or Intel MKL)
- For multi-threading: OpenMP support by the compiler
Expand Down
18 changes: 13 additions & 5 deletions cmake/SpFFTSharedConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
include(CMakeFindDependencyMacro)
macro(find_dependency_components)
if(${ARGV0}_FOUND AND ${CMAKE_VERSION} VERSION_LESS "3.15.0")
# find_dependency does not handle new components correctly before 3.15.0
set(${ARGV0}_FOUND FALSE)
endif()
find_dependency(${ARGV})
endmacro()

# options used for building library
set(SPFFT_OMP @SPFFT_OMP@)
set(SPFFT_MPI @SPFFT_MPI@)
Expand All @@ -10,7 +19,6 @@ set(SPFFT_CUDA @SPFFT_CUDA@)
set(SPFFT_ROCM @SPFFT_ROCM@)
set(SPFFT_MKL @SPFFT_MKL@)

include(CMakeFindDependencyMacro)

# add version of package
include("${CMAKE_CURRENT_LIST_DIR}/SpFFTSharedConfigVersion.cmake")
Expand All @@ -21,17 +29,17 @@ include("${CMAKE_CURRENT_LIST_DIR}/SpFFTSharedTargets.cmake")
# SpFFT only has MPI as public dependency, since the mpi header is
# part of the public header file
if(SPFFT_MPI)
# only look for MPI if header matching language is possibly used
# only look for MPI if interface for language may be used
get_property(_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
if("CXX" IN_LIST _LANGUAGES)
find_dependency(MPI COMPONENTS CXX)
find_dependency_components(MPI COMPONENTS CXX)
target_link_libraries(SpFFT::spfft INTERFACE MPI::MPI_CXX)
endif()

if("C" IN_LIST _LANGUAGES)
find_dependency(MPI COMPONENTS C)
find_dependency_components(MPI COMPONENTS C)
target_link_libraries(SpFFT::spfft INTERFACE MPI::MPI_C)
endif()

# NOTE: Fortran module does not depend on MPI
# Fortran interface does not depend on MPI -> no linking for shared library required
endif()
40 changes: 32 additions & 8 deletions cmake/SpFFTStaticConfig.cmake
Original file line number Diff line number Diff line change
@@ -1,3 +1,12 @@
include(CMakeFindDependencyMacro)
macro(find_dependency_components)
if(${ARGV0}_FOUND AND ${CMAKE_VERSION} VERSION_LESS "3.15.0")
# find_dependency does not handle new components correctly before 3.15.0
set(${ARGV0}_FOUND FALSE)
endif()
find_dependency(${ARGV})
endmacro()

# options used for building library
set(SPFFT_OMP @SPFFT_OMP@)
set(SPFFT_MPI @SPFFT_MPI@)
Expand All @@ -10,9 +19,11 @@ set(SPFFT_CUDA @SPFFT_CUDA@)
set(SPFFT_ROCM @SPFFT_ROCM@)
set(SPFFT_MKL @SPFFT_MKL@)


# find depencies
include(CMakeFindDependencyMacro)
# make sure CXX is enabled
get_property(_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
if(SpFFT_FIND_REQUIRED AND NOT "CXX" IN_LIST _LANGUAGES)
message(FATAL_ERROR "SpFFT requires CXX language to be enabled for static linking.")
endif()

# Only look for modules we installed and save value
set(_CMAKE_MODULE_PATH_SAVE ${CMAKE_MODULE_PATH})
Expand All @@ -24,15 +35,15 @@ else()
find_dependency(FFTW)
endif()

if(SPFFT_OMP)
find_dependency(OpenMP COMPONENTS CXX)
if(SPFFT_OMP AND NOT TARGET OpenMP::OpenMP_CXX)
find_dependency_components(OpenMP COMPONENTS CXX)
endif()

if(SPFFT_MPI)
# MPI::MPI_CXX requires CXX Language enabled
find_dependency(MPI COMPONENTS CXX)
if(SPFFT_MPI AND NOT TARGET MPI::MPI_CXX)
find_dependency_components(MPI COMPONENTS CXX)
endif()


if(SPFFT_CUDA)
if(${CMAKE_VERSION} VERSION_GREATER_EQUAL "3.17.0")
find_dependency(CUDAToolkit)
Expand Down Expand Up @@ -67,3 +78,16 @@ include("${CMAKE_CURRENT_LIST_DIR}/SpFFTStaticConfigVersion.cmake")
# add library target
include("${CMAKE_CURRENT_LIST_DIR}/SpFFTStaticTargets.cmake")

# Make MPI dependency public to compile interface depending on enabled languages
if(SPFFT_MPI)
if("CXX" IN_LIST _LANGUAGES)
target_link_libraries(SpFFT::spfft INTERFACE MPI::MPI_CXX)
endif()

if("C" IN_LIST _LANGUAGES)
if(NOT TARGET MPI::MPI_C)
find_dependency_components(MPI COMPONENTS C)
endif()
target_link_libraries(SpFFT::spfft INTERFACE MPI::MPI_C)
endif()
endif()
21 changes: 2 additions & 19 deletions cmake/modules/FindFFTW.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,13 @@
# FindFFTW
# -----------
#
# This module searches for the fftw3 library.
# This module looks for the fftw3 library.
#
# The following variables are set
#
# ::
#
# FFTW_FOUND - True if double precision fftw library is found
# FFTW_FLOAT_FOUND - True if single precision fftw library is found
# FFTW_LIBRARIES - The required libraries
# FFTW_INCLUDE_DIRS - The required include directory
#
Expand Down Expand Up @@ -75,13 +74,6 @@ find_library(
PATH_SUFFIXES "lib" "lib64"
${_FFTW_DEFAULT_PATH_SWITCH}
)
find_library(
_FFTW_FLOAT_LIBRARY
NAMES "fftw3f"
HINTS ${_FFTW_PATHS}
PATH_SUFFIXES "lib" "lib64"
${_FFTW_DEFAULT_PATH_SWITCH}
)
find_path(FFTW_INCLUDE_DIRS
NAMES "fftw3.h"
HINTS ${_FFTW_PATHS} ${_FFTW_INCLUDE_PATHS}
Expand All @@ -93,15 +85,6 @@ find_path(FFTW_INCLUDE_DIRS
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFTW REQUIRED_VARS FFTW_INCLUDE_DIRS FFTW_LIBRARIES )

# check if single precision library found
if(_FFTW_FLOAT_LIBRARY AND FFTW_FOUND)
list(APPEND FFTW_LIBRARIES ${_FFTW_FLOAT_LIBRARY})
set(FFTW_FLOAT_FOUND TRUE)
else()
set(FFTW_FLOAT_FOUND FALSE)
endif()


# add target to link against
if(FFTW_FOUND)
if(NOT TARGET FFTW::FFTW)
Expand All @@ -112,4 +95,4 @@ if(FFTW_FOUND)
endif()

# prevent clutter in cache
MARK_AS_ADVANCED(FFTW_FOUND FFTW_LIBRARIES FFTW_INCLUDE_DIRS pkgcfg_lib_PKG_FFTW_fftw3 _FFTW_FLOAT_LIBRARY)
MARK_AS_ADVANCED(FFTW_FOUND FFTW_LIBRARIES FFTW_INCLUDE_DIRS pkgcfg_lib_PKG_FFTW_fftw3)
99 changes: 99 additions & 0 deletions cmake/modules/FindFFTWF.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,99 @@
# Copyright (c) 2019 ETH Zurich, Simon Frasch
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright notice,
# this list of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
# 3. Neither the name of the copyright holder nor the names of its contributors
# may be used to endorse or promote products derived from this software
# without specific prior written permission.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
# ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
# LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
# POSSIBILITY OF SUCH DAMAGE.


#.rst:
# FindFFTWF
# -----------
#
# This module looks for the fftw3f library.
#
# The following variables are set
#
# ::
#
# FFTWF_FOUND - True if single precision fftw library is found
# FFTWF_LIBRARIES - The required libraries
# FFTWF_INCLUDE_DIRS - The required include directory
#
# The following import target is created
#
# ::
#
# FFTWF::FFTWF



# set paths to look for library
set(_FFTWF_PATHS ${FFTW_ROOT} $ENV{FFTW_ROOT} ${FFTWF_ROOT} $ENV{FFTWF_ROOT})
set(_FFTWF_INCLUDE_PATHS)

set(_FFTWF_DEFAULT_PATH_SWITCH)

if(_FFTWF_PATHS)
# disable default paths if ROOT is set
set(_FFTWF_DEFAULT_PATH_SWITCH NO_DEFAULT_PATH)
else()
# try to detect location with pkgconfig
find_package(PkgConfig QUIET)
if(PKG_CONFIG_FOUND)
pkg_check_modules(PKG_FFTWF QUIET "fftw3")
endif()
set(_FFTWF_PATHS ${PKG_FFTWF_LIBRARY_DIRS})
set(_FFTWF_INCLUDE_PATHS ${PKG_FFTWF_INCLUDE_DIRS})
endif()


find_library(
FFTWF_LIBRARIES
NAMES "fftw3f"
HINTS ${_FFTWF_PATHS}
PATH_SUFFIXES "lib" "lib64"
${_FFTWF_DEFAULT_PATH_SWITCH}
)
find_path(FFTWF_INCLUDE_DIRS
NAMES "fftw3.h"
HINTS ${_FFTWF_PATHS} ${_FFTWF_INCLUDE_PATHS}
PATH_SUFFIXES "include" "include/fftw"
${_FFTWF_DEFAULT_PATH_SWITCH}
)

# check if found
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(FFTWF REQUIRED_VARS FFTWF_INCLUDE_DIRS FFTWF_LIBRARIES )


# add target to link against
if(FFTWF_FOUND)
if(NOT TARGET FFTWF::FFTWF)
add_library(FFTWF::FFTWF INTERFACE IMPORTED)
endif()
set_property(TARGET FFTWF::FFTWF PROPERTY INTERFACE_LINK_LIBRARIES ${FFTWF_LIBRARIES})
set_property(TARGET FFTWF::FFTWF PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${FFTWF_INCLUDE_DIRS})
endif()

# prevent clutter in cache
MARK_AS_ADVANCED(FFTWF_FOUND FFTWF_LIBRARIES FFTWF_INCLUDE_DIRS pkgcfg_lib_PKG_FFTWF_fftw3)
2 changes: 1 addition & 1 deletion docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Requirements

* GCC 6 and later
* Clang 5 and later
* ICC 18.0 and later
* ICC 19.0 and later


- CMake 3.11 and later
Expand Down
2 changes: 1 addition & 1 deletion src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ if(SPFFT_INSTALL)
install(FILES ${PROJECT_BINARY_DIR}/SpFFT.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

install(DIRECTORY "${PROJECT_SOURCE_DIR}/cmake/modules"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/spfft"
DESTINATION "${CMAKE_INSTALL_LIBDIR}/cmake/SpFFT"
FILES_MATCHING PATTERN "*.cmake")

if(SPFFT_FORTRAN)
Expand Down

0 comments on commit d862ebb

Please sign in to comment.