Update Kokkos library in LAMMPS to v3.6.0
This commit is contained in:
@ -59,6 +59,12 @@
|
||||
#define MATHEMATICAL_FUNCTIONS_HAVE_LONG_DOUBLE_OVERLOADS
|
||||
#endif
|
||||
|
||||
// WORKAROUND icpx changing default FP model when optimization level is >= 1
|
||||
// using -fp-model=precise works too
|
||||
#if defined(__INTEL_LLVM_COMPILER)
|
||||
#define KOKKOS_IMPL_WORKAROUND_INTEL_LLVM_DEFAULT_FLOATING_POINT_MODEL
|
||||
#endif
|
||||
|
||||
// clang-format off
|
||||
template <class>
|
||||
struct math_unary_function_return_type;
|
||||
@ -342,7 +348,13 @@ DEFINE_UNARY_FUNCTION_EVAL(asinh, 4);
|
||||
DEFINE_UNARY_FUNCTION_EVAL(acosh, 2);
|
||||
DEFINE_UNARY_FUNCTION_EVAL(atanh, 2);
|
||||
|
||||
#if defined(__APPLE__)
|
||||
// Apple's standard library implementation seems to have a poor implementation
|
||||
DEFINE_UNARY_FUNCTION_EVAL(erf, 5);
|
||||
#else
|
||||
DEFINE_UNARY_FUNCTION_EVAL(erf, 2);
|
||||
#endif
|
||||
|
||||
DEFINE_UNARY_FUNCTION_EVAL(erfc, 5);
|
||||
// has a larger error due to some impls doing integer exact.
|
||||
// We cast always to double leading to larger difference when comparing our
|
||||
@ -415,8 +427,6 @@ struct TestMathUnaryFunction : FloatingPointComparison {
|
||||
Arg val_[N];
|
||||
Ret res_[N];
|
||||
TestMathUnaryFunction(const Arg (&val)[N]) {
|
||||
std::cout << math_function_name<Func>::name << "("
|
||||
<< type_helper<Arg>::name() << ")\n";
|
||||
std::copy(val, val + N, val_);
|
||||
std::transform(val, val + N, res_,
|
||||
[](auto x) { return Func::eval_std(x); });
|
||||
@ -425,7 +435,9 @@ struct TestMathUnaryFunction : FloatingPointComparison {
|
||||
void run() {
|
||||
int errors = 0;
|
||||
Kokkos::parallel_reduce(Kokkos::RangePolicy<Space>(0, N), *this, errors);
|
||||
ASSERT_EQ(errors, 0);
|
||||
ASSERT_EQ(errors, 0) << "Failed check no error for "
|
||||
<< math_function_name<Func>::name << "("
|
||||
<< type_helper<Arg>::name() << ")";
|
||||
}
|
||||
KOKKOS_FUNCTION void operator()(int i, int& e) const {
|
||||
bool ar = compare(Func::eval(val_[i]), res_[i], Func::ulp_factor());
|
||||
@ -456,15 +468,15 @@ struct TestMathBinaryFunction : FloatingPointComparison {
|
||||
Ret res_;
|
||||
TestMathBinaryFunction(Arg1 val1, Arg2 val2)
|
||||
: val1_(val1), val2_(val2), res_(Func::eval_std(val1, val2)) {
|
||||
std::cout << math_function_name<Func>::name << "("
|
||||
<< type_helper<Arg1>::name() << ", " << type_helper<Arg2>::name()
|
||||
<< ")\n";
|
||||
run();
|
||||
}
|
||||
void run() {
|
||||
int errors = 0;
|
||||
Kokkos::parallel_reduce(Kokkos::RangePolicy<Space>(0, 1), *this, errors);
|
||||
ASSERT_EQ(errors, 0);
|
||||
ASSERT_EQ(errors, 0) << "Failed check no error for "
|
||||
<< math_function_name<Func>::name << "("
|
||||
<< type_helper<Arg1>::name() << ", "
|
||||
<< type_helper<Arg2>::name() << ")";
|
||||
}
|
||||
KOKKOS_FUNCTION void operator()(int, int& e) const {
|
||||
bool ar = compare(Func::eval(val1_, val2_), res_, Func::ulp_factor());
|
||||
@ -917,9 +929,7 @@ struct TestAbsoluteValueFunction {
|
||||
using Kokkos::Experimental::isinf;
|
||||
using Kokkos::Experimental::isnan;
|
||||
if (abs(-0.) != 0.
|
||||
// WORKAROUND icpx changing default FP model when optimization level is >= 1
|
||||
// using -fp-model=precise works too
|
||||
#ifndef __INTEL_LLVM_COMPILER
|
||||
#ifndef KOKKOS_IMPL_WORKAROUND_INTEL_LLVM_DEFAULT_FLOATING_POINT_MODEL
|
||||
|| !isinf(abs(-INFINITY)) || !isnan(abs(-NAN))
|
||||
#endif
|
||||
) {
|
||||
@ -942,3 +952,73 @@ struct TestAbsoluteValueFunction {
|
||||
TEST(TEST_CATEGORY, mathematical_functions_absolute_value) {
|
||||
TestAbsoluteValueFunction<TEST_EXECSPACE>();
|
||||
}
|
||||
|
||||
template <class Space>
|
||||
struct TestIsNaN {
|
||||
TestIsNaN() { run(); }
|
||||
void run() const {
|
||||
int errors = 0;
|
||||
Kokkos::parallel_reduce(Kokkos::RangePolicy<Space>(0, 1), *this, errors);
|
||||
ASSERT_EQ(errors, 0);
|
||||
}
|
||||
KOKKOS_FUNCTION void operator()(int, int& e) const {
|
||||
using Kokkos::Experimental::isnan;
|
||||
using Kokkos::Experimental::quiet_NaN;
|
||||
using Kokkos::Experimental::signaling_NaN;
|
||||
if (isnan(1) || isnan(INT_MAX)) {
|
||||
++e;
|
||||
KOKKOS_IMPL_DO_NOT_USE_PRINTF("failed isnan(integral)\n");
|
||||
}
|
||||
if (isnan(2.f)
|
||||
#ifndef KOKKOS_IMPL_WORKAROUND_INTEL_LLVM_DEFAULT_FLOATING_POINT_MODEL
|
||||
|| !isnan(quiet_NaN<float>::value) ||
|
||||
!isnan(signaling_NaN<float>::value)
|
||||
#endif
|
||||
|
||||
) {
|
||||
++e;
|
||||
KOKKOS_IMPL_DO_NOT_USE_PRINTF("failed isnan(float)\n");
|
||||
}
|
||||
if (isnan(3.)
|
||||
#ifndef KOKKOS_IMPL_WORKAROUND_INTEL_LLVM_DEFAULT_FLOATING_POINT_MODEL
|
||||
|| !isnan(quiet_NaN<double>::value) ||
|
||||
!isnan(signaling_NaN<double>::value)
|
||||
#endif
|
||||
) {
|
||||
++e;
|
||||
KOKKOS_IMPL_DO_NOT_USE_PRINTF("failed isnan(double)\n");
|
||||
}
|
||||
#ifdef MATHEMATICAL_FUNCTIONS_HAVE_LONG_DOUBLE_OVERLOADS
|
||||
if (isnan(4.l)
|
||||
#ifndef KOKKOS_IMPL_WORKAROUND_INTEL_LLVM_DEFAULT_FLOATING_POINT_MODEL
|
||||
|| !isnan(quiet_NaN<long double>::value) ||
|
||||
!isnan(signaling_NaN<long double>::value)
|
||||
#endif
|
||||
) {
|
||||
++e;
|
||||
KOKKOS_IMPL_DO_NOT_USE_PRINTF("failed isnan(long double)\n");
|
||||
}
|
||||
#endif
|
||||
// special values
|
||||
if (isnan(INFINITY)
|
||||
#ifndef KOKKOS_IMPL_WORKAROUND_INTEL_LLVM_DEFAULT_FLOATING_POINT_MODEL
|
||||
|| !isnan(NAN)
|
||||
#endif
|
||||
) {
|
||||
++e;
|
||||
KOKKOS_IMPL_DO_NOT_USE_PRINTF(
|
||||
"failed isnan(floating_point) special values\n");
|
||||
}
|
||||
|
||||
static_assert(std::is_same<decltype(isnan(1)), bool>::value, "");
|
||||
static_assert(std::is_same<decltype(isnan(2.f)), bool>::value, "");
|
||||
static_assert(std::is_same<decltype(isnan(3.)), bool>::value, "");
|
||||
#ifdef MATHEMATICAL_FUNCTIONS_HAVE_LONG_DOUBLE_OVERLOADS
|
||||
static_assert(std::is_same<decltype(isnan(4.l)), bool>::value, "");
|
||||
#endif
|
||||
}
|
||||
};
|
||||
|
||||
TEST(TEST_CATEGORY, mathematical_functions_isnan) {
|
||||
TestIsNaN<TEST_EXECSPACE>();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user