Skip to content

Commit

Permalink
Revert "[libc][math][c23] Add MPFR unit tests for {ceil,floor,round,r…
Browse files Browse the repository at this point in the history
…oundeven,trunc}f16 (#94383)" (#94505)

This reverts commit fda1e4b.

The commit caused Buildbot failures:
- https://lab.llvm.org/buildbot/#/builders/256/builds/14331
- https://lab.llvm.org/buildbot/#/builders/229/builds/27009
  • Loading branch information
overmighty authored Jun 5, 2024
1 parent 8407779 commit cbe97e9
Show file tree
Hide file tree
Showing 12 changed files with 53 additions and 264 deletions.
90 changes: 0 additions & 90 deletions libc/test/src/math/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,6 @@ add_fp_unittest(
TruncTest.h
DEPENDS
libc.src.math.trunc
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -156,7 +155,6 @@ add_fp_unittest(
TruncTest.h
DEPENDS
libc.src.math.truncf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -171,22 +169,6 @@ add_fp_unittest(
TruncTest.h
DEPENDS
libc.src.math.truncl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
truncf16_test
NEED_MPFR
SUITE
libc-math-unittests
SRCS
truncf16_test.cpp
HDRS
TruncTest.h
DEPENDS
libc.src.math.truncf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -201,7 +183,6 @@ add_fp_unittest(
CeilTest.h
DEPENDS
libc.src.math.ceil
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -216,7 +197,6 @@ add_fp_unittest(
CeilTest.h
DEPENDS
libc.src.math.ceilf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -231,22 +211,6 @@ add_fp_unittest(
CeilTest.h
DEPENDS
libc.src.math.ceill
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
ceilf16_test
NEED_MPFR
SUITE
libc-math-unittests
SRCS
ceilf16_test.cpp
HDRS
CeilTest.h
DEPENDS
libc.src.math.ceilf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -261,7 +225,6 @@ add_fp_unittest(
FloorTest.h
DEPENDS
libc.src.math.floor
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -276,7 +239,6 @@ add_fp_unittest(
FloorTest.h
DEPENDS
libc.src.math.floorf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -291,22 +253,6 @@ add_fp_unittest(
FloorTest.h
DEPENDS
libc.src.math.floorl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
floorf16_test
NEED_MPFR
SUITE
libc-math-unittests
SRCS
floorf16_test.cpp
HDRS
FloorTest.h
DEPENDS
libc.src.math.floorf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -321,7 +267,6 @@ add_fp_unittest(
RoundTest.h
DEPENDS
libc.src.math.round
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -336,7 +281,6 @@ add_fp_unittest(
RoundTest.h
DEPENDS
libc.src.math.roundf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -351,22 +295,6 @@ add_fp_unittest(
RoundTest.h
DEPENDS
libc.src.math.roundl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
roundf16_test
NEED_MPFR
SUITE
libc-math-unittests
SRCS
roundf16_test.cpp
HDRS
RoundTest.h
DEPENDS
libc.src.math.roundf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -381,7 +309,6 @@ add_fp_unittest(
RoundEvenTest.h
DEPENDS
libc.src.math.roundeven
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -396,7 +323,6 @@ add_fp_unittest(
RoundEvenTest.h
DEPENDS
libc.src.math.roundevenf
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand All @@ -411,22 +337,6 @@ add_fp_unittest(
RoundEvenTest.h
DEPENDS
libc.src.math.roundevenl
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

add_fp_unittest(
roundevenf16_test
NEED_MPFR
SUITE
libc-math-unittests
SRCS
roundevenf16_test.cpp
HDRS
RoundEvenTest.h
DEPENDS
libc.src.math.roundevenf16
libc.src.__support.CPP.algorithm
libc.src.__support.FPUtil.fp_bits
)

Expand Down
27 changes: 9 additions & 18 deletions libc/test/src/math/CeilTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,6 @@
//
//===----------------------------------------------------------------------===//

#ifndef LLVM_LIBC_TEST_SRC_MATH_CEILTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_CEILTEST_H

#include "src/__support/CPP/algorithm.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
Expand Down Expand Up @@ -63,21 +59,18 @@ class CeilTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_FP_EQ(T(-10.0), func(T(-10.32)));
EXPECT_FP_EQ(T(11.0), func(T(10.65)));
EXPECT_FP_EQ(T(-10.0), func(T(-10.65)));
EXPECT_FP_EQ(T(124.0), func(T(123.38)));
EXPECT_FP_EQ(T(-123.0), func(T(-123.38)));
EXPECT_FP_EQ(T(124.0), func(T(123.96)));
EXPECT_FP_EQ(T(-123.0), func(T(-123.96)));
EXPECT_FP_EQ(T(1235.0), func(T(1234.38)));
EXPECT_FP_EQ(T(-1234.0), func(T(-1234.38)));
EXPECT_FP_EQ(T(1235.0), func(T(1234.96)));
EXPECT_FP_EQ(T(-1234.0), func(T(-1234.96)));
}

void testRange(CeilFunc func) {
constexpr int COUNT = 100'000;
constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max(
static_cast<StorageType>(STORAGE_MAX / COUNT), StorageType(1));
StorageType v = 0;
for (int i = 0; i <= COUNT; ++i, v += STEP) {
FPBits xbits(v);
T x = xbits.get_val();
if (xbits.is_inf_or_nan())
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;

ASSERT_MPFR_MATCH(mpfr::Operation::Ceil, x, func(x), 0.0);
Expand All @@ -91,5 +84,3 @@ class CeilTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
TEST_F(LlvmLibcCeilTest, RoundedNubmers) { testRoundedNumbers(&func); } \
TEST_F(LlvmLibcCeilTest, Fractions) { testFractions(&func); } \
TEST_F(LlvmLibcCeilTest, Range) { testRange(&func); }

#endif // LLVM_LIBC_TEST_SRC_MATH_CEILTEST_H
22 changes: 9 additions & 13 deletions libc/test/src/math/FloorTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_FLOORTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_FLOORTEST_H

#include "src/__support/CPP/algorithm.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
Expand Down Expand Up @@ -63,21 +62,18 @@ class FloorTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_FP_EQ(T(-11.0), func(T(-10.32)));
EXPECT_FP_EQ(T(10.0), func(T(10.65)));
EXPECT_FP_EQ(T(-11.0), func(T(-10.65)));
EXPECT_FP_EQ(T(123.0), func(T(123.38)));
EXPECT_FP_EQ(T(-124.0), func(T(-123.38)));
EXPECT_FP_EQ(T(123.0), func(T(123.96)));
EXPECT_FP_EQ(T(-124.0), func(T(-123.96)));
EXPECT_FP_EQ(T(1234.0), func(T(1234.38)));
EXPECT_FP_EQ(T(-1235.0), func(T(-1234.38)));
EXPECT_FP_EQ(T(1234.0), func(T(1234.96)));
EXPECT_FP_EQ(T(-1235.0), func(T(-1234.96)));
}

void testRange(FloorFunc func) {
constexpr int COUNT = 100'000;
constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max(
static_cast<StorageType>(STORAGE_MAX / COUNT), StorageType(1));
StorageType v = 0;
for (int i = 0; i <= COUNT; ++i, v += STEP) {
FPBits xbits(v);
T x = xbits.get_val();
if (xbits.is_inf_or_nan())
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;

ASSERT_MPFR_MATCH(mpfr::Operation::Floor, x, func(x), 0.0);
Expand Down
30 changes: 13 additions & 17 deletions libc/test/src/math/RoundEvenTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_ROUNDEVENTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_ROUNDEVENTEST_H

#include "src/__support/CPP/algorithm.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
Expand Down Expand Up @@ -61,25 +60,22 @@ class RoundEvenTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_FP_EQ(T(-2.0), func(T(-1.75)));
EXPECT_FP_EQ(T(11.0), func(T(10.65)));
EXPECT_FP_EQ(T(-11.0), func(T(-10.65)));
EXPECT_FP_EQ(T(123.0), func(T(123.25)));
EXPECT_FP_EQ(T(124.0), func(T(123.50)));
EXPECT_FP_EQ(T(124.0), func(T(123.75)));
EXPECT_FP_EQ(T(-123.0), func(T(-123.25)));
EXPECT_FP_EQ(T(-124.0), func(T(-123.50)));
EXPECT_FP_EQ(T(-124.0), func(T(-123.75)));
EXPECT_FP_EQ(T(124.0), func(T(124.50)));
EXPECT_FP_EQ(T(-124.0), func(T(-124.50)));
EXPECT_FP_EQ(T(1233.0), func(T(1233.25)));
EXPECT_FP_EQ(T(1234.0), func(T(1233.50)));
EXPECT_FP_EQ(T(1234.0), func(T(1233.75)));
EXPECT_FP_EQ(T(-1233.0), func(T(-1233.25)));
EXPECT_FP_EQ(T(-1234.0), func(T(-1233.50)));
EXPECT_FP_EQ(T(-1234.0), func(T(-1233.75)));
EXPECT_FP_EQ(T(1234.0), func(T(1234.50)));
EXPECT_FP_EQ(T(-1234.0), func(T(-1234.50)));
}

void testRange(RoundEvenFunc func) {
constexpr int COUNT = 100'000;
constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max(
static_cast<StorageType>(STORAGE_MAX / COUNT), StorageType(1));
StorageType v = 0;
for (int i = 0; i <= COUNT; ++i, v += STEP) {
FPBits xbits(v);
T x = xbits.get_val();
if (xbits.is_inf_or_nan())
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;

ASSERT_MPFR_MATCH(mpfr::Operation::RoundEven, x, func(x), 0.0);
Expand Down
22 changes: 9 additions & 13 deletions libc/test/src/math/RoundTest.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
#ifndef LLVM_LIBC_TEST_SRC_MATH_ROUNDTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_ROUNDTEST_H

#include "src/__support/CPP/algorithm.h"
#include "test/UnitTest/FEnvSafeTest.h"
#include "test/UnitTest/FPMatcher.h"
#include "test/UnitTest/Test.h"
Expand Down Expand Up @@ -63,21 +62,18 @@ class RoundTest : public LIBC_NAMESPACE::testing::FEnvSafeTest {
EXPECT_FP_EQ(T(-10.0), func(T(-10.32)));
EXPECT_FP_EQ(T(11.0), func(T(10.65)));
EXPECT_FP_EQ(T(-11.0), func(T(-10.65)));
EXPECT_FP_EQ(T(123.0), func(T(123.38)));
EXPECT_FP_EQ(T(-123.0), func(T(-123.38)));
EXPECT_FP_EQ(T(124.0), func(T(123.96)));
EXPECT_FP_EQ(T(-124.0), func(T(-123.96)));
EXPECT_FP_EQ(T(1234.0), func(T(1234.38)));
EXPECT_FP_EQ(T(-1234.0), func(T(-1234.38)));
EXPECT_FP_EQ(T(1235.0), func(T(1234.96)));
EXPECT_FP_EQ(T(-1235.0), func(T(-1234.96)));
}

void testRange(RoundFunc func) {
constexpr int COUNT = 100'000;
constexpr StorageType STEP = LIBC_NAMESPACE::cpp::max(
static_cast<StorageType>(STORAGE_MAX / COUNT), StorageType(1));
StorageType v = 0;
for (int i = 0; i <= COUNT; ++i, v += STEP) {
FPBits xbits(v);
T x = xbits.get_val();
if (xbits.is_inf_or_nan())
constexpr StorageType COUNT = 100'000;
constexpr StorageType STEP = STORAGE_MAX / COUNT;
for (StorageType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
T x = FPBits(v).get_val();
if (isnan(x) || isinf(x))
continue;

ASSERT_MPFR_MATCH(mpfr::Operation::Round, x, func(x), 0.0);
Expand Down
Loading

0 comments on commit cbe97e9

Please sign in to comment.