Skip to content

Commit

Permalink
Merge pull request #50 from eth-cscs/release/v1.0.5
Browse files Browse the repository at this point in the history
Release v1.0.5
  • Loading branch information
AdhocMan committed Nov 4, 2021
2 parents d862ebb + 1b018bf commit ae11716
Show file tree
Hide file tree
Showing 11 changed files with 220 additions and 101 deletions.
57 changes: 32 additions & 25 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.4)
project(SpFFT LANGUAGES CXX VERSION 1.0.5)
set(SPFFT_SO_VERSION 1)
set(SPFFT_VERSION ${PROJECT_VERSION})

Expand All @@ -23,6 +23,21 @@ endif()

# set language and standard
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CUDA_STANDARD 11)

# set CUDA flags
if(NOT CMAKE_CUDA_FLAGS_RELEASE)
set(CMAKE_CUDA_FLAGS_RELEASE "-O3 -DNDEBUG" CACHE STRING "Flags used by CUDA compiler at given build type." FORCE)
endif()
if(NOT CMAKE_CUDA_FLAGS_RELWITHDEBINFO)
set(CMAKE_CUDA_FLAGS_RELWITHDEBINFO "-O2 -g -DNDEBUG" CACHE STRING "Flags used by CUDA compiler at given build type." FORCE)
endif()
if(NOT CMAKE_CUDA_FLAGS_MINSIZEREL)
set(CMAKE_CUDA_FLAGS_MINSIZEREL "-Os -DNDEBUG" CACHE STRING "Flags used by CUDA compiler at given build type." FORCE)
endif()
if(NOT CMAKE_CUDA_FLAGS_DEBUG)
set(CMAKE_CUDA_FLAGS_DEBUG "-g" CACHE STRING "Flags used by CUDA compiler at given build type." FORCE)
endif()

#add local module path
set(CMAKE_MODULE_PATH ${CMAKE_MODULE_PATH} ${PROJECT_SOURCE_DIR}/cmake/modules)
Expand All @@ -44,7 +59,7 @@ set_property(CACHE SPFFT_GPU_BACKEND PROPERTY STRINGS

set(SPFFT_FFTW_LIB "AUTO" CACHE STRING "Library providing a FFTW interface")
set_property(CACHE SPFFT_FFTW_LIB PROPERTY STRINGS
"AUTO" "FFTW" "MKL"
"AUTO" "FFTW" "MKL" "ARMPL"
)

# Get GNU standard install prefixes
Expand All @@ -64,11 +79,7 @@ else()
set(SPFFT_LIBRARY_TYPE SHARED)
endif()

set(SPFFT_DEFINITIONS)
set(SPFFT_EXTERNAL_COMPILE_OPTIONS)
set(SPFFT_LIBS)
set(SPFFT_EXTERNAL_LIBS)
set(SPFFT_INTERFACE_INCLUDE_DIRS)
set(SPFFT_INCLUDE_DIRS)
set(SPFFT_EXTERNAL_INCLUDE_DIRS)
set(SPFFT_EXTERNAL_PKG_PACKAGES)
Expand All @@ -87,17 +98,6 @@ if(SPFFT_GPU_BACKEND)
endif()
mark_as_advanced(SPFFT_CUDA SPFFT_ROCM)

# Hide symbols by default if tests are not build
if(NOT SPFFT_BUILD_TESTS)
set(CMAKE_CXX_VISIBILITY_PRESET hidden)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 1)
else()
# disable visibility macros if tests are build
list(APPEND SPFFT_DEFINITIONS -DSPFFT_STATIC_DEFINE)
set(CMAKE_CXX_VISIBILITY_PRESET default)
set(CMAKE_VISIBILITY_INLINES_HIDDEN 0)
endif()

# Fortran
if(SPFFT_FORTRAN)
enable_language(Fortran)
Expand Down Expand Up @@ -155,7 +155,6 @@ endif()
if(SPFFT_MPI)
find_package(MPI COMPONENTS CXX REQUIRED)
list(APPEND SPFFT_EXTERNAL_LIBS MPI::MPI_CXX)
list(APPEND SPFFT_INTERFACE_INCLUDE_DIRS ${MPI_CXX_INCLUDE_DIRS})
endif()

if(SPFFT_OMP)
Expand All @@ -175,6 +174,9 @@ if(NOT ${SPFFT_FFTW_LIB} STREQUAL "AUTO")
endif()

set(SPFFT_MKL OFF)
set(SPFFT_ARMPL OFF)
set(SPFFT_FFTW OFF)

# Look for MKL first
if(${SPFFT_FFTW_LIB} STREQUAL "AUTO" OR ${SPFFT_FFTW_LIB} STREQUAL "MKL")
# Use MKL if available, otherwise require FFTW3
Expand All @@ -196,21 +198,28 @@ if(${SPFFT_FFTW_LIB} STREQUAL "AUTO" OR ${SPFFT_FFTW_LIB} STREQUAL "MKL")
endif()
endif()


# Look for ARM PL
if(NOT SPFFT_MKL AND ${SPFFT_FFTW_LIB} STREQUAL "AUTO" OR ${SPFFT_FFTW_LIB} STREQUAL "ARMPL")
find_package(ARMPL ${_SPFFT_FIND_FFTW_LIB_OPTION})
if(TARGET ARM::pl)
list(APPEND SPFFT_EXTERNAL_LIBS ARM::pl)
set(SPFFT_ARMPL ON)
endif()
endif()

# Look for FFTW library if required
if(NOT TARGET MKL::Sequential)
if(NOT SPFFT_MKL AND NOT SPFFT_ARMPL)
find_package(FFTW REQUIRED)
list(APPEND SPFFT_EXTERNAL_LIBS FFTW::FFTW)
if(SPFFT_SINGLE_PRECISION)
find_package(FFTWF REQUIRED)
list(APPEND SPFFT_EXTERNAL_LIBS FFTWF::FFTWF)
endif()
list(APPEND SPFFT_EXTERNAL_PKG_PACKAGES fftw3)
set(SPFFT_FFTW ON)
endif()

if(SPFFT_BUILD_TESTS)
# enable timing with testing
set(SPFFT_TIMING ON)
endif()

# generate config.h
configure_file(include/spfft/config.h.in ${PROJECT_BINARY_DIR}/spfft/config.h)
Expand All @@ -225,8 +234,6 @@ list(APPEND SPFFT_EXTERNAL_INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/ext)
#############################################################################
add_subdirectory(src)

list(APPEND SPFFT_LIBS spfft)

# add tests for developement
if(SPFFT_BUILD_TESTS)
add_subdirectory(tests)
Expand Down
2 changes: 2 additions & 0 deletions cmake/SpFFTSharedConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ set(SPFFT_GPU_BACKEND @SPFFT_GPU_BACKEND@)
set(SPFFT_CUDA @SPFFT_CUDA@)
set(SPFFT_ROCM @SPFFT_ROCM@)
set(SPFFT_MKL @SPFFT_MKL@)
set(SPFFT_ARMPL @SPFFT_ARMPL@)
set(SPFFT_FFTW @SPFFT_FFTW@)


# add version of package
Expand Down
8 changes: 7 additions & 1 deletion cmake/SpFFTStaticConfig.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,8 @@ set(SPFFT_GPU_BACKEND @SPFFT_GPU_BACKEND@)
set(SPFFT_CUDA @SPFFT_CUDA@)
set(SPFFT_ROCM @SPFFT_ROCM@)
set(SPFFT_MKL @SPFFT_MKL@)
set(SPFFT_ARMPL @SPFFT_ARMPL@)
set(SPFFT_FFTW @SPFFT_FFTW@)

# make sure CXX is enabled
get_property(_LANGUAGES GLOBAL PROPERTY ENABLED_LANGUAGES)
Expand All @@ -31,7 +33,11 @@ set(CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/modules")

if(SPFFT_MKL)
find_dependency(MKLSequential)
else()
endif()
if(SPFFT_ARMPL)
find_dependency(ARMPL)
endif()
if(SPFFT_FFTW)
find_dependency(FFTW)
endif()

Expand Down
93 changes: 93 additions & 0 deletions cmake/modules/FindARMPL.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# 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:
# FindARMPL
# -----------
#
# This module searches for the sequential 32-bit integer ARM library.
#
#
# The following variables are set
#
# ::
#
# ARMPL_FOUND - True if double precision fftw library is found
# ARMPL_LIBRARIES - The required libraries
# ARMPL_INCLUDE_DIRS - The required include directory
#
# The following import target is created
#
# ::
#
# ARM::pl

# set paths to look for ARM
set(_ARMPL_PATHS ${ARMPL_ROOT} $ENV{ARMPL_ROOT} $ENV{ARMPL_DIR})

set(_ARMPL_DEFAULT_PATH_SWITCH)

if(_ARMPL_PATHS)
# do not look at any default paths if a custom path was set
set(_ARMPL_DEFAULT_PATH_SWITCH NO_DEFAULT_PATH)
else()
set(_ARMPL_PATHS /opt/arm)
endif()


# find all ARM libraries / include directories
find_library(
ARMPL_LIBRARIES
NAMES "armpl_lp64"
HINTS ${_ARMPL_PATHS}
PATH_SUFFIXES "lib" "lib64"
${_ARMPL_DEFAULT_PATH_SWITCH}
)
find_path(ARMPL_INCLUDE_DIRS
NAMES "fftw3.h"
HINTS ${_ARMPL_PATHS}
PATH_SUFFIXES "include" "include/fftw" "fftw"
${_ARMPL_DEFAULT_PATH_SWITCH}
)

# check if found
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(ARMPL REQUIRED_VARS ARMPL_LIBRARIES ARMPL_INCLUDE_DIRS)

# add target to link against
if(ARMPL_FOUND)
# create interface target
if(NOT TARGET ARM::pl)
add_library(ARM::pl INTERFACE IMPORTED)
endif()
set_property(TARGET ARM::pl PROPERTY INTERFACE_LINK_LIBRARIES ${ARMPL_LIBRARIES})
set_property(TARGET ARM::pl PROPERTY INTERFACE_INCLUDE_DIRECTORIES ${ARMPL_INCLUDE_DIRS})
endif()

# prevent clutter in gui
MARK_AS_ADVANCED(ARMPL_LIBRARIES ARMPL_INCLUDE_DIRS)

1 change: 0 additions & 1 deletion include/spfft/config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@
#cmakedefine SPFFT_ROCM
#cmakedefine SPFFT_MPI
#cmakedefine SPFFT_OMP
#cmakedefine SPFFT_TIMING
#cmakedefine SPFFT_SINGLE_PRECISION
#cmakedefine SPFFT_GPU_DIRECT

Expand Down
91 changes: 55 additions & 36 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -57,35 +57,68 @@ if(SPFFT_ROCM)
if(CMAKE_CXX_STANDARD)
set(HIP_HCC_FLAGS ${HIP_HCC_FLAGS} -std=gnu++${CMAKE_CXX_STANDARD})
endif()

# macro from FindHIP package, which compiles all .cu files with hipcc and cpp files with the set c++ compiler
HIP_ADD_LIBRARY(spfft ${SPFFT_LIBRARY_TYPE} ${SPFFT_SOURCE_FILES})
else()
add_library(spfft ${SPFFT_LIBRARY_TYPE} ${SPFFT_SOURCE_FILES})
endif()

set_property(TARGET spfft PROPERTY VERSION ${SPFFT_VERSION})
set_property(TARGET spfft PROPERTY SOVERSION ${SPFFT_SO_VERSION})
# All .cu files are self-contained. Device linking can have issues with propageted linker flags of other targets like MPI.
if(SPFFT_CUDA)
set_property(TARGET spfft PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS OFF)
set_property(TARGET spfft PROPERTY CUDA_SEPARABLE_COMPILATION OFF)

# Creates library with given name. All common target modifications should be done here.
macro(spfft_create_library _TARGET_NAME)
# create target
if(SPFFT_ROCM)
# macro from FindHIP package, which compiles all .cu files with hipcc and cpp files with the set c++ compiler
HIP_ADD_LIBRARY(${_TARGET_NAME} ${SPFFT_LIBRARY_TYPE} ${SPFFT_SOURCE_FILES})
else()
add_library(${_TARGET_NAME} ${SPFFT_LIBRARY_TYPE} ${SPFFT_SOURCE_FILES})
endif()

# set version
set_property(TARGET ${_TARGET_NAME} PROPERTY VERSION ${SPFFT_VERSION})
set_property(TARGET ${_TARGET_NAME} PROPERTY SOVERSION ${SPFFT_SO_VERSION})

# All .cu files are self-contained. Device linking can have issues with propageted linker flags of other targets like MPI.
if(SPFFT_CUDA)
set_property(TARGET ${_TARGET_NAME} PROPERTY CUDA_RESOLVE_DEVICE_SYMBOLS OFF)
set_property(TARGET ${_TARGET_NAME} PROPERTY CUDA_SEPARABLE_COMPILATION OFF)
endif()

# Don't export any symbols of external static libaries. Only works on linux.
if(UNIX AND NOT APPLE)
if(${CMAKE_VERSION} VERSION_LESS "3.13.5")
target_link_libraries(${_TARGET_NAME} PRIVATE "-Wl,--exclude-libs,ALL")
else()
target_link_options(${_TARGET_NAME} PRIVATE "-Wl,--exclude-libs,ALL")
endif()
endif()

target_include_directories(${_TARGET_NAME} PRIVATE ${SPFFT_INCLUDE_DIRS} ${SPFFT_EXTERNAL_INCLUDE_DIRS})
target_link_libraries(${_TARGET_NAME} PRIVATE ${SPFFT_EXTERNAL_LIBS})

target_include_directories(${_TARGET_NAME} INTERFACE $<INSTALL_INTERFACE:include>) # for install(EXPORT ...)
target_include_directories(${_TARGET_NAME} INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>) # for export(...)
if(${SPFFT_FORTRAN}) # Add include directory for fortran module
target_include_directories(${_TARGET_NAME} INTERFACE $<INSTALL_INTERFACE:include/spfft>)
target_include_directories(${_TARGET_NAME} INTERFACE $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}/src>)
endif()

endmacro()

# Create library
spfft_create_library(spfft)
set_target_properties(spfft PROPERTIES VISIBILITY_INLINES_HIDDEN TRUE CXX_VISIBILITY_PRESET hidden)

# Create library for testing, which allows linking to internal symbols and has timings enabled.
if(SPFFT_BUILD_TESTS)
spfft_create_library(spfft_test)
set_target_properties(spfft_test PROPERTIES VISIBILITY_INLINES_HIDDEN FALSE CXX_VISIBILITY_PRESET default)
target_compile_options(spfft_test PUBLIC -DSPFFT_STATIC_DEFINE) # disable properties of export header
# enable internal timings
target_compile_options(spfft_test PUBLIC -DSPFFT_TIMING)
endif()

# build fortran module
if(SPFFT_FORTRAN)
add_library(spfft_fortran OBJECT ${PROJECT_SOURCE_DIR}/include/spfft/spfft.f90)
endif()

# Don't export any symbols of external static libaries. Only works on linux.
if(UNIX AND NOT APPLE)
if(${CMAKE_VERSION} VERSION_LESS "3.13.5")
set(CMAKE_SHARED_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS} "-Wl,--exclude-libs,ALL")
else()
target_link_options(spfft PRIVATE "-Wl,--exclude-libs,ALL")
endif()
endif()

# generate export header to control symbol visibility
include(GenerateExportHeader)
generate_export_header(spfft)
Expand All @@ -94,23 +127,9 @@ configure_file("${CMAKE_CURRENT_BINARY_DIR}/spfft_export.h"
COPYONLY
)

target_compile_options(spfft PRIVATE ${SPFFT_DEFINITIONS} ${SPFFT_EXTERNAL_COMPILE_OPTIONS})
target_include_directories(spfft PRIVATE ${SPFFT_EXTERNAL_INCLUDE_DIRS})
target_include_directories(spfft PRIVATE ${PROJECT_SOURCE_DIR}/include)
target_include_directories(spfft PRIVATE ${PROJECT_SOURCE_DIR}/src)
target_include_directories(spfft PRIVATE ${PROJECT_BINARY_DIR})
target_link_libraries(spfft PRIVATE ${SPFFT_EXTERNAL_LIBS})

target_include_directories(spfft INTERFACE ${SPFFT_INTERFACE_INCLUDE_DIRS})
target_include_directories(spfft INTERFACE $<INSTALL_INTERFACE:include>) # for install(EXPORT ...)
target_include_directories(spfft INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/include> $<BUILD_INTERFACE:${PROJECT_BINARY_DIR}>) # for export(...)
if(${SPFFT_FORTRAN}) # Add include directory for fortran module
target_include_directories(spfft INTERFACE $<INSTALL_INTERFACE:include/spfft>)
target_include_directories(spfft INTERFACE $<BUILD_INTERFACE:${PROJECT_SOURCE_DIR}/src>)
endif()

# set packge config names
if(SPFFT_STATIC)
get_target_property(_LIB_TYPE spfft TYPE)
if(_LIB_TYPE STREQUAL "STATIC_LIBRARY")
set(SPFFT_VERSION_FILE "SpFFTStaticConfigVersion.cmake")
set(SPFFT_CONFIG_FILE "SpFFTStaticConfig.cmake")
set(SPFFT_TARGETS_FILE "SpFFTStaticTargets.cmake")
Expand Down
6 changes: 3 additions & 3 deletions src/execution/execution_host.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@ ExecutionHost<T>::ExecutionHost(const int numThreads, std::shared_ptr<Parameters
HostArray<std::complex<T>>& array2)
: numThreads_(numThreads),
scalingFactor_(static_cast<T>(
1.0 / static_cast<double>(param->dim_x() * param->dim_y() * param->dim_z()))) {
1.0 / static_cast<double>(param->dim_x() * param->dim_y() * param->dim_z()))),
zStickSymmetry_(new Symmetry()),
planeSymmetry_(new Symmetry()) {
HOST_TIMING_SCOPED("Execution init");
const SizeType numLocalZSticks = param->num_z_sticks(0);
const SizeType numLocalXYPlanes = param->num_xy_planes(0);
Expand Down Expand Up @@ -103,8 +105,6 @@ ExecutionHost<T>::ExecutionHost(const int numThreads, std::shared_ptr<Parameters
transformXForward_.reset(new R2CTransform1DPlanesHost<T>(
spaceDomainDataExternal_, freqDomainXY_, false, true, numThreads));
} else {
zStickSymmetry_.reset(new Symmetry());
planeSymmetry_.reset(new Symmetry());

auto spaceDomainData =
create_3d_view(array1, 0, param->dim_z(), param->dim_y(), param->dim_x_freq());
Expand Down

0 comments on commit ae11716

Please sign in to comment.