diff --git a/CMakeLists.txt b/CMakeLists.txt index c03396b..e21849d 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -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) @@ -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 @@ -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) @@ -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) @@ -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}) diff --git a/README.md b/README.md index a987f44..1c45725 100644 --- a/README.md +++ b/README.md @@ -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). + + + +***Fig. 1:*** Illustration of a transform, where data on each MPI rank is identified by color. ### Design Goals - Sparse frequency domain input @@ -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: @@ -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. diff --git a/docs/Doxyfile b/docs/Doxyfile index 1d016b9..f0e01fa 100644 --- a/docs/Doxyfile +++ b/docs/Doxyfile @@ -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 diff --git a/docs/images/sparse_to_dense.png b/docs/images/sparse_to_dense.png new file mode 100644 index 0000000..457fa2e Binary files /dev/null and b/docs/images/sparse_to_dense.png differ diff --git a/docs/source/examples.rst b/docs/source/examples.rst index 800a00c..34ec4dd 100644 --- a/docs/source/examples.rst +++ b/docs/source/examples.rst @@ -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 diff --git a/docs/source/index.rst b/docs/source/index.rst index a9a8181..7219771 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -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 ------------ @@ -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 ---------------- diff --git a/docs/source/installation.rst b/docs/source/installation.rst index 68d1151..5af73e3 100644 --- a/docs/source/installation.rst +++ b/docs/source/installation.rst @@ -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 ====================== ======= ================================================ diff --git a/examples/example.f90 b/examples/example.f90 index 86f35b6..f41a12c 100644 --- a/examples/example.f90 +++ b/examples/example.f90 @@ -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 diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 1899b8c..89146b5 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -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) @@ -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" @@ -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()