From e187fdf53af5f936363de1ee8bc2412fc15754e2 Mon Sep 17 00:00:00 2001 From: Brian Kelley Date: Tue, 19 Sep 2023 15:28:25 -0600 Subject: [PATCH] Fix #1972 Fix some uses of execution_space in ODE test that I missed in #1969. Also, for as long as the Kokkos_ENABLE_CUDA_UVM option exists, check that KokkosKernels is actually instantiating for CudaUVMSpace (without this, tests will hit linker errors) --- ode/unit_test/Test_ODE_Newton.hpp | 23 ++++++++++------------- test_common/Test_Cuda.hpp | 13 ++++++++++++- 2 files changed, 22 insertions(+), 14 deletions(-) diff --git a/ode/unit_test/Test_ODE_Newton.hpp b/ode/unit_test/Test_ODE_Newton.hpp index f6b63ee562..d235df1e56 100644 --- a/ode/unit_test/Test_ODE_Newton.hpp +++ b/ode/unit_test/Test_ODE_Newton.hpp @@ -158,10 +158,10 @@ struct QuadraticEquation { // f(x) = cos(x) - x = 0 // Solution: 0.739085 // f'(x) = -sin(x) - 1 -template +template struct TrigonometricEquation { - using vec_type = Kokkos::View; - using mat_type = Kokkos::View; + using vec_type = Kokkos::View; + using mat_type = Kokkos::View; static constexpr int neqs = 1; @@ -180,10 +180,10 @@ struct TrigonometricEquation { // f(x) = 7x - log(7x) - 1 = 0 // Solution: 1/7 = 0.14285714285 // f'(x) = 7 - (1 / x) -template +template struct LogarithmicEquation { - using vec_type = Kokkos::View; - using mat_type = Kokkos::View; + using vec_type = Kokkos::View; + using mat_type = Kokkos::View; static constexpr int neqs = 1; @@ -216,8 +216,7 @@ void test_newton_status() { throw std::runtime_error("scalar_type is neither float, nor double!"); } KokkosODE::Experimental::Newton_params params(50, abs_tol, rel_tol); - Kokkos::View status( - "newton solver status", 1); + Kokkos::View status("newton solver status", 1); auto status_h = Kokkos::create_mirror_view(status); // Create the non-linear system and initialize data @@ -262,7 +261,6 @@ void test_newton_status() { template void test_simple_problems() { - using execution_space = typename Device::execution_space; double abs_tol, rel_tol; if (std::is_same_v) { rel_tol = 10e-5; @@ -299,7 +297,7 @@ void test_simple_problems() { #ifdef HAVE_KOKKOSKERNELS_DEBUG std::cout << "\nStarting Trigonometric Equation problem" << std::endl; #endif - using system_type = TrigonometricEquation; + using system_type = TrigonometricEquation; system_type mySys{}; scalar_type initial_value[1] = {0.1}, solution[1] = {0.739085}; run_newton_test(mySys, params, @@ -314,7 +312,7 @@ void test_simple_problems() { #ifdef HAVE_KOKKOSKERNELS_DEBUG std::cout << "\nStarting Logarithmic Equation problem" << std::endl; #endif - using system_type = LogarithmicEquation; + using system_type = LogarithmicEquation; system_type mySys{}; scalar_type initial_value[1] = {static_cast(0.5)}, solution[1] = {static_cast(1.0) / @@ -400,7 +398,6 @@ struct CircleHyperbolaIntersection { template void test_simple_systems() { - using execution_space = typename Device::execution_space; double abs_tol, rel_tol; if (std::is_same_v) { rel_tol = 10e-5; @@ -418,7 +415,7 @@ void test_simple_systems() { #ifdef HAVE_KOKKOSKERNELS_DEBUG std::cout << "\nStarting Circles Intersetcion problem" << std::endl; #endif - using system_type = CirclesIntersections; + using system_type = CirclesIntersections; system_type mySys{}; scalar_type initial_values[2] = {1.5, 1.5}; scalar_type solution[2] = {10.75 / 6, 0.8887803753}; diff --git a/test_common/Test_Cuda.hpp b/test_common/Test_Cuda.hpp index 01eb78dfef..cf1042a2c4 100644 --- a/test_common/Test_Cuda.hpp +++ b/test_common/Test_Cuda.hpp @@ -36,8 +36,19 @@ class Cuda : public ::testing::Test { using CudaSpaceDevice = Kokkos::Device; using CudaUVMSpaceDevice = Kokkos::Device; +#ifdef KOKKOS_ENABLE_CUDA_UVM +// KOKKOS_ENABLE_CUDA_UVM macro and cmake option is deprecated +// But if it is defined, test with CudaUVMSpace. +// Make sure it's instantiated first: +#if defined(KOKKOSKERNELS_TEST_ETI_ONLY) && \ + !defined(KOKKOSKERNELS_INST_MEMSPACE_CUDAUVMSPACE) +#error \ + "Deprecated option KOKKOS_ENABLE_CUDA_UVM is defined, so KokkosKernels will test with CudaUVMSpace. " \ + "KokkosKernels_INST_MEMSPACE_CUDAUVMSPACE=ON must be set in configuration." +#endif +#define TestDevice CudaUVMSpaceDevice // Prefer for any testing where only one exec space is used -#if defined(KOKKOSKERNELS_INST_MEMSPACE_CUDAUVMSPACE) && \ +#elif defined(KOKKOSKERNELS_INST_MEMSPACE_CUDAUVMSPACE) && \ !defined(KOKKOSKERNELS_INST_MEMSPACE_CUDASPACE) #define TestDevice CudaUVMSpaceDevice #else