[libc-commits] [libc] 2697ffd - [libc] Reduce math tests runtime further

Guillaume Chatelet via libc-commits libc-commits at lists.llvm.org
Thu Jun 1 05:43:26 PDT 2023


Author: Guillaume Chatelet
Date: 2023-06-01T12:43:18Z
New Revision: 2697ffd039559ec83469165c70f8fd9a484a5a54

URL: https://github.com/llvm/llvm-project/commit/2697ffd039559ec83469165c70f8fd9a484a5a54
DIFF: https://github.com/llvm/llvm-project/commit/2697ffd039559ec83469165c70f8fd9a484a5a54.diff

LOG: [libc] Reduce math tests runtime further

Reviewed By: lntue

Differential Revision: https://reviews.llvm.org/D151875

Added: 
    

Modified: 
    libc/test/src/math/FmaTest.h
    libc/test/src/math/HypotTest.h
    libc/test/src/math/RIntTest.h
    libc/test/src/math/RemQuoTest.h
    libc/test/src/math/RoundToIntegerTest.h
    libc/test/src/math/SqrtTest.h
    libc/test/src/math/asinhf_test.cpp
    libc/test/src/math/log10_test.cpp
    libc/test/src/math/log1p_test.cpp
    libc/test/src/math/log2_test.cpp
    libc/test/src/math/sincosf_test.cpp

Removed: 
    


################################################################################
diff  --git a/libc/test/src/math/FmaTest.h b/libc/test/src/math/FmaTest.h
index cbfe8d948b061..f648ac05333c3 100644
--- a/libc/test/src/math/FmaTest.h
+++ b/libc/test/src/math/FmaTest.h
@@ -67,7 +67,7 @@ class FmaTestTemplate : public __llvm_libc::testing::Test {
   }
 
   void test_subnormal_range(Func func) {
-    constexpr UIntType COUNT = 1000001;
+    constexpr UIntType COUNT = 100'001;
     constexpr UIntType STEP =
         (FPBits::MAX_SUBNORMAL - FPBits::MIN_SUBNORMAL) / COUNT;
     for (UIntType v = FPBits::MIN_SUBNORMAL, w = FPBits::MAX_SUBNORMAL;
@@ -82,7 +82,7 @@ class FmaTestTemplate : public __llvm_libc::testing::Test {
   }
 
   void test_normal_range(Func func) {
-    constexpr UIntType COUNT = 1000001;
+    constexpr UIntType COUNT = 100'001;
     constexpr UIntType STEP = (FPBits::MAX_NORMAL - FPBits::MIN_NORMAL) / COUNT;
     for (UIntType v = FPBits::MIN_NORMAL, w = FPBits::MAX_NORMAL;
          v <= FPBits::MAX_NORMAL && w >= FPBits::MIN_NORMAL;

diff  --git a/libc/test/src/math/HypotTest.h b/libc/test/src/math/HypotTest.h
index 8d3fd88dec31d..5bee260c70f0e 100644
--- a/libc/test/src/math/HypotTest.h
+++ b/libc/test/src/math/HypotTest.h
@@ -59,7 +59,7 @@ class HypotTestTemplate : public __llvm_libc::testing::Test {
   }
 
   void test_subnormal_range(Func func) {
-    constexpr UIntType COUNT = 100001;
+    constexpr UIntType COUNT = 10'001;
     for (unsigned scale = 0; scale < 4; ++scale) {
       UIntType max_value = FPBits::MAX_SUBNORMAL << scale;
       UIntType step = (max_value - FPBits::MIN_SUBNORMAL) / COUNT;
@@ -84,7 +84,7 @@ class HypotTestTemplate : public __llvm_libc::testing::Test {
   }
 
   void test_normal_range(Func func) {
-    constexpr UIntType COUNT = 100001;
+    constexpr UIntType COUNT = 10'001;
     constexpr UIntType STEP = (FPBits::MAX_NORMAL - FPBits::MIN_NORMAL) / COUNT;
     for (int signs = 0; signs < 4; ++signs) {
       for (UIntType v = FPBits::MIN_NORMAL, w = FPBits::MAX_NORMAL;

diff  --git a/libc/test/src/math/RIntTest.h b/libc/test/src/math/RIntTest.h
index 5fc130f23e1a8..caa62e743f266 100644
--- a/libc/test/src/math/RIntTest.h
+++ b/libc/test/src/math/RIntTest.h
@@ -93,7 +93,7 @@ class RIntTestTemplate : public __llvm_libc::testing::Test {
   }
 
   void testSubnormalRange(RIntFunc func) {
-    constexpr UIntType COUNT = 1000001;
+    constexpr UIntType COUNT = 100'001;
     constexpr UIntType STEP =
         (FPBits::MAX_SUBNORMAL - FPBits::MIN_SUBNORMAL) / COUNT;
     for (UIntType i = FPBits::MIN_SUBNORMAL; i <= FPBits::MAX_SUBNORMAL;
@@ -108,7 +108,7 @@ class RIntTestTemplate : public __llvm_libc::testing::Test {
   }
 
   void testNormalRange(RIntFunc func) {
-    constexpr UIntType COUNT = 1000001;
+    constexpr UIntType COUNT = 100'001;
     constexpr UIntType STEP = (FPBits::MAX_NORMAL - FPBits::MIN_NORMAL) / COUNT;
     for (UIntType i = FPBits::MIN_NORMAL; i <= FPBits::MAX_NORMAL; i += STEP) {
       T x = T(FPBits(i));

diff  --git a/libc/test/src/math/RemQuoTest.h b/libc/test/src/math/RemQuoTest.h
index 63f3d2e60bf08..636a19dafcd36 100644
--- a/libc/test/src/math/RemQuoTest.h
+++ b/libc/test/src/math/RemQuoTest.h
@@ -95,7 +95,7 @@ class RemQuoTestTemplate : public __llvm_libc::testing::Test {
   }
 
   void testSubnormalRange(RemQuoFunc func) {
-    constexpr UIntType COUNT = 1000001;
+    constexpr UIntType COUNT = 100'001;
     constexpr UIntType STEP =
         (FPBits::MAX_SUBNORMAL - FPBits::MIN_SUBNORMAL) / COUNT;
     for (UIntType v = FPBits::MIN_SUBNORMAL, w = FPBits::MAX_SUBNORMAL;
@@ -110,7 +110,7 @@ class RemQuoTestTemplate : public __llvm_libc::testing::Test {
   }
 
   void testNormalRange(RemQuoFunc func) {
-    constexpr UIntType COUNT = 234561;
+    constexpr UIntType COUNT = 1'001;
     constexpr UIntType STEP = (FPBits::MAX_NORMAL - FPBits::MIN_NORMAL) / COUNT;
     for (UIntType v = FPBits::MIN_NORMAL, w = FPBits::MAX_NORMAL;
          v <= FPBits::MAX_NORMAL && w >= FPBits::MIN_NORMAL;

diff  --git a/libc/test/src/math/RoundToIntegerTest.h b/libc/test/src/math/RoundToIntegerTest.h
index a8be9481d3c6e..d0f0ee23ada8d 100644
--- a/libc/test/src/math/RoundToIntegerTest.h
+++ b/libc/test/src/math/RoundToIntegerTest.h
@@ -214,7 +214,7 @@ class RoundToIntegerTestTemplate : public __llvm_libc::testing::Test {
   }
 
   void testSubnormalRange(RoundToIntegerFunc func) {
-    constexpr UIntType COUNT = 1000001;
+    constexpr UIntType COUNT = 1'000'001;
     constexpr UIntType STEP =
         (FPBits::MAX_SUBNORMAL - FPBits::MIN_SUBNORMAL) / COUNT;
     for (UIntType i = FPBits::MIN_SUBNORMAL; i <= FPBits::MAX_SUBNORMAL;
@@ -258,7 +258,7 @@ class RoundToIntegerTestTemplate : public __llvm_libc::testing::Test {
     if (sizeof(I) > sizeof(long))
       return;
 
-    constexpr UIntType COUNT = 1000001;
+    constexpr UIntType COUNT = 1'000'001;
     constexpr UIntType STEP = (FPBits::MAX_NORMAL - FPBits::MIN_NORMAL) / COUNT;
     for (UIntType i = FPBits::MIN_NORMAL; i <= FPBits::MAX_NORMAL; i += STEP) {
       F x = F(FPBits(i));

diff  --git a/libc/test/src/math/SqrtTest.h b/libc/test/src/math/SqrtTest.h
index b3154b6852276..dbac32581a58b 100644
--- a/libc/test/src/math/SqrtTest.h
+++ b/libc/test/src/math/SqrtTest.h
@@ -45,7 +45,7 @@ template <typename T> class SqrtTest : public __llvm_libc::testing::Test {
       test_all_rounding_modes(func, T(denormal));
     }
 
-    constexpr UIntType COUNT = 1'000'001;
+    constexpr UIntType COUNT = 200'001;
     constexpr UIntType STEP = HIDDEN_BIT / COUNT;
     for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
       T x = __llvm_libc::cpp::bit_cast<T>(v);
@@ -54,7 +54,7 @@ template <typename T> class SqrtTest : public __llvm_libc::testing::Test {
   }
 
   void test_normal_range(SqrtFunc func) {
-    constexpr UIntType COUNT = 1'234'561;
+    constexpr UIntType COUNT = 200'001;
     constexpr UIntType STEP = UIntType(-1) / COUNT;
     for (UIntType i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
       T x = __llvm_libc::cpp::bit_cast<T>(v);

diff  --git a/libc/test/src/math/asinhf_test.cpp b/libc/test/src/math/asinhf_test.cpp
index db86a240992c2..f7ba2eae4b7fe 100644
--- a/libc/test/src/math/asinhf_test.cpp
+++ b/libc/test/src/math/asinhf_test.cpp
@@ -43,7 +43,7 @@ TEST(LlvmLibcAsinhfTest, SpecialNumbers) {
 }
 
 TEST(LlvmLibcAsinhfTest, InFloatRange) {
-  constexpr uint32_t COUNT = 234561;
+  constexpr uint32_t COUNT = 1'001;
   constexpr uint32_t STEP = UINT32_MAX / COUNT;
   for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
     float x = float(FPBits_t(v));

diff  --git a/libc/test/src/math/log10_test.cpp b/libc/test/src/math/log10_test.cpp
index 3382f07732ebf..7ae5afa778c13 100644
--- a/libc/test/src/math/log10_test.cpp
+++ b/libc/test/src/math/log10_test.cpp
@@ -78,7 +78,7 @@ TEST(LlvmLibcLog10Test, AllExponents) {
 }
 
 TEST(LlvmLibcLog10Test, InDoubleRange) {
-  constexpr uint64_t COUNT = 234561;
+  constexpr uint64_t COUNT = 1'001;
   constexpr uint64_t START = 0x3FD0'0000'0000'0000ULL; // 0.25
   constexpr uint64_t STOP = 0x4010'0000'0000'0000ULL;  // 4.0
   // constexpr uint64_t START = 0x3FF0'0000'0000'0000ULL;  // 1.0

diff  --git a/libc/test/src/math/log1p_test.cpp b/libc/test/src/math/log1p_test.cpp
index 41daabad5333d..a2d2a4864aa73 100644
--- a/libc/test/src/math/log1p_test.cpp
+++ b/libc/test/src/math/log1p_test.cpp
@@ -81,7 +81,7 @@ TEST(LlvmLibcLog1pTest, AllExponents) {
 }
 
 TEST(LlvmLibcLog1pTest, InDoubleRange) {
-  constexpr uint64_t COUNT = 234561;
+  constexpr uint64_t COUNT = 4501;
 
   auto test = [&](uint64_t start, uint64_t stop,
                   mpfr::RoundingMode rounding_mode) {

diff  --git a/libc/test/src/math/log2_test.cpp b/libc/test/src/math/log2_test.cpp
index 59b5828c2d609..aa68d6eda8c9c 100644
--- a/libc/test/src/math/log2_test.cpp
+++ b/libc/test/src/math/log2_test.cpp
@@ -78,7 +78,7 @@ TEST(LlvmLibcLog2Test, AllExponents) {
 }
 
 TEST(LlvmLibcLog2Test, InDoubleRange) {
-  constexpr uint64_t COUNT = 234561;
+  constexpr uint64_t COUNT = 1'001;
   constexpr uint64_t START = 0x3FD0'0000'0000'0000ULL; // 0.25
   constexpr uint64_t STOP = 0x4010'0000'0000'0000ULL;  // 4.0
   // constexpr uint64_t START = 0x3FF0'0000'0000'0000ULL;  // 1.0

diff  --git a/libc/test/src/math/sincosf_test.cpp b/libc/test/src/math/sincosf_test.cpp
index 1caf3a2700b95..1c1d878c7db07 100644
--- a/libc/test/src/math/sincosf_test.cpp
+++ b/libc/test/src/math/sincosf_test.cpp
@@ -90,7 +90,7 @@ TEST(LlvmLibcSinCosfTest, SpecialNumbers) {
   }
 
 TEST(LlvmLibcSinCosfTest, InFloatRange) {
-  constexpr uint32_t COUNT = 234561;
+  constexpr uint32_t COUNT = 1'001;
   constexpr uint32_t STEP = UINT32_MAX / COUNT;
   for (uint32_t i = 0, v = 0; i <= COUNT; ++i, v += STEP) {
     float x = float(FPBits((v)));


        


More information about the libc-commits mailing list