Skip to content

Commit

Permalink
Improve to print details of tpls in CMake
Browse files Browse the repository at this point in the history
  • Loading branch information
yasahi-hpc committed Aug 20, 2024
1 parent e3454ae commit 46e952f
Show file tree
Hide file tree
Showing 4 changed files with 85 additions and 48 deletions.
18 changes: 15 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,17 @@ endif ()

# Set tpls
set(KOKKOSFFT_TPL_LIST)
set(KOKKOSFFT_BACKEND_LIST)
include(KokkosFFT_tpls)
get_tpls_list(KOKKOSFFT_TPL_LIST)
get_tpls_list(KOKKOSFFT_TPL_LIST KOKKOSFFT_BACKEND_LIST)

# Get the size of the lists
list(LENGTH KOKKOSFFT_TPL_LIST KOKKOSFFT_TPL_LIST_LEN)
list(LENGTH KOKKOSFFT_BACKEND_LIST KOKKOSFFT_BACKEND_LIST_LEN)

if(NOT KOKKOSFFT_TPL_LIST_LEN EQUAL KOKKOSFFT_BACKEND_LIST_LEN)
message(FATAL_ERROR "Lists have different lengths, cannot zip")
endif()

# ==================================================================
# CMake Summary
Expand All @@ -56,9 +65,12 @@ message("")
message(STATUS "KokkosFFT version: ${KOKKOSFFT_VERSION_MAJOR}.${KOKKOSFFT_VERSION_MINOR}.${KOKKOSFFT_VERSION_PATCH}")
message(STATUS "KokkosFFT TPLs:")
if(KOKKOSFFT_TPL_LIST)
foreach(TPL ${KOKKOSFFT_TPL_LIST})
math(EXPR LOOP_LEN "${KOKKOSFFT_TPL_LIST_LEN} - 1")
foreach(i RANGE 0 ${LOOP_LEN})
# [TO DO] show more information about the library (like location)
message(STATUS " ${TPL}")
list(GET KOKKOSFFT_BACKEND_LIST ${i} BACKEND)
list(GET KOKKOSFFT_TPL_LIST ${i} TPL)
message(STATUS " ${BACKEND}: ${TPL}")
endforeach()
else()
message(STATUS " (None)")
Expand Down
3 changes: 3 additions & 0 deletions cmake/KokkosFFT_config.h.in
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
/* CUFFT */
#cmakedefine KOKKOSFFT_ENABLE_TPL_CUFFT

/* ROCFFT */
#cmakedefine KOKKOSFFT_ENABLE_TPL_ROCFFT

/* HIPFFT */
#cmakedefine KOKKOSFFT_ENABLE_TPL_HIPFFT

Expand Down
33 changes: 25 additions & 8 deletions cmake/KokkosFFT_tpls.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,34 +2,51 @@
#
# SPDX-License-Identifier: MIT OR Apache-2.0 WITH LLVM-exception

function(get_tpls_list tpls_list)
function(get_tpls_list tpls_list backend_list)
# In order to display Tpls in the Kokkos order
# Device Parallel:
# Host Parallel:
# Host Serial:
if(Kokkos_ENABLE_CUDA)
list(APPEND tpls_list CUFFT)
list(APPEND backend_list "Device Parallel")
elseif(Kokkos_ENABLE_HIP)
if(KokkosFFT_ENABLE_ROCFFT)
list(APPEND tpls_list ROCFFT)
else()
list(APPEND tpls_list HIPFFT)
endif()
list(APPEND backend_list "Device Parallel")
elseif(Kokkos_ENABLE_SYCL)
list(APPEND tpls_list ONEMKL)
list(APPEND backend_list "Device Parallel")
elseif(Kokkos_ENABLE_OPENMP)
list(APPEND tpls_list FFTW_OPENMP)
list(APPEND backend_list "Host Parallel")
elseif(Kokkos_ENABLE_THREADS)
list(APPEND tpls_list FFTW_THREADS)
elseif(Kokkos_ENABLE_SERIAL)
list(APPEND tpls_list FFTW)
list(APPEND backend_list "Host Parallel")
endif()

if(KokkosFFT_ENABLE_HOST_AND_DEVICE)
if(Kokkos_ENABLE_OPENMP)
# Check if TPL is already included
list(FIND tpls_list "FFTW_OPENMP" idx_FFTW_OPENMP)
list(FIND tpls_list "FFTW_THREADS" idx_FFTW_THREADS)
if(Kokkos_ENABLE_OPENMP AND (idx_FFTW_OPENMP EQUAL -1))
list(APPEND tpls_list FFTW_OPENMP)
elseif(Kokkos_ENABLE_THREADS)
list(APPEND backend_list "Host Parallel")
elseif(Kokkos_ENABLE_THREADS AND (idx_FFTW_THREADS EQUAL -1))
list(APPEND tpls_list FFTW_THREADS)
else()
list(APPEND tpls_list FFTW)
list(APPEND backend_list "Host Parallel")
endif()
endif()

if(Kokkos_ENABLE_SERIAL)
list(APPEND tpls_list FFTW_SERIAL)
list(APPEND backend_list " Host Serial")
endif()

set(${tpls_list} ${${tpls_list}} PARENT_SCOPE)
endfunction()
set(${backend_list} ${${backend_list}} PARENT_SCOPE)
endfunction()

79 changes: 42 additions & 37 deletions common/src/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -9,55 +9,60 @@ target_link_libraries(common
Kokkos::kokkos
)

if(Kokkos_ENABLE_CUDA)
find_package(CUDAToolkit REQUIRED COMPONENTS cufft)
target_link_libraries(common INTERFACE CUDA::cufft)
target_compile_definitions(common INTERFACE KOKKOSFFT_ENABLE_TPL_CUFFT)
if(KokkosFFT_ENABLE_HOST_AND_DEVICE)
find_package(FFTW MODULE REQUIRED)
target_link_libraries(common INTERFACE FFTW::Float FFTW::Double FFTW::FloatOpenMP FFTW::DoubleOpenMP)
target_compile_definitions(common INTERFACE ENABLE_HOST_AND_DEVICE KOKKOSFFT_ENABLE_TPL_FFTW)
endif()
elseif(Kokkos_ENABLE_HIP)
if(KokkosFFT_ENABLE_ROCFFT)
# Check which tpls are needed
list(FIND tpls_list "CUFFT" idx_CUFFT)
list(FIND tpls_list "ROCFFT" idx_ROCFFT)
list(FIND tpls_list "HIPFFT" idx_HIPFFT)
list(FIND tpls_list "ONEMKL" idx_ONEMKL)
list(FIND tpls_list "FFTW_OPENMP" idx_FFTW_OPENMP)
list(FIND tpls_list "FFTW_THREADS" idx_FFTW_THREADS)
list(FIND tpls_list "FFTW_SERIAL" idx_FFTW_SERIAL)

if(idx_CUFFT GREATER -1)
find_package(CUDAToolkit REQUIRED COMPONENTS cufft)
target_link_libraries(common INTERFACE CUDA::cufft)
target_compile_definitions(common INTERFACE KOKKOSFFT_ENABLE_TPL_CUFFT)
endif()

if(idx_ROCFFT GREATER -1)
find_package(rocfft REQUIRED)
target_link_libraries(common INTERFACE roc::rocfft)
target_compile_definitions(common INTERFACE KOKKOSFFT_ENABLE_TPL_ROCFFT)
else()
endif()

if(idx_HIPFFT GREATER -1)
find_package(hipfft REQUIRED)
target_link_libraries(common INTERFACE hip::hipfft)
target_compile_definitions(common INTERFACE KOKKOSFFT_ENABLE_TPL_HIPFFT)
endif()
if(KokkosFFT_ENABLE_HOST_AND_DEVICE)
endif()

if(idx_ONEMKL GREATER -1)
find_package(MKL REQUIRED COMPONENTS SYCL)
target_link_libraries(common INTERFACE MKL::MKL_SYCL)
target_compile_definitions(common INTERFACE KOKKOSFFT_ENABLE_TPL_ONEMKL)
endif()

if(idx_FFTW_OPENMP GREATER -1)
find_package(FFTW MODULE REQUIRED)
target_link_libraries(common INTERFACE FFTW::Float FFTW::Double FFTW::FloatOpenMP FFTW::DoubleOpenMP)
target_compile_definitions(common INTERFACE ENABLE_HOST_AND_DEVICE KOKKOSFFT_ENABLE_TPL_FFTW)
endif()
elseif(Kokkos_ENABLE_SYCL)
find_package(MKL REQUIRED COMPONENTS SYCL)
target_link_libraries(common INTERFACE MKL::MKL_SYCL)
target_compile_definitions(common INTERFACE KOKKOSFFT_ENABLE_TPL_ONEMKL)
if(KokkosFFT_ENABLE_HOST_AND_DEVICE)
target_compile_definitions(common INTERFACE KOKKOSFFT_ENABLE_TPL_FFTW)
elseif(idx_FFTW_THREADS GREATER -1)
find_package(FFTW MODULE REQUIRED)
target_link_libraries(common INTERFACE FFTW::Float FFTW::Double FFTW::FloatOpenMP FFTW::DoubleOpenMP)
target_compile_definitions(common INTERFACE ENABLE_HOST_AND_DEVICE KOKKOSFFT_ENABLE_TPL_FFTW)
endif()
elseif(Kokkos_ENABLE_OPENMP)
find_package(FFTW MODULE REQUIRED)
target_link_libraries(common INTERFACE FFTW::Float FFTW::Double FFTW::FloatOpenMP FFTW::DoubleOpenMP)
target_compile_definitions(common INTERFACE KOKKOSFFT_ENABLE_TPL_FFTW)
elseif(Kokkos_ENABLE_THREADS)
find_package(FFTW MODULE REQUIRED)
target_link_libraries(common INTERFACE FFTW::Float FFTW::Double FFTW::FloatThreads FFTW::DoubleThreads)
target_compile_definitions(common INTERFACE KOKKOSFFT_ENABLE_TPL_FFTW)
elseif(Kokkos_ENABLE_SERIAL)
find_package(FFTW MODULE REQUIRED)
target_link_libraries(common INTERFACE FFTW::Float FFTW::Double)
target_compile_definitions(common INTERFACE KOKKOSFFT_ENABLE_TPL_FFTW)
target_link_libraries(common INTERFACE FFTW::Float FFTW::Double FFTW::FloatThreads FFTW::DoubleThreads)
target_compile_definitions(common INTERFACE KOKKOSFFT_ENABLE_TPL_FFTW)
elseif(idx_FFTW_SERIAL GREATER -1)
find_package(FFTW MODULE REQUIRED)
target_link_libraries(common INTERFACE FFTW::Float FFTW::Double)
target_compile_definitions(common INTERFACE KOKKOSFFT_ENABLE_TPL_FFTW)
endif()

if(KokkosFFT_ENABLE_HOST_AND_DEVICE)
target_compile_definitions(common INTERFACE ENABLE_HOST_AND_DEVICE)
endif()

target_compile_features(common INTERFACE cxx_std_17)
target_include_directories(common INTERFACE
$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}>
$<INSTALL_INTERFACE:${INSTALL_INCLUDEDIR}>
)
)

0 comments on commit 46e952f

Please sign in to comment.