From 0e067746dba2b65f11742fe4a6e7937daeb7f651 Mon Sep 17 00:00:00 2001 From: Wolfgang Bangerth Date: Mon, 10 Mar 2025 16:09:44 -0600 Subject: [PATCH] Export the KOKKOS version numbers. --- bundled/setup_bundled.cmake | 3 +++ cmake/modules/FindDEAL_II_KOKKOS.cmake | 33 ++++++++++++++++++++++++++ include/deal.II/base/config.h.in | 19 +++++++++++++++ 3 files changed, 55 insertions(+) diff --git a/bundled/setup_bundled.cmake b/bundled/setup_bundled.cmake index f514af70fc..60106c434e 100644 --- a/bundled/setup_bundled.cmake +++ b/bundled/setup_bundled.cmake @@ -78,6 +78,9 @@ set(KOKKOS_FOLDER "${CMAKE_SOURCE_DIR}/bundled/kokkos-3.7.00") macro(feature_kokkos_configure_bundled) set(Kokkos_VERSION "3.7.0") set(KOKKOS_VERSION "3.7.0") + set(KOKKOS_VERSION_MAJOR "3") + set(KOKKOS_VERSION_MINOR "7") + set(KOKKOS_VERSION_SUBMINOR "0") set(Kokkos_DEVICES "Serial") set(Kokkos_ARCH " ") diff --git a/cmake/modules/FindDEAL_II_KOKKOS.cmake b/cmake/modules/FindDEAL_II_KOKKOS.cmake index ac27fe1b62..e5266c783d 100644 --- a/cmake/modules/FindDEAL_II_KOKKOS.cmake +++ b/cmake/modules/FindDEAL_II_KOKKOS.cmake @@ -20,6 +20,9 @@ # KOKKOS_INCLUDE_DIRS # KOKKOS_INTERFACE_LINK_FLAGS # KOKKOS_VERSION +# KOKKOS_VERSION_MAJOR +# KOKKOS_VERSION_MINOR +# KOKKOS_VERSION_SUBMINOR # set(KOKKOS_DIR "" CACHE PATH "An optional hint to a Kokkos installation") @@ -162,4 +165,34 @@ if(KOKKOS_FOUND) # warning #940-D: missing return statement at end of non-void function enable_if_supported(DEAL_II_CXX_FLAGS "-Xcudafe --diag_suppress=940") endif() + + # + # Extract version numbers: + # + if(NOT KOKKOS_VERSION) + if(Kokkos_VERSION) + set(KOKKOS_VERSION "${Kokkos_VERSION}") + else() + message(FATAL_ERROR "FindPackage(Kokkos) did not set KOKKOS_VERSION!") + endif() + endif() + + string(REGEX REPLACE + "^([0-9]+).*$" "\\1" + KOKKOS_VERSION_MAJOR "${KOKKOS_VERSION}") + + string(REGEX REPLACE + "^[0-9]+\\.([0-9]+).*$" "\\1" + KOKKOS_VERSION_MINOR "${KOKKOS_VERSION}") + + # If there is no subminor number, KOKKOS_VERSION_SUBMINOR is set to an + # empty string. If that is the case, set the subminor number to zero + string(REGEX REPLACE + "^[0-9]+\\.[0-9]+\\.?(([0-9]+)?).*$" "\\1" + KOKKOS_VERSION_SUBMINOR "${KOKKOS_VERSION}") + if("${KOKKOS_VERSION_SUBMINOR}" STREQUAL "") + set(KOKKOS_VERSION_SUBMINOR "0") + endif() + + endif() diff --git a/include/deal.II/base/config.h.in b/include/deal.II/base/config.h.in index 865ccf190a..c4e53dacdd 100644 --- a/include/deal.II/base/config.h.in +++ b/include/deal.II/base/config.h.in @@ -429,6 +429,25 @@ DEAL_II_NAMESPACE_CLOSE # define DEAL_II_GMSH_EXECUTABLE_PATH "@GMSH_EXECUTABLE@" #endif + +/** + * Kokkos: + */ + +#ifdef DEAL_II_WITH_KOKKOS +# define DEAL_II_KOKKOS_VERSION_MAJOR @KOKKOS_VERSION_MAJOR@ +# define DEAL_II_KOKKOS_VERSION_MINOR @KOKKOS_VERSION_MINOR@ +# define DEAL_II_KOKKOS_VERSION_SUBMINOR @KOKKOS_VERSION_SUBMINOR@ + +# define DEAL_II_KOKKOS_VERSION_GTE(major,minor,subminor) \ + ((DEAL_II_KOKKOS_VERSION_MAJOR * 10000 + \ + DEAL_II_KOKKOS_VERSION_MINOR * 100 + \ + DEAL_II_KOKKOS_VERSION_SUBMINOR) \ + >= \ + (major)*10000 + (minor)*100 + (subminor)) +#endif + + /** * OpenCASCADE: */ -- 2.39.5