From a3008f24160932ca70d124b515a785073a1dbcc3 Mon Sep 17 00:00:00 2001 From: Thomas Padioleau Date: Thu, 30 Jul 2026 19:07:48 +0200 Subject: [PATCH] Add checks about Kokkos options --- CMakeLists.txt | 8 ++++---- cmake/GMGPolarCheckRequiredKokkosOptions.cmake | 14 ++++++++++++++ 2 files changed, 18 insertions(+), 4 deletions(-) create mode 100644 cmake/GMGPolarCheckRequiredKokkosOptions.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index 2660eb33..519ab551 100755 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,8 +1,5 @@ cmake_minimum_required(VERSION 3.12) -# Ensure custom cmake modules can be found -list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") - # Options should be defined before they're used option(GMGPOLAR_BUILD_TESTS "Build GMGPolar unit tests." ON) option(GMGPOLAR_USE_LIKWID "Use LIKWID to measure code (regions)." OFF) @@ -18,7 +15,9 @@ endif() set(CMAKE_CXX_STANDARD 20) set(CMAKE_CXX_STANDARD_REQUIRED True) -set(CMAKE_MODULE_PATH "${PROJECT_SOURCE_DIR}/cmake" ${CMAKE_MODULE_PATH}) +# Ensure custom cmake modules can be found +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") +include(GMGPolarCheckRequiredKokkosOptions) # Set build type - must come before compiler flags if(NOT CMAKE_BUILD_TYPE) @@ -49,6 +48,7 @@ if(GMGPOLAR_ENABLE_COVERAGE) endif() find_package(Kokkos 4.4.1...<6 QUIET REQUIRED) +gmgpolar_check_required_kokkos_options() if(GMGPOLAR_USE_MUMPS) find_package(MUMPS REQUIRED COMPONENTS OpenMP METIS) diff --git a/cmake/GMGPolarCheckRequiredKokkosOptions.cmake b/cmake/GMGPolarCheckRequiredKokkosOptions.cmake new file mode 100644 index 00000000..76670dfb --- /dev/null +++ b/cmake/GMGPolarCheckRequiredKokkosOptions.cmake @@ -0,0 +1,14 @@ +function(gmgpolar_check_required_kokkos_options) + kokkos_check(DEVICES CUDA RETURN_VALUE is_cuda_enabled) + if("${is_cuda_enabled}") + kokkos_check(OPTIONS CUDA_CONSTEXPR CUDA_RELOCATABLE_DEVICE_CODE) + endif() + kokkos_check(DEVICES HIP RETURN_VALUE is_hip_enabled) + if("${is_hip_enabled}") + kokkos_check(OPTIONS HIP_RELOCATABLE_DEVICE_CODE) + endif() + kokkos_check(DEVICES SYCL RETURN_VALUE is_sycl_enabled) + if("${is_sycl_enabled}") + kokkos_check(OPTIONS SYCL_RELOCATABLE_DEVICE_CODE) + endif() +endfunction()