Skip to content

Commit

Permalink
Add missing dependencies on installed config
Browse files Browse the repository at this point in the history
  • Loading branch information
tpadioleau committed Oct 16, 2024
1 parent f33b08b commit 3a2b7ce
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 48 deletions.
61 changes: 13 additions & 48 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -26,42 +26,10 @@ set(DDC_DEPENDENCY_POLICIES "AUTO" "EMBEDDED" "INSTALLED" "SUBPROJECT")
include(CMakePackageConfigHelpers)
include(CTest)

## Custom cmake modules
list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake")
include(DDCVendorConfiguration)

macro(ddc_configure_embedded_kokkos)
if("${Kokkos_ENABLE_CUDA}")
option(Kokkos_ENABLE_CUDA_CONSTEXPR "Whether to activate experimental relaxed constexpr functions" ON)
option(Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE "Whether to enable relocatable device code (RDC) for CUDA" ON)
endif()
if("${Kokkos_ENABLE_HIP}")
option(Kokkos_ENABLE_HIP_RELOCATABLE_DEVICE_CODE "Whether to enable relocatable device code (RDC) for HIP" ON)
endif()
add_subdirectory(vendor/kokkos)
endmacro()

macro(ddc_configure_embedded_kokkos_fft)
option(KokkosFFT_ENABLE_HOST_AND_DEVICE "Enable FFT on both host and device" ON)
add_subdirectory(vendor/kokkos-fft)
endmacro()

macro(ddc_configure_embedded_kokkos_kernels)
set(KokkosKernels_ENABLE_ALL_COMPONENTS OFF)
set(KokkosKernels_ENABLE_COMPONENT_BLAS ON)
set(KokkosKernels_ENABLE_COMPONENT_BATCHED ON)
set(KokkosKernels_ENABLE_COMPONENT_LAPACK OFF)
set(KokkosKernels_ENABLE_TPL_BLAS OFF)
set(KokkosKernels_ENABLE_TPL_LAPACK OFF)
add_subdirectory(vendor/kokkos-kernels)
endmacro()

macro(ddc_configure_embedded_googletest)
add_subdirectory(vendor/googletest)
endmacro()

macro(ddc_configure_embedded_benchmark)
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." OFF)
option(BENCHMARK_ENABLE_INSTALL "Enable installation of benchmark. (Projects embedding benchmark may want to turn this OFF.)" OFF)
add_subdirectory(vendor/benchmark)
endmacro()

## kokkos

Expand All @@ -71,18 +39,15 @@ if("${DDC_Kokkos_DEPENDENCY_POLICY}" STREQUAL "AUTO")
if(NOT TARGET Kokkos::kokkos)
find_package(Kokkos 4.4...4.5 CONFIG QUIET)
if(NOT Kokkos_FOUND)
ddc_configure_embedded_kokkos()
ddc_configure_kokkos()
endif()
endif()
elseif("${DDC_Kokkos_DEPENDENCY_POLICY}" STREQUAL "EMBEDDED")
ddc_configure_embedded_kokkos()
ddc_configure_kokkos()
elseif("${DDC_Kokkos_DEPENDENCY_POLICY}" STREQUAL "INSTALLED")
find_package(Kokkos 4.4...4.5 CONFIG REQUIRED)
endif()

# Custom cmake modules
list( APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake" )


## PDI

Expand All @@ -103,11 +68,11 @@ if("${BUILD_TESTING}" AND "${DDC_BUILD_TESTS}")
if(NOT TARGET GTest::GTest AND NOT TARGET GTest::gtest)
find_package(GTest QUIET)
if(NOT GTest_FOUND)
ddc_configure_embedded_googletest()
ddc_configure_googletest()
endif()
endif()
elseif("${DDC_GTest_DEPENDENCY_POLICY}" STREQUAL "EMBEDDED")
ddc_configure_embedded_googletest()
ddc_configure_googletest()
elseif("${DDC_GTest_DEPENDENCY_POLICY}" STREQUAL "INSTALLED")
find_package(GTest REQUIRED)
endif()
Expand All @@ -126,11 +91,11 @@ if("${DDC_BUILD_BENCHMARKS}")
if(NOT TARGET benchmark::benchmark)
find_package(benchmark QUIET)
if(NOT benchmark_FOUND)
ddc_configure_embedded_benchmark()
ddc_configure_benchmark()
endif()
endif()
elseif("${DDC_benchmark_DEPENDENCY_POLICY}" STREQUAL "EMBEDDED")
ddc_configure_embedded_benchmark()
ddc_configure_benchmark()
elseif("${DDC_benchmark_DEPENDENCY_POLICY}" STREQUAL "INSTALLED")
find_package(benchmark REQUIRED)
endif()
Expand Down Expand Up @@ -184,11 +149,11 @@ if("${DDC_BUILD_KERNELS_FFT}")
if(NOT TARGET KokkosFFT::fft)
find_package(KokkosFFT 0.2.1...<1 CONFIG QUIET)
if(NOT KokkosFFT_FOUND)
ddc_configure_embedded_kokkos_fft()
ddc_configure_kokkos_fft()
endif()
endif()
elseif("${DDC_KokkosFFT_DEPENDENCY_POLICY}" STREQUAL "EMBEDDED")
ddc_configure_embedded_kokkos_fft()
ddc_configure_kokkos_fft()
elseif("${DDC_KokkosFFT_DEPENDENCY_POLICY}" STREQUAL "INSTALLED")
find_package(KokkosFFT 0.2.1...<1 CONFIG REQUIRED)
endif()
Expand All @@ -214,11 +179,11 @@ if("${DDC_BUILD_KERNELS_SPLINES}")
if(NOT TARGET Kokkos::kokkoskernels)
find_package(KokkosKernels QUIET)
if(NOT KokkosKernels_FOUND)
ddc_configure_embedded_kokkos_kernels()
ddc_configure_kokkos_kernels()
endif()
endif()
elseif("${DDC_KokkosKernels_DEPENDENCY_POLICY}" STREQUAL "EMBEDDED")
ddc_configure_embedded_kokkos_kernels()
ddc_configure_kokkos_kernels()
elseif("${DDC_KokkosKernels_DEPENDENCY_POLICY}" STREQUAL "INSTALLED")
find_package(KokkosKernels REQUIRED)
endif()
Expand Down
42 changes: 42 additions & 0 deletions cmake/DDCVendorConfiguration.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
# Copyright (C) The DDC development team, see COPYRIGHT.md file
#
# SPDX-License-Identifier: MIT

# This file provides different macros that will configure the dependencies with required options.
# They should be used only if DDC is responsible of handling the vendor dependency.

macro(ddc_configure_benchmark)
option(BENCHMARK_ENABLE_TESTING "Enable testing of the benchmark library." OFF)
option(BENCHMARK_ENABLE_INSTALL "Enable installation of benchmark. (Projects embedding benchmark may want to turn this OFF.)" OFF)
add_subdirectory(vendor/benchmark)
endmacro()

macro(ddc_configure_googletest)
add_subdirectory(vendor/googletest)
endmacro()

macro(ddc_configure_kokkos)
if("${Kokkos_ENABLE_CUDA}")
option(Kokkos_ENABLE_CUDA_CONSTEXPR "Whether to activate experimental relaxed constexpr functions" ON)
option(Kokkos_ENABLE_CUDA_RELOCATABLE_DEVICE_CODE "Whether to enable relocatable device code (RDC) for CUDA" ON)
endif()
if("${Kokkos_ENABLE_HIP}")
option(Kokkos_ENABLE_HIP_RELOCATABLE_DEVICE_CODE "Whether to enable relocatable device code (RDC) for HIP" ON)
endif()
add_subdirectory(vendor/kokkos)
endmacro()

macro(ddc_configure_kokkos_fft)
option(KokkosFFT_ENABLE_HOST_AND_DEVICE "Enable FFT on both host and device" ON)
add_subdirectory(vendor/kokkos-fft)
endmacro()

macro(ddc_configure_kokkos_kernels)
set(KokkosKernels_ENABLE_ALL_COMPONENTS OFF)
set(KokkosKernels_ENABLE_COMPONENT_BLAS ON)
set(KokkosKernels_ENABLE_COMPONENT_BATCHED ON)
set(KokkosKernels_ENABLE_COMPONENT_LAPACK OFF)
set(KokkosKernels_ENABLE_TPL_BLAS OFF)
set(KokkosKernels_ENABLE_TPL_LAPACK OFF)
add_subdirectory(vendor/kokkos-kernels)
endmacro()

0 comments on commit 3a2b7ce

Please sign in to comment.