From c74aa417d2da22c4a9a0ffdd60715e3baf22157d Mon Sep 17 00:00:00 2001 From: Christian Trott Date: Wed, 22 Feb 2023 09:31:15 -0700 Subject: [PATCH] Split math function test further, to work around compilation issue with MSVC/CUDA --- core/unit_test/CMakeLists.txt | 3 +++ core/unit_test/TestMathematicalFunctions.hpp | 8 ++++++- core/unit_test/TestMathematicalFunctions1.hpp | 2 ++ core/unit_test/TestMathematicalFunctions2.hpp | 2 ++ core/unit_test/TestMathematicalFunctions3.hpp | 21 +++++++++++++++++++ 5 files changed, 35 insertions(+), 1 deletion(-) create mode 100644 core/unit_test/TestMathematicalFunctions3.hpp diff --git a/core/unit_test/CMakeLists.txt b/core/unit_test/CMakeLists.txt index 588fb219f8..dc374711e6 100644 --- a/core/unit_test/CMakeLists.txt +++ b/core/unit_test/CMakeLists.txt @@ -140,6 +140,7 @@ foreach(Tag Threads;Serial;OpenMP;Cuda;HPX;OpenMPTarget;OpenACC;HIP;SYCL) MathematicalConstants MathematicalFunctions1 MathematicalFunctions2 + MathematicalFunctions3 MDRange_a MDRange_b MDRange_c @@ -524,6 +525,7 @@ IF(KOKKOS_ENABLE_OPENACC AND KOKKOS_CXX_COMPILER_ID STREQUAL NVHPC) ${CMAKE_CURRENT_BINARY_DIR}/openacc/TestOpenACC_MathematicalFunctions.cpp ${CMAKE_CURRENT_BINARY_DIR}/openacc/TestOpenACC_MathematicalFunctions1.cpp ${CMAKE_CURRENT_BINARY_DIR}/openacc/TestOpenACC_MathematicalFunctions2.cpp + ${CMAKE_CURRENT_BINARY_DIR}/openacc/TestOpenACC_MathematicalFunctions3.cpp ${CMAKE_CURRENT_BINARY_DIR}/openacc/TestOpenACC_SubView_a.cpp ${CMAKE_CURRENT_BINARY_DIR}/openacc/TestOpenACC_SubView_b.cpp ${CMAKE_CURRENT_BINARY_DIR}/openacc/TestOpenACC_SubView_c01.cpp @@ -1125,6 +1127,7 @@ KOKKOS_ADD_EXECUTABLE_AND_TEST( # This test is not properly set up to run within Trilinos if (NOT KOKKOS_HAS_TRILINOS) + SET_SOURCE_FILES_PROPERTIES(UnitTest_DeviceAndThreads.cpp PROPERTIES LANGUAGE ${KOKKOS_COMPILE_LANGUAGE}) add_executable(KokkosCore_UnitTest_DeviceAndThreads UnitTest_DeviceAndThreads.cpp) target_link_libraries(KokkosCore_UnitTest_DeviceAndThreads Kokkos::kokkoscore) find_package(Python3 COMPONENTS Interpreter) diff --git a/core/unit_test/TestMathematicalFunctions.hpp b/core/unit_test/TestMathematicalFunctions.hpp index dfcd2340a2..fe7074d5a1 100644 --- a/core/unit_test/TestMathematicalFunctions.hpp +++ b/core/unit_test/TestMathematicalFunctions.hpp @@ -311,7 +311,7 @@ struct math_function_name; }; \ constexpr char math_function_name::name[] -#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1 +#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_3 // Generally the expected ULP error should come from here: // https://www.gnu.org/software/libc/manual/html_node/Errors-in-Math-Functions.html // For now 1s largely seem to work ... @@ -327,7 +327,9 @@ DEFINE_UNARY_FUNCTION_EVAL(log, 2); DEFINE_UNARY_FUNCTION_EVAL(log10, 2); DEFINE_UNARY_FUNCTION_EVAL(log2, 2); DEFINE_UNARY_FUNCTION_EVAL(log1p, 2); +#endif +#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1 DEFINE_UNARY_FUNCTION_EVAL(sqrt, 2); DEFINE_UNARY_FUNCTION_EVAL(cbrt, 2); @@ -729,7 +731,9 @@ TEST(TEST_CATEGORY, mathematical_functions_fma) { do_test_math_ternary_function(2.l, 3.l, 4.l); #endif } +#endif +#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_3 TEST(TEST_CATEGORY, mathematical_functions_exponential_functions) { TEST_MATH_FUNCTION(exp)({-9, -8, -7, -6, -5, 4, 3, 2, 1, 0}); TEST_MATH_FUNCTION(exp)({-9l, -8l, -7l, -6l, -5l, 4l, 3l, 2l, 1l, 0l}); @@ -821,7 +825,9 @@ TEST(TEST_CATEGORY, mathematical_functions_exponential_functions) { TEST_MATH_FUNCTION(log1p)({1234.l, 567.l, 89.l, -.007l}); #endif } +#endif +#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1 TEST(TEST_CATEGORY, mathematical_functions_hyperbolic_functions) { TEST_MATH_FUNCTION(sinh)({-3, -2, -1, 0, 1}); TEST_MATH_FUNCTION(sinh)({-3l, -2l, -1l, 0l, 1l}); diff --git a/core/unit_test/TestMathematicalFunctions1.hpp b/core/unit_test/TestMathematicalFunctions1.hpp index d902a04422..7452d45e42 100644 --- a/core/unit_test/TestMathematicalFunctions1.hpp +++ b/core/unit_test/TestMathematicalFunctions1.hpp @@ -15,5 +15,7 @@ //@HEADER #define KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2 +#define KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_3 #include "TestMathematicalFunctions.hpp" #undef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2 +#undef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_3 diff --git a/core/unit_test/TestMathematicalFunctions2.hpp b/core/unit_test/TestMathematicalFunctions2.hpp index 58572ebe6f..72f792b089 100644 --- a/core/unit_test/TestMathematicalFunctions2.hpp +++ b/core/unit_test/TestMathematicalFunctions2.hpp @@ -15,5 +15,7 @@ //@HEADER #define KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1 +#define KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_3 #include "TestMathematicalFunctions.hpp" #undef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1 +#undef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_3 diff --git a/core/unit_test/TestMathematicalFunctions3.hpp b/core/unit_test/TestMathematicalFunctions3.hpp new file mode 100644 index 0000000000..3d7b356367 --- /dev/null +++ b/core/unit_test/TestMathematicalFunctions3.hpp @@ -0,0 +1,21 @@ +//@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 + +#define KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1 +#define KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2 +#include "TestMathematicalFunctions.hpp" +#undef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1 +#undef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2