Skip to content

Commit

Permalink
Split math function test further, to work around compilation issue wi…
Browse files Browse the repository at this point in the history
…th MSVC/CUDA
  • Loading branch information
crtrott committed Feb 22, 2023
1 parent 43ec33e commit c74aa41
Show file tree
Hide file tree
Showing 5 changed files with 35 additions and 1 deletion.
3 changes: 3 additions & 0 deletions core/unit_test/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
8 changes: 7 additions & 1 deletion core/unit_test/TestMathematicalFunctions.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ struct math_function_name;
}; \
constexpr char math_function_name<MathUnaryFunction_##FUNC>::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 ...
Expand All @@ -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);

Expand Down Expand Up @@ -729,7 +731,9 @@ TEST(TEST_CATEGORY, mathematical_functions_fma) {
do_test_math_ternary_function<TEST_EXECSPACE, kk3_fma>(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});
Expand Down Expand Up @@ -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});
Expand Down
2 changes: 2 additions & 0 deletions core/unit_test/TestMathematicalFunctions1.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
2 changes: 2 additions & 0 deletions core/unit_test/TestMathematicalFunctions2.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
21 changes: 21 additions & 0 deletions core/unit_test/TestMathematicalFunctions3.hpp
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit c74aa41

Please sign in to comment.