Skip to content

Commit

Permalink
Merge pull request #31 from eth-cscs/develop
Browse files Browse the repository at this point in the history
  • Loading branch information
AdhocMan authored Dec 6, 2019
2 parents d550618 + 2cb18e3 commit 92307b2
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 14 deletions.
17 changes: 14 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
cmake_minimum_required(VERSION 3.11 FATAL_ERROR) # 3.8 added CUDA language support without FindCUDA
cmake_minimum_required(VERSION 3.11 FATAL_ERROR) # 3.11 to avoid issues with OpenMP + CUDA
project(SpFFT LANGUAGES CXX VERSION 0.9.9)
set(SPFFT_SO_VERSION 0)
set(SPFFT_VERSION ${PROJECT_VERSION})

# allow {module}_ROOT variables to be set
if(POLICY CMP0074)
Expand Down Expand Up @@ -33,12 +35,16 @@ option(SPFFT_GPU_DIRECT "Compile with GPU direct (GPU aware MPI) support." OFF)
option(SPFFT_BUILD_TESTS "Build tests" OFF)
option(SPFFT_SINGLE_PRECISION "Enable single precision support" OFF)
option(SPFFT_INSTALL "Enable CMake install commands" ON)
option(SPFFT_FORTRAN "Compile fortran module" OFF)

set(SPFFT_GPU_BACKEND "OFF" CACHE STRING "GPU backend")
set_property(CACHE SPFFT_GPU_BACKEND PROPERTY STRINGS
"OFF" "CUDA" "ROCM"
)

# Get GNU standard install prefixes
include(GNUInstallDirs)

# set preferred library type
if (SPFFT_STATIC)
# prefer static over dynamic libraries with the find_library() command by changing the order
Expand Down Expand Up @@ -88,6 +94,11 @@ else()
set(CMAKE_VISIBILITY_INLINES_HIDDEN 0)
endif()

# Fortran
if(SPFFT_FORTRAN)
enable_language(Fortran)
endif()

# CUDA
if(SPFFT_CUDA)
enable_language(CUDA)
Expand All @@ -107,7 +118,7 @@ endif()


if(SPFFT_MPI)
find_package(MPI REQUIRED)
find_package(MPI COMPONENTS CXX REQUIRED)
list(APPEND SPFFT_EXTERNAL_LIBS MPI::MPI_CXX)
# always add MPI to interface libraries, because mpi.h is included in public header files
if(SPFFT_STATIC)
Expand All @@ -117,7 +128,7 @@ if(SPFFT_MPI)
endif()

if(SPFFT_OMP)
find_package(OpenMP REQUIRED)
find_package(OpenMP COMPONENTS CXX REQUIRED)
list(APPEND SPFFT_EXTERNAL_LIBS OpenMP::OpenMP_CXX)
if(SPFFT_STATIC)
list(APPEND SPFFT_INTERFACE_LIBS ${OpenMP_CXX_LIBRARIES})
Expand Down
11 changes: 10 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,11 @@
SpFFT - A 3D FFT library for sparse frequency domain data written in C++ with support for MPI, OpenMP, CUDA and ROCm.

It was originally intended for transforms of data with spherical cutoff in frequency domain, as required by some computational material science codes.
For distributed computations, SpFFT uses a slab decomposition in space domain and pencil decomposition in frequency domain (all sparse data within a pencil must be on one rank). If desired, the libray can be compiled without any parallization (MPI, OpenMP, CUDA / ROCm).
For distributed computations, SpFFT uses a slab decomposition in space domain and pencil decomposition in frequency domain (all sparse data within a pencil must be on one rank).

<img src="docs/images/sparse_to_dense.png" alt="" width=70% />

***Fig. 1:*** Illustration of a transform, where data on each MPI rank is identified by color.

### Design Goals
- Sparse frequency domain input
Expand All @@ -15,6 +19,7 @@ For distributed computations, SpFFT uses a slab decomposition in space domain an
- Unified interface for calculations on CPUs and GPUs
- Support of Complex-To-Real and Real-To-Complex transforms, where the full hermitian symmetry property is utilized.
- C++, C and Fortran interfaces
- Parallelization and acceleration are optional

### Interface Design
To allow for pre-allocation and reuse of memory, the design is based on two classes:
Expand Down Expand Up @@ -59,6 +64,10 @@ make -j8 install
| SPFFT_STATIC | OFF | Build as static library |
| SPFFT_BUILD_TESTS | OFF | Build test executables for developement purposes |
| SPFFT_INSTALL | ON | Add library to install target |
| SPFFT_FORTRAN | OFF | Build Fortran interface module |




## Examples
Further exmples for C++, C and Fortran can be found in the "examples" folder.
Expand Down
2 changes: 1 addition & 1 deletion docs/Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ QUIET = YES
JAVADOC_AUTOBRIEF = YES
WARN_IF_UNDOCUMENTED = NO
MACRO_EXPANSION = YES
PREDEFINED = "SPFFT_MPI" "SPFFT_SINGLE_PRECISION"
PREDEFINED = "SPFFT_MPI" "SPFFT_SINGLE_PRECISION" "SPFFT_EXPORT"
EXTRACT_PRIVATE = NO
EXTRACT_ALL = YES
Binary file added docs/images/sparse_to_dense.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
3 changes: 2 additions & 1 deletion docs/source/examples.rst
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,8 @@ Fortran
! create grid and transform
errorCode = spfft_grid_create(grid, dimX, dimY, dimZ, maxNumLocalZColumns, processingUnit, maxNumThreads);
if (errorCode /= SPFFT_SUCCESS) error stop
errorCode = spfft_transform_create(transform, grid, processingUnit, 0, dimX, dimY, dimZ, dimZ, size(frequencyElements), 0, indices)
errorCode = spfft_transform_create(transform, grid, processingUnit, 0, dimX, dimY, dimZ, dimZ,&
size(frequencyElements), SPFFT_INDEX_TRIPLETS, indices)
if (errorCode /= SPFFT_SUCCESS) error stop
! grid can be safely destroyed after creating all required transforms
Expand Down
8 changes: 7 additions & 1 deletion docs/source/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,13 @@ SpFFT Documentation
===================
| SpFFT - A 3D FFT library for sparse frequency domain data written in C++ with support for MPI, OpenMP, CUDA and ROCm. It was originally intended for transforms of data with spherical cutoff in frequency domain, as required by some computational material science codes.
| For distributed computations, SpFFT uses a slab decomposition in space domain and pencil decomposition in frequency domain (all sparse data within a pencil must be on one rank). If desired, the libray can be compiled without any parallization (MPI, OpenMP, CUDA / ROCm).
| For distributed computations, SpFFT uses a slab decomposition in space domain and pencil decomposition in frequency domain (all sparse data within a pencil must be on one rank).
.. figure:: ../images/sparse_to_dense.png
:align: center
:width: 70%

Illustration of a transform, where data on each MPI rank is identified by color.

Design Goals
------------
Expand All @@ -20,6 +25,7 @@ Design Goals
- Unified interface for calculations on CPUs and GPUs
- Support of Complex-To-Real and Real-To-Complex transforms, where the full hermitian symmetry property is utilized.
- C++, C and Fortran interfaces
- Parallelization and acceleration are optional

Interface Design
----------------
Expand Down
1 change: 1 addition & 0 deletions docs/source/installation.rst
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,5 @@ SPFFT_SINGLE_PRECISION OFF Enable single precision support
SPFFT_STATIC OFF Build as static library
SPFFT_BUILD_TESTS OFF Build test executables for developement purposes
SPFFT_INSTALL ON Add library to install target
SPFFT_FORTRAN OFF Build Fortran interface module
====================== ======= ================================================
3 changes: 2 additions & 1 deletion examples/example.f90
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ program main
! create grid and transform
errorCode = spfft_grid_create(grid, dimX, dimY, dimZ, maxNumLocalZColumns, processingUnit, maxNumThreads);
if (errorCode /= SPFFT_SUCCESS) error stop
errorCode = spfft_transform_create(transform, grid, processingUnit, 0, dimX, dimY, dimZ, dimZ, size(frequencyElements), 0, indices)
errorCode = spfft_transform_create(transform, grid, processingUnit, 0, dimX, dimY, dimZ, dimZ,&
size(frequencyElements), SPFFT_INDEX_TRIPLETS, indices)
if (errorCode /= SPFFT_SUCCESS) error stop

! grid can be safely destroyed after creating all required transforms
Expand Down
24 changes: 18 additions & 6 deletions src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,13 @@ endif()
add_library(spfft ${SPFFT_LIBRARY_TYPE}
${SPFFT_SOURCE_FILES}
)
set_property(TARGET spfft PROPERTY VERSION ${SPFFT_VERSION})
set_property(TARGET spfft PROPERTY SOVERSION ${SPFFT_SO_VERSION})

# 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)
Expand Down Expand Up @@ -147,10 +154,10 @@ configure_file(${PROJECT_SOURCE_DIR}/cmake/SpFFT.pc.in

# installation commands
if(SPFFT_INSTALL)
install(TARGETS spfft DESTINATION lib EXPORT SpFFTTargets)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/spfft DESTINATION include FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "*.f90")
install(FILES ${PROJECT_BINARY_DIR}/spfft/config.h "${PROJECT_BINARY_DIR}/spfft/spfft_export.h" DESTINATION include/spfft)
install(EXPORT SpFFTTargets NAMESPACE SpFFT:: DESTINATION lib/cmake/SpFFT FILE ${SPFFT_TARGETS_FILE})
install(TARGETS spfft DESTINATION ${CMAKE_INSTALL_LIBDIR} EXPORT SpFFTTargets)
install(DIRECTORY ${PROJECT_SOURCE_DIR}/include/spfft DESTINATION ${CMAKE_INSTALL_INCLUDEDIR} FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN "*.f90")
install(FILES ${PROJECT_BINARY_DIR}/spfft/config.h "${PROJECT_BINARY_DIR}/spfft/spfft_export.h" DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/spfft)
install(EXPORT SpFFTTargets NAMESPACE SpFFT:: DESTINATION ${CMAKE_INSTALL_LIBDIR}/cmake/SpFFT FILE ${SPFFT_TARGETS_FILE})
install(
FILES
"${PROJECT_BINARY_DIR}/SpFFTConfig.cmake"
Expand All @@ -159,7 +166,12 @@ if(SPFFT_INSTALL)
"${PROJECT_BINARY_DIR}/${SPFFT_CONFIG_FILE}"
"${PROJECT_BINARY_DIR}/${SPFFT_VERSION_FILE}"
DESTINATION
lib/cmake/SpFFT
${CMAKE_INSTALL_LIBDIR}/cmake/SpFFT
)
install(FILES ${PROJECT_BINARY_DIR}/SpFFT.pc DESTINATION lib/pkgconfig)

install(FILES ${PROJECT_BINARY_DIR}/SpFFT.pc DESTINATION ${CMAKE_INSTALL_LIBDIR}/pkgconfig)

if(SPFFT_FORTRAN)
install(FILES ${PROJECT_BINARY_DIR}/src/spfft.mod DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/spfft)
endif()
endif()

0 comments on commit 92307b2

Please sign in to comment.