Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[libcxx][test][z/OS] Fix hermite.pass.cpp for HEX float #101019

Merged
merged 5 commits into from
Aug 7, 2024

Conversation

zibi2
Copy link
Contributor

@zibi2 zibi2 commented Jul 29, 2024

The HEX float on z/OS does not have infinity nor NaN. In addition, the limits are smaller before the overflow occurs in mathematical calculations. This PR accounts for this.

FYI, this LIT test was recently added in PR 89982

@zibi2 zibi2 self-assigned this Jul 29, 2024
@zibi2 zibi2 requested a review from a team as a code owner July 29, 2024 14:31
@llvmbot llvmbot added the libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi. label Jul 29, 2024
@llvmbot
Copy link
Member

llvmbot commented Jul 29, 2024

@llvm/pr-subscribers-libcxx

Author: Zibi Sarbinowski (zibi2)

Changes

The HEX float on z/OS does not have infinity nor NaN. In addition, the limits are smaller before the overflow occurs in mathematical calculations. This PR accounts for this.

FYI, this LIT test was recently added in PR 89982


Full diff: https://github.com/llvm/llvm-project/pull/101019.diff

1 Files Affected:

  • (modified) libcxx/test/std/numerics/c.math/hermite.pass.cpp (+10-1)
diff --git a/libcxx/test/std/numerics/c.math/hermite.pass.cpp b/libcxx/test/std/numerics/c.math/hermite.pass.cpp
index 08fbd5c3283c1..fb702369ad036 100644
--- a/libcxx/test/std/numerics/c.math/hermite.pass.cpp
+++ b/libcxx/test/std/numerics/c.math/hermite.pass.cpp
@@ -26,7 +26,12 @@
 
 #include "type_algorithms.h"
 
-inline constexpr unsigned g_max_n = 128;
+inline constexpr unsigned g_max_n =
+#if !(defined(__MVS__) && !defined(__BFP__))
+  128;
+#else
+  39;
+#endif
 
 template <class T>
 std::array<T, 11> sample_points() {
@@ -203,6 +208,7 @@ std::vector<T> get_roots(unsigned n) {
 
 template <class Real>
 void test() {
+#if !(defined(__MVS__) && !defined(__BFP__))
   { // checks if NaNs are reported correctly (i.e. output == input for input == NaN)
     using nl = std::numeric_limits<Real>;
     for (Real NaN : {nl::quiet_NaN(), nl::signaling_NaN()})
@@ -215,6 +221,7 @@ void test() {
       for (unsigned n = 0; n < g_max_n; ++n)
         assert(!std::isnan(std::hermite(n, x)));
   }
+#endif
 
   { // checks std::hermite(n, x) for n=0..5 against analytic polynoms
     const auto h0 = [](Real) -> Real { return 1; };
@@ -289,6 +296,7 @@ void test() {
     }
   }
 
+#if !(defined(__MVS__) && !defined(__BFP__))
   { // check input infinity is handled correctly
     Real inf = std::numeric_limits<Real>::infinity();
     for (unsigned n = 1; n < g_max_n; ++n) {
@@ -316,6 +324,7 @@ void test() {
       }
     }
   }
+#endif
 }
 
 struct TestFloat {

Copy link

github-actions bot commented Jul 29, 2024

✅ With the latest revision this PR passed the C/C++ code formatter.

Copy link
Contributor

@abhina-sree abhina-sree left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zibi2 zibi2 requested a review from PaulXiCao July 31, 2024 21:26
@zibi2 zibi2 force-pushed the zs_hermite.pass.cpp branch from 3cbd490 to b4ece91 Compare July 31, 2024 21:44
@zibi2 zibi2 requested a review from melody-notpond August 1, 2024 17:50
@zibi2 zibi2 requested a review from PaulXiCao August 2, 2024 20:40
Copy link
Contributor

@PaulXiCao PaulXiCao left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@zibi2 zibi2 merged commit f343fee into llvm:main Aug 7, 2024
54 checks passed
@PaulXiCao
Copy link
Contributor

@zibi2 Thanks for finding and solving this issue! 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
libc++ libc++ C++ Standard Library. Not GNU libstdc++. Not libc++abi.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants