Skip to content

Commit

Permalink
Fix builtin_unreachable use for MSVC/CUDA
Browse files Browse the repository at this point in the history
Also split math functions test differently to avoid need for bigobj
  • Loading branch information
crtrott committed Dec 9, 2023
1 parent 843fca3 commit fb0380b
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 7 deletions.
2 changes: 1 addition & 1 deletion algorithms/unit_tests/TestStdAlgorithmsCommon.hpp
Expand Up @@ -199,7 +199,7 @@ auto create_deep_copyable_compatible_view_with_same_extent(ViewType view) {
// this is needed for intel to avoid
// error #1011: missing return statement at end of non-void function
#if defined KOKKOS_COMPILER_INTEL || \
(defined(KOKKOS_COMPILER_NVCC) && KOKKOS_COMPILER_NVCC >= 1130)
(defined(KOKKOS_COMPILER_NVCC) && KOKKOS_COMPILER_NVCC >= 1130 && !defined(KOKKOS_COMPILER_MSVC))
__builtin_unreachable();
#endif
}
Expand Down
22 changes: 16 additions & 6 deletions core/unit_test/TestMathematicalFunctions.hpp
Expand Up @@ -31,7 +31,7 @@
#endif

#if defined KOKKOS_COMPILER_INTEL || \
(defined(KOKKOS_COMPILER_NVCC) && KOKKOS_COMPILER_NVCC >= 1130)
(defined(KOKKOS_COMPILER_NVCC) && KOKKOS_COMPILER_NVCC >= 1130 && !defined(KOKKOS_COMPILER_MSVC))
#define MATHEMATICAL_FUNCTIONS_TEST_UNREACHABLE __builtin_unreachable();
#else
#define MATHEMATICAL_FUNCTIONS_TEST_UNREACHABLE
Expand Down Expand Up @@ -394,10 +394,12 @@ DEFINE_UNARY_FUNCTION_EVAL(log2, 2);
DEFINE_UNARY_FUNCTION_EVAL(log1p, 2);
#endif

#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1
#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2
DEFINE_UNARY_FUNCTION_EVAL(sqrt, 2);
DEFINE_UNARY_FUNCTION_EVAL(cbrt, 2);
#endif

#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1
DEFINE_UNARY_FUNCTION_EVAL(sin, 2);
DEFINE_UNARY_FUNCTION_EVAL(cos, 2);
DEFINE_UNARY_FUNCTION_EVAL(tan, 2);
Expand Down Expand Up @@ -483,11 +485,9 @@ DEFINE_UNARY_FUNCTION_EVAL(logb, 2);
}; \
constexpr char math_function_name<MathBinaryFunction_##FUNC>::name[]

#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1
#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2
DEFINE_BINARY_FUNCTION_EVAL(pow, 2);
DEFINE_BINARY_FUNCTION_EVAL(hypot, 2);
#endif
#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2
DEFINE_BINARY_FUNCTION_EVAL(nextafter, 1);
DEFINE_BINARY_FUNCTION_EVAL(copysign, 1);
#endif
Expand Down Expand Up @@ -519,7 +519,7 @@ DEFINE_BINARY_FUNCTION_EVAL(copysign, 1);
}; \
constexpr char math_function_name<MathTernaryFunction_##FUNC>::name[]

#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_1
#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2
DEFINE_TERNARY_FUNCTION_EVAL(hypot, 2);
DEFINE_TERNARY_FUNCTION_EVAL(fma, 2);
#endif
Expand Down Expand Up @@ -787,7 +787,9 @@ TEST(TEST_CATEGORY, mathematical_functions_trigonometric_functions) {

// TODO atan2
}
#endif

#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2
TEST(TEST_CATEGORY, mathematical_functions_power_functions) {
TEST_MATH_FUNCTION(sqrt)({0, 1, 2, 3, 5, 7, 11});
TEST_MATH_FUNCTION(sqrt)({0l, 1l, 2l, 3l, 5l, 7l, 11l});
Expand Down Expand Up @@ -1558,6 +1560,7 @@ TEST(TEST_CATEGORY, mathematical_functions_ieee_remainder_function) {

// TODO: TestFpClassify, see https://github.com/kokkos/kokkos/issues/6279

#ifndef KOKKOS_MATHEMATICAL_FUNCTIONS_SKIP_2
template <class Space>
struct TestIsFinite {
TestIsFinite() { run(); }
Expand All @@ -1581,6 +1584,7 @@ struct TestIsFinite {
++e;
Kokkos::printf("failed isfinite(float)\n");
}
#if !(defined(KOKKOS_ENABLE_CUDA) && defined(KOKKOS_COMPILER_MSVC))
if (!isfinite(static_cast<KE::half_t>(2.f))
#ifndef KOKKOS_COMPILER_NVHPC // FIXME_NVHPC 23.7
|| isfinite(quiet_NaN<KE::half_t>::value) ||
Expand All @@ -1601,6 +1605,7 @@ struct TestIsFinite {
++e;
Kokkos::printf("failed isfinite(KE::bhalf_t)\n");
}
#endif
if (!isfinite(3.)
#ifndef KOKKOS_COMPILER_NVHPC // FIXME_NVHPC 23.7
|| isfinite(quiet_NaN<double>::value) ||
Expand Down Expand Up @@ -1660,6 +1665,7 @@ struct TestIsInf {
++e;
Kokkos::printf("failed isinf(float)\n");
}
#if !(defined(KOKKOS_ENABLE_CUDA) && defined(KOKKOS_COMPILER_MSVC))
if (isinf(static_cast<KE::half_t>(2.f))
#ifndef KOKKOS_COMPILER_NVHPC // FIXME_NVHPC 23.7
|| isinf(quiet_NaN<KE::half_t>::value) ||
Expand All @@ -1680,6 +1686,7 @@ struct TestIsInf {
++e;
Kokkos::printf("failed isinf(KE::bhalf_t)\n");
}
#endif
if (isinf(3.)
#ifndef KOKKOS_COMPILER_NVHPC // FIXME_NVHPC 23.7
|| isinf(quiet_NaN<double>::value) ||
Expand Down Expand Up @@ -1738,6 +1745,7 @@ struct TestIsNaN {
++e;
Kokkos::printf("failed isnan(float)\n");
}
#if !(defined(KOKKOS_ENABLE_CUDA) && defined(KOKKOS_COMPILER_MSVC))
if (isnan(static_cast<KE::half_t>(2.f))
#ifndef KOKKOS_COMPILER_NVHPC // FIXME_NVHPC 23.7
|| !isnan(quiet_NaN<KE::half_t>::value) ||
Expand Down Expand Up @@ -1767,6 +1775,7 @@ struct TestIsNaN {
++e;
Kokkos::printf("failed isnan(double)\n");
}
#endif
#ifdef MATHEMATICAL_FUNCTIONS_HAVE_LONG_DOUBLE_OVERLOADS
if (isnan(4.l) || !isnan(quiet_NaN<long double>::value) ||
!isnan(signaling_NaN<long double>::value) ||
Expand All @@ -1793,6 +1802,7 @@ struct TestIsNaN {
TEST(TEST_CATEGORY, mathematical_functions_isnan) {
TestIsNaN<TEST_EXECSPACE>();
}
#endif

// TODO: TestSignBit, see https://github.com/kokkos/kokkos/issues/6279
#endif

0 comments on commit fb0380b

Please sign in to comment.