Skip to content

Commit

Permalink
Add a ddc, fft, pdi and splines targets
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Nov 4, 2024
1 parent dc487b5 commit 583a0f2
Show file tree
Hide file tree
Showing 4 changed files with 73 additions and 35 deletions.
74 changes: 52 additions & 22 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -122,21 +122,29 @@ endif()

## The library itself

### DDC legacy target
add_library(DDC INTERFACE)
target_compile_features(DDC INTERFACE cxx_std_17)
add_library(DDC::DDC ALIAS DDC)
install(TARGETS DDC EXPORT DDCTargets)

add_library(ddc INTERFACE)
add_library(DDC::ddc ALIAS ddc)
install(TARGETS ddc EXPORT DDCTargets)
target_compile_definitions(ddc INTERFACE MDSPAN_USE_PAREN_OPERATOR=1)
if("${DDC_BUILD_DOUBLE_PRECISION}")
target_compile_definitions(ddc INTERFACE DDC_BUILD_DOUBLE_PRECISION)
endif()
target_compile_features(ddc INTERFACE cxx_std_17)
target_include_directories(
DDC
ddc
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_link_libraries(DDC INTERFACE Kokkos::kokkos)
target_compile_definitions(DDC INTERFACE MDSPAN_USE_PAREN_OPERATOR=1)
if("${DDC_BUILD_DOUBLE_PRECISION}")
target_compile_definitions(DDC INTERFACE DDC_BUILD_DOUBLE_PRECISION)
endif()
add_library(DDC::DDC ALIAS DDC)
install(TARGETS DDC EXPORT DDCTargets)
target_link_libraries(ddc INTERFACE Kokkos::kokkos)

### DDC legacy target
target_link_libraries(DDC INTERFACE ddc)

# Link library to DDC

Expand Down Expand Up @@ -165,20 +173,22 @@ if("${DDC_BUILD_KERNELS_FFT}")
find_package(KokkosFFT 0.2.1...<1 REQUIRED)
endif()

target_link_libraries(DDC INTERFACE KokkosFFT::fft)
target_compile_definitions(DDC INTERFACE "DDC_BUILD_KERNELS_FFT")
add_library(ddc_fft INTERFACE)
add_library(DDC::fft ALIAS ddc_fft)
install(TARGETS ddc_fft EXPORT DDCTargets)
target_compile_definitions(ddc_fft INTERFACE "DDC_BUILD_KERNELS_FFT")
target_link_libraries(ddc_fft INTERFACE ddc Kokkos::kokkos KokkosFFT::fft)

### DDC legacy target
target_link_libraries(DDC INTERFACE ddc_fft)
endif()

if("${DDC_BUILD_KERNELS_SPLINES}")
# Ginkgo
find_package(Ginkgo 1.8.0 EXACT REQUIRED)
target_link_libraries(DDC INTERFACE Ginkgo::ginkgo)

# Lapacke
find_package(LAPACKE REQUIRED)
target_link_libraries(DDC INTERFACE ${LAPACKE_LIBRARIES})
target_include_directories(DDC SYSTEM INTERFACE ${LAPACKE_INCLUDE_DIRS})
install(FILES cmake/FindLAPACKE.cmake DESTINATION lib/cmake/DDC)

# Kokkos-kernels
set(DDC_KokkosKernels_DEPENDENCY_POLICY
Expand All @@ -203,25 +213,45 @@ if("${DDC_BUILD_KERNELS_SPLINES}")
find_package(KokkosKernels REQUIRED)
endif()

target_link_libraries(DDC INTERFACE Kokkos::kokkoskernels)
target_compile_definitions(DDC INTERFACE "DDC_BUILD_KERNELS_SPLINES")
add_library(ddc_splines INTERFACE)
add_library(DDC::splines ALIAS ddc_splines)
install(FILES cmake/FindLAPACKE.cmake DESTINATION lib/cmake/DDC)
install(TARGETS ddc_splines EXPORT DDCTargets)
target_compile_definitions(ddc_splines INTERFACE "DDC_BUILD_KERNELS_SPLINES")
target_include_directories(ddc_splines SYSTEM INTERFACE ${LAPACKE_INCLUDE_DIRS})
target_link_libraries(
ddc_splines
INTERFACE ddc Ginkgo::ginkgo Kokkos::kokkos Kokkos::kokkoskernels ${LAPACKE_LIBRARIES}
)

### DDC legacy target
target_link_libraries(DDC INTERFACE ddc_splines)
endif()

## The PDI wrapper

if("${DDC_BUILD_PDI_WRAPPER}")
add_library(PDI_Wrapper INTERFACE)
target_compile_features(PDI_Wrapper INTERFACE cxx_std_17)
add_library(ddc_pdi INTERFACE)
add_library(DDC::pdi ALIAS ddc_pdi)
install(TARGETS ddc_pdi EXPORT DDCTargets)
target_compile_definitions(ddc_pdi INTERFACE "DDC_BUILD_PDI_WRAPPER")
target_compile_features(ddc_pdi INTERFACE cxx_std_17)
target_include_directories(
PDI_Wrapper
ddc_pdi
INTERFACE
"$<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>"
"$<INSTALL_INTERFACE:include>"
)
target_link_libraries(PDI_Wrapper INTERFACE DDC::DDC PDI::PDI_C)
target_compile_definitions(PDI_Wrapper INTERFACE "DDC_BUILD_PDI_WRAPPER")
target_link_libraries(ddc_pdi INTERFACE ddc PDI::PDI_C)

### PDI_Wrapper legacy target
add_library(PDI_Wrapper INTERFACE)
add_library(DDC::PDI_Wrapper ALIAS PDI_Wrapper)
install(TARGETS PDI_Wrapper EXPORT DDCTargets)
target_link_libraries(PDI_Wrapper INTERFACE ddc_pdi)

### DDC legacy target
target_link_libraries(DDC INTERFACE ddc_pdi)
endif()

## if examples are enabled, build them
Expand Down
6 changes: 6 additions & 0 deletions cmake/DDCConfig.cmake.in
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,10 @@ endif()

include(${CMAKE_CURRENT_LIST_DIR}/DDCTargets.cmake)

foreach(target fft;pdi;splines)
if(TARGET DDC::ddc_${target})
add_library(DDC::${target} ALIAS DDC::ddc_${target})
endif()
endforeach()

check_required_components(DDC)
26 changes: 14 additions & 12 deletions examples/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,28 +2,30 @@
#
# SPDX-License-Identifier: MIT

add_executable(game_of_life game_of_life.cpp)
target_link_libraries(game_of_life PUBLIC DDC::ddc)

add_executable(heat_equation heat_equation.cpp)
target_link_libraries(heat_equation PUBLIC DDC::DDC)
target_link_libraries(heat_equation PUBLIC DDC::ddc)

add_executable(uniform_heat_equation uniform_heat_equation.cpp)
add_executable(non_uniform_heat_equation non_uniform_heat_equation.cpp)
target_link_libraries(uniform_heat_equation PUBLIC DDC::ddc)

target_link_libraries(uniform_heat_equation PUBLIC DDC::DDC)
target_link_libraries(non_uniform_heat_equation PUBLIC DDC::DDC)
target_link_libraries(uniform_heat_equation PUBLIC DDC::DDC)
add_executable(non_uniform_heat_equation non_uniform_heat_equation.cpp)
target_link_libraries(non_uniform_heat_equation PUBLIC DDC::ddc)

if("${DDC_BUILD_PDI_WRAPPER}")
target_link_libraries(heat_equation PUBLIC DDC::PDI_Wrapper)
target_link_libraries(uniform_heat_equation PUBLIC DDC::PDI_Wrapper)
target_link_libraries(non_uniform_heat_equation PUBLIC DDC::PDI_Wrapper)
target_link_libraries(heat_equation PUBLIC DDC::pdi)
target_link_libraries(uniform_heat_equation PUBLIC DDC::pdi)
target_link_libraries(non_uniform_heat_equation PUBLIC DDC::pdi)
endif()

if("${DDC_BUILD_KERNELS_FFT}")
add_executable(heat_equation_spectral heat_equation_spectral.cpp)
target_link_libraries(heat_equation_spectral PUBLIC DDC::DDC)
target_link_libraries(heat_equation_spectral PUBLIC DDC::ddc DDC::fft)
endif()
add_executable(game_of_life game_of_life.cpp)
target_link_libraries(game_of_life PUBLIC DDC::DDC)

if("${DDC_BUILD_KERNELS_SPLINES}")
add_executable(characteristics_advection characteristics_advection.cpp)
target_link_libraries(characteristics_advection PUBLIC DDC::DDC)
target_link_libraries(characteristics_advection PUBLIC DDC::ddc DDC::splines)
endif()
2 changes: 1 addition & 1 deletion install_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ message("DDC_BUILD_KERNELS_SPLINES=${DDC_BUILD_KERNELS_SPLINES}")
message("DDC_BUILD_PDI_WRAPPER=${DDC_BUILD_PDI_WRAPPER}")

add_executable(main main.cpp)
target_link_libraries(main PRIVATE DDC::DDC DDC::PDI_Wrapper)
target_link_libraries(main PRIVATE DDC::ddc DDC::fft DDC::pdi DDC::splines)

0 comments on commit 583a0f2

Please sign in to comment.