Skip to content

Commit

Permalink
Merge pull request #5121 from janvrany/pr/add-nan-and-infinity-cases-…
Browse files Browse the repository at this point in the history
…to-fp-tests
  • Loading branch information
fjeremic authored May 13, 2020
2 parents 4eb7a6a + 816b3d7 commit 92e2fea
Show file tree
Hide file tree
Showing 8 changed files with 378 additions and 67 deletions.
93 changes: 34 additions & 59 deletions fvtest/compilertriltest/ArithmeticTest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,6 @@
#include "default_compiler.hpp"
#include "omrformatconsts.h"

#include <cmath>

#if defined(J9ZOS390) || defined(AIXPPC)
namespace std
{
using ::isnan;
}
#endif

template <typename T>
T add(T l, T r) {
return l + r;
Expand Down Expand Up @@ -713,6 +704,10 @@ class FloatArithmetic : public TRTest::BinaryOpTest<float> {};
TEST_P(FloatArithmetic, UsingConst) {
auto param = TRTest::to_struct(GetParam());

if ( std::isnan(param.lhs) || std::isnan(param.rhs) ) {
SKIP_ON_ZOS(KnownBug) << "TRIL parser cannot handle NaN values on zOS (see issue #5183)";
}

char inputTrees[1024] = {0};
std::snprintf(inputTrees, sizeof(inputTrees),
"(method return=Float"
Expand All @@ -736,11 +731,7 @@ TEST_P(FloatArithmetic, UsingConst) {
auto entry_point = compiler.getEntryPoint<float (*)(void)>();
volatile auto exp = param.oracle(param.lhs, param.rhs);
volatile auto act = entry_point();
if (std::isnan(exp)) {
ASSERT_EQ(std::isnan(exp), std::isnan(act));
} else {
ASSERT_EQ(exp, act);
}
ASSERT_EQ(exp, act);
}

TEST_P(FloatArithmetic, UsingLoadParam) {
Expand All @@ -767,16 +758,16 @@ TEST_P(FloatArithmetic, UsingLoadParam) {
auto entry_point = compiler.getEntryPoint<float (*)(float, float)>();
volatile auto exp = param.oracle(param.lhs, param.rhs);
volatile auto act = entry_point(param.lhs, param.rhs);
if (std::isnan(exp)) {
ASSERT_EQ(std::isnan(exp), std::isnan(act));
} else {
ASSERT_EQ(exp, act);
}
ASSERT_EQ(exp, act);
}

TEST_P(FloatArithmetic, UsingLoadParamAndLoadConst) {
auto param = TRTest::to_struct(GetParam());

if ( std::isnan(param.lhs) || std::isnan(param.rhs) ) {
SKIP_ON_ZOS(KnownBug) << "TRIL parser cannot handle NaN values on zOS (see issue #5183)";
}

char inputTrees[1024] = {0};
std::snprintf(inputTrees, sizeof(inputTrees),
"(method return=Float args=[Float]"
Expand All @@ -799,11 +790,7 @@ TEST_P(FloatArithmetic, UsingLoadParamAndLoadConst) {
auto entry_point = compiler.getEntryPoint<float (*)(float)>();
volatile auto exp = param.oracle(param.lhs, param.rhs);
volatile auto act = entry_point(param.lhs);
if (std::isnan(exp)) {
ASSERT_EQ(std::isnan(exp), std::isnan(act));
} else {
ASSERT_EQ(exp, act);
}
ASSERT_EQ(exp, act);
}

INSTANTIATE_TEST_CASE_P(ArithmeticTest, FloatArithmetic, ::testing::Combine(
Expand Down Expand Up @@ -1051,6 +1038,10 @@ class DoubleArithmetic : public TRTest::BinaryOpTest<double> {};
TEST_P(DoubleArithmetic, UsingConst) {
auto param = TRTest::to_struct(GetParam());

if ( std::isnan(param.lhs) || std::isnan(param.rhs) ) {
SKIP_ON_ZOS(KnownBug) << "TRIL parser cannot handle NaN values on zOS (see issue #5183)";
}

char inputTrees[1024] = {0};
std::snprintf(inputTrees, sizeof(inputTrees),
"(method return=Double"
Expand All @@ -1074,11 +1065,7 @@ TEST_P(DoubleArithmetic, UsingConst) {
auto entry_point = compiler.getEntryPoint<double (*)(void)>();
volatile auto exp = param.oracle(param.lhs, param.rhs);
volatile auto act = entry_point();
if (std::isnan(exp)) {
ASSERT_EQ(std::isnan(exp), std::isnan(act));
} else {
ASSERT_EQ(exp, act);
}
ASSERT_EQ(exp, act);
}

TEST_P(DoubleArithmetic, UsingLoadParam) {
Expand All @@ -1105,16 +1092,16 @@ TEST_P(DoubleArithmetic, UsingLoadParam) {
auto entry_point = compiler.getEntryPoint<double (*)(double, double)>();
volatile auto exp = param.oracle(param.lhs, param.rhs);
volatile auto act = entry_point(param.lhs, param.rhs);
if (std::isnan(exp)) {
ASSERT_EQ(std::isnan(exp), std::isnan(act));
} else {
ASSERT_EQ(exp, act);
}
ASSERT_EQ(exp, act);
}

TEST_P(DoubleArithmetic, UsingLoadParamAndLoadConst) {
auto param = TRTest::to_struct(GetParam());

if ( std::isnan(param.lhs) || std::isnan(param.rhs) ) {
SKIP_ON_ZOS(KnownBug) << "TRIL parser cannot handle NaN values on zOS (see issue #5183)";
}

char inputTrees[1024] = {0};
std::snprintf(inputTrees, sizeof(inputTrees),
"(method return=Double args=[Double]"
Expand All @@ -1137,11 +1124,7 @@ TEST_P(DoubleArithmetic, UsingLoadParamAndLoadConst) {
auto entry_point = compiler.getEntryPoint<double (*)(double)>();
volatile auto exp = param.oracle(param.lhs, param.rhs);
volatile auto act = entry_point(param.lhs);
if (std::isnan(exp)) {
ASSERT_EQ(std::isnan(exp), std::isnan(act));
} else {
ASSERT_EQ(exp, act);
}
ASSERT_EQ(exp, act);
}

INSTANTIATE_TEST_CASE_P(ArithmeticTest, DoubleArithmetic, ::testing::Combine(
Expand Down Expand Up @@ -1170,6 +1153,10 @@ class FloatUnaryArithmetic : public TRTest::UnaryOpTest<float> {};
TEST_P(FloatUnaryArithmetic, UsingConst) {
auto param = TRTest::to_struct(GetParam());

if ( std::isnan(param.value) ) {
SKIP_ON_ZOS(KnownBug) << "TRIL parser cannot handle NaN values on zOS (see issue #5183)";
}

char inputTrees[1024] = {0};
std::snprintf(inputTrees, sizeof(inputTrees),
"(method return=Float"
Expand All @@ -1191,11 +1178,7 @@ TEST_P(FloatUnaryArithmetic, UsingConst) {
auto entry_point = compiler.getEntryPoint<float (*)(void)>();
volatile auto exp = param.oracle(param.value);
volatile auto act = entry_point();
if (std::isnan(exp)) {
ASSERT_EQ(std::isnan(exp), std::isnan(act));
} else {
ASSERT_EQ(exp, act);
}
ASSERT_EQ(exp, act);
}

TEST_P(FloatUnaryArithmetic, UsingLoadParam) {
Expand All @@ -1221,11 +1204,7 @@ TEST_P(FloatUnaryArithmetic, UsingLoadParam) {
auto entry_point = compiler.getEntryPoint<float (*)(float)>();
volatile auto exp = param.oracle(param.value);
volatile auto act = entry_point(param.value);
if (std::isnan(exp)) {
ASSERT_EQ(std::isnan(exp), std::isnan(act));
} else {
ASSERT_EQ(exp, act);
}
ASSERT_EQ(exp, act);
}

INSTANTIATE_TEST_CASE_P(ArithmeticTest, FloatUnaryArithmetic, ::testing::Combine(
Expand All @@ -1245,6 +1224,10 @@ class DoubleUnaryArithmetic : public TRTest::UnaryOpTest<double> {};
TEST_P(DoubleUnaryArithmetic, UsingConst) {
auto param = TRTest::to_struct(GetParam());

if ( std::isnan(param.value) ) {
SKIP_ON_ZOS(KnownBug) << "TRIL parser cannot handle NaN values on zOS (see issue #5183)";
}

char inputTrees[1024] = {0};
std::snprintf(inputTrees, sizeof(inputTrees),
"(method return=Double"
Expand All @@ -1266,11 +1249,7 @@ TEST_P(DoubleUnaryArithmetic, UsingConst) {
auto entry_point = compiler.getEntryPoint<double (*)(void)>();
volatile auto exp = param.oracle(param.value);
volatile auto act = entry_point();
if (std::isnan(exp)) {
ASSERT_EQ(std::isnan(exp), std::isnan(act));
} else {
ASSERT_EQ(exp, act);
}
ASSERT_EQ(exp, act);
}

TEST_P(DoubleUnaryArithmetic, UsingLoadParam) {
Expand All @@ -1296,11 +1275,7 @@ TEST_P(DoubleUnaryArithmetic, UsingLoadParam) {
auto entry_point = compiler.getEntryPoint<double (*)(double)>();
volatile auto exp = param.oracle(param.value);
volatile auto act = entry_point(param.value);
if (std::isnan(exp)) {
ASSERT_EQ(std::isnan(exp), std::isnan(act));
} else {
ASSERT_EQ(exp, act);
}
ASSERT_EQ(exp, act);
}

INSTANTIATE_TEST_CASE_P(ArithmeticTest, DoubleUnaryArithmetic, ::testing::Combine(
Expand Down
1 change: 1 addition & 0 deletions fvtest/compilertriltest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ set(CMAKE_CXX_EXTENSIONS OFF)

omr_add_executable(comptest
main.cpp
JitTest.cpp
JitTestUtilitiesTest.cpp
ILValidatorTest.cpp
ArithmeticTest.cpp
Expand Down
Loading

0 comments on commit 92e2fea

Please sign in to comment.