From 1d19eeabbd3a0dd1bea4450e50ab8a117eaebedc Mon Sep 17 00:00:00 2001 From: Luc Berger-Vergiat Date: Thu, 9 Feb 2023 09:14:57 -0700 Subject: [PATCH 1/3] CMake: export version and subversion to config file The new logic exports CMake variables to KokkosKernels_config.h so that users can use them in their code more easily. It also allows us to print more cleanly version in print_config() --- CMakeLists.txt | 11 +++++++++-- cmake/KokkosKernels_config.h.in | 6 +++++- 2 files changed, 14 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 9d685e648e..d75a45499c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -27,7 +27,12 @@ IF(NOT KOKKOSKERNELS_HAS_TRILINOS) SET(KokkosKernels_VERSION_MINOR 0) SET(KokkosKernels_VERSION_PATCH 99) SET(KokkosKernels_VERSION "${KokkosKernels_VERSION_MAJOR}.${KokkosKernels_VERSION_MINOR}.${KokkosKernels_VERSION_PATCH}") + + #Set variables for config file MATH(EXPR KOKKOSKERNELS_VERSION "${KokkosKernels_VERSION_MAJOR} * 10000 + ${KokkosKernels_VERSION_MINOR} * 100 + ${KokkosKernels_VERSION_PATCH}") + MATH(EXPR KOKKOSKERNELS_VERSION_MAJOR "${KOKKOSKERNELS_VERSION} / 10000") + MATH(EXPR KOKKOSKERNELS_VERSION_MINOR "${KOKKOSKERNELS_VERSION} / 100 % 100") + MATH(EXPR KOKKOSKERNELS_VERSION_PATCH "${KOKKOSKERNELS_VERSION} % 100") ENDIF() INCLUDE(GNUInstallDirs) @@ -214,7 +219,9 @@ ELSE() # CMake Summary # ================================================================== MESSAGE("") - MESSAGE("=======================") + MESSAGE("================================") + MESSAGE("Kokkos Kernels version: ${KokkosKernels_VERSION_MAJOR}.${KokkosKernels_VERSION_MINOR}.${KokkosKernels_VERSION_PATCH}") + MESSAGE("================================") MESSAGE("Kokkos Kernels ETI Types") MESSAGE(" Devices: ${DEVICE_LIST}") MESSAGE(" Scalars: ${SCALAR_LIST}") @@ -238,7 +245,7 @@ ELSE() ELSE() MESSAGE(" (None)") ENDIF() - MESSAGE("=======================") + MESSAGE("================================") MESSAGE("") diff --git a/cmake/KokkosKernels_config.h.in b/cmake/KokkosKernels_config.h.in index 1fb6a31544..22a6cd9416 100644 --- a/cmake/KokkosKernels_config.h.in +++ b/cmake/KokkosKernels_config.h.in @@ -9,7 +9,11 @@ // clang-format on /* Define the current version of Kokkos Kernels */ -#cmakedefine KOKKOSKERNELS_VERSION @KOKKOSKERNELS_VERSION@ +#define KOKKOSKERNELS_VERSION @KOKKOSKERNELS_VERSION@ +#define KOKKOSKERNELS_VERSION_MAJOR @KOKKOSKERNELS_VERSION_MAJOR@ +#define KOKKOSKERNELS_VERSION_MINOR @KOKKOSKERNELS_VERSION_MINOR@ +#define KOKKOSKERNELS_VERSION_PATCH @KOKKOSKERNELS_VERSION_PATCH@ + /* Define if fortran blas 1 function can return complex type */ #cmakedefine KOKKOSKERNELS_TPL_BLAS_RETURN_COMPLEX From c284ef4ac111bffe8079eab22c43f02ed44a433c Mon Sep 17 00:00:00 2001 From: Luc Berger-Vergiat Date: Thu, 9 Feb 2023 11:00:25 -0700 Subject: [PATCH 2/3] Version: adding unit-test to verify that version info is available Small unit-test that asserts that the pre-processor macros to access the version number of Kokkos Kernels are available and that the values are consistent with each other. --- common/unit_test/Test_Common.hpp | 1 + common/unit_test/Test_Common_Version.hpp | 52 ++++++++++++++++++++++++ 2 files changed, 53 insertions(+) create mode 100644 common/unit_test/Test_Common_Version.hpp diff --git a/common/unit_test/Test_Common.hpp b/common/unit_test/Test_Common.hpp index 9cf686f513..dd368f009b 100644 --- a/common/unit_test/Test_Common.hpp +++ b/common/unit_test/Test_Common.hpp @@ -22,5 +22,6 @@ #include #include #include +#include #endif // TEST_COMMON_HPP diff --git a/common/unit_test/Test_Common_Version.hpp b/common/unit_test/Test_Common_Version.hpp new file mode 100644 index 0000000000..f09f1709d0 --- /dev/null +++ b/common/unit_test/Test_Common_Version.hpp @@ -0,0 +1,52 @@ +//@HEADER +// ************************************************************************ +// +// Kokkos v. 4.0 +// Copyright (2022) National Technology & Engineering +// Solutions of Sandia, LLC (NTESS). +// +// Under the terms of Contract DE-NA0003525 with NTESS, +// the U.S. Government retains certain rights in this software. +// +// Part of Kokkos, under the Apache License v2.0 with LLVM Exceptions. +// See https://kokkos.org/LICENSE for license information. +// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception +// +//@HEADER + +/// \file Test_Common_Version.hpp +/// \brief Tests that the version information that Kokkos Kernels +/// makes available in KokkosKernels_config.h is properly +/// accessible and correct. + +#ifndef TEST_COMMON_VERSION_HPP +#define TEST_COMMON_VERSION_HPP + +#include +#include + +void test_version_info() { +#ifndef KOKKOSKERNELS_VERSION + static_assert(false, "KOKKOSKERNELS_VERSION macro is not defined!"); +#endif + +#ifndef KOKKOSKERNELS_VERSION_MAJOR + static_assert(false, "KOKKOSKERNELS_VERSION_MAJOR macro is not defined!"); +#endif + +#ifndef KOKKOSKERNELS_VERSION_MINOR + static_assert(false, "KOKKOSKERNELS_VERSION_MINOR macro is not defined!"); +#endif + +#ifndef KOKKOSKERNELS_VERSION_PATCH + static_assert(false, "KOKKOSKERNELS_VERSION_PATCH macro is not defined!"); +#endif + + static_assert(KOKKOSKERNELS_VERSION == (KOKKOSKERNELS_VERSION_MAJOR*10000 + KOKKOSKERNELS_VERSION_MINOR*100 + KOKKOSKERNELS_VERSION_PATCH)); +} + +TEST_F(TestCategory, common_version) { + test_version_info(); +} + +#endif // TEST_COMMON_VERSION_HPP From c9e631b61f1d716653f9ad45b38c664922d72726 Mon Sep 17 00:00:00 2001 From: Luc Berger-Vergiat Date: Thu, 9 Feb 2023 11:12:40 -0700 Subject: [PATCH 3/3] Version: applying clang-format --- common/unit_test/Test_Common_Version.hpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/common/unit_test/Test_Common_Version.hpp b/common/unit_test/Test_Common_Version.hpp index f09f1709d0..cb5265cfef 100644 --- a/common/unit_test/Test_Common_Version.hpp +++ b/common/unit_test/Test_Common_Version.hpp @@ -42,11 +42,11 @@ void test_version_info() { static_assert(false, "KOKKOSKERNELS_VERSION_PATCH macro is not defined!"); #endif - static_assert(KOKKOSKERNELS_VERSION == (KOKKOSKERNELS_VERSION_MAJOR*10000 + KOKKOSKERNELS_VERSION_MINOR*100 + KOKKOSKERNELS_VERSION_PATCH)); + static_assert(KOKKOSKERNELS_VERSION == (KOKKOSKERNELS_VERSION_MAJOR * 10000 + + KOKKOSKERNELS_VERSION_MINOR * 100 + + KOKKOSKERNELS_VERSION_PATCH)); } -TEST_F(TestCategory, common_version) { - test_version_info(); -} +TEST_F(TestCategory, common_version) { test_version_info(); } -#endif // TEST_COMMON_VERSION_HPP +#endif // TEST_COMMON_VERSION_HPP