Skip to content

Conversation

@harrisonGPU
Copy link
Contributor

@harrisonGPU harrisonGPU commented Mar 10, 2025

Implementation of acoshf16 function for 16-bit inputs.

@harrisonGPU harrisonGPU requested a review from overmighty March 10, 2025 12:04
@harrisonGPU harrisonGPU self-assigned this Mar 10, 2025
@github-actions
Copy link

github-actions bot commented Mar 10, 2025

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

@harrisonGPU harrisonGPU force-pushed the libcAcoshf16 branch 2 times, most recently from 5113bfe to 0dea69f Compare March 10, 2025 13:58
@llvmbot
Copy link
Member

llvmbot commented Mar 13, 2025

@llvm/pr-subscribers-libc

Author: Harrison Hao (harrisonGPU)

Changes

Implementation of acoshf16 function for 16-bit inputs.


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

11 Files Affected:

  • (modified) libc/config/linux/x86_64/entrypoints.txt (+1)
  • (modified) libc/docs/headers/math/index.rst (+1-1)
  • (modified) libc/include/math.yaml (+7)
  • (modified) libc/src/math/CMakeLists.txt (+1)
  • (added) libc/src/math/acoshf16.h (+21)
  • (modified) libc/src/math/generic/CMakeLists.txt (+21)
  • (added) libc/src/math/generic/acoshf16.cpp (+88)
  • (modified) libc/test/src/math/CMakeLists.txt (+11)
  • (added) libc/test/src/math/acoshf16_test.cpp (+76)
  • (modified) libc/test/src/math/smoke/CMakeLists.txt (+11)
  • (added) libc/test/src/math/smoke/acoshf16_test.cpp (+41)
diff --git a/libc/config/linux/x86_64/entrypoints.txt b/libc/config/linux/x86_64/entrypoints.txt
index 12dc87bf945fd..b705d81fff79c 100644
--- a/libc/config/linux/x86_64/entrypoints.txt
+++ b/libc/config/linux/x86_64/entrypoints.txt
@@ -653,6 +653,7 @@ if(LIBC_TYPES_HAS_FLOAT16)
     # math.h C23 _Float16 entrypoints
     libc.src.math.asinf16
     libc.src.math.acosf16
+    libc.src.math.acoshf16
     libc.src.math.canonicalizef16
     libc.src.math.ceilf16
     libc.src.math.copysignf16
diff --git a/libc/docs/headers/math/index.rst b/libc/docs/headers/math/index.rst
index 5b855ce4881c3..8dc7c8c1a0966 100644
--- a/libc/docs/headers/math/index.rst
+++ b/libc/docs/headers/math/index.rst
@@ -251,7 +251,7 @@ Higher Math Functions
 +===========+==================+=================+========================+======================+========================+========================+============================+
 | acos      | |check|          |                 |                        | |check|              |                        | 7.12.4.1               | F.10.1.1                   |
 +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
-| acosh     | |check|          |                 |                        |                      |                        | 7.12.5.1               | F.10.2.1                   |
+| acosh     | |check|          |                 |                        | |check|              |                        | 7.12.5.1               | F.10.2.1                   |
 +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
 | acospi    |                  |                 |                        |                      |                        | 7.12.4.8               | F.10.1.8                   |
 +-----------+------------------+-----------------+------------------------+----------------------+------------------------+------------------------+----------------------------+
diff --git a/libc/include/math.yaml b/libc/include/math.yaml
index a66f981030864..7fd73445cc74e 100644
--- a/libc/include/math.yaml
+++ b/libc/include/math.yaml
@@ -27,6 +27,13 @@ functions:
     return_type: float
     arguments:
       - type: float
+    name: acoshf16
+    standards:
+      - stdc
+    return_type: _Float16
+    arguments:
+      - type: _Float16
+    guard: LIBC_TYPES_HAS_FLOAT16
   - name: asin
     standards:
       - stdc
diff --git a/libc/src/math/CMakeLists.txt b/libc/src/math/CMakeLists.txt
index f18a73d46f9aa..bdf8b923416d8 100644
--- a/libc/src/math/CMakeLists.txt
+++ b/libc/src/math/CMakeLists.txt
@@ -46,6 +46,7 @@ add_math_entrypoint_object(acosf16)
 
 add_math_entrypoint_object(acosh)
 add_math_entrypoint_object(acoshf)
+add_math_entrypoint_object(acoshf16)
 
 add_math_entrypoint_object(asin)
 add_math_entrypoint_object(asinf)
diff --git a/libc/src/math/acoshf16.h b/libc/src/math/acoshf16.h
new file mode 100644
index 0000000000000..f471ecfeb6154
--- /dev/null
+++ b/libc/src/math/acoshf16.h
@@ -0,0 +1,21 @@
+//===-- Implementation header for acoshf16 ----------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception.
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC_MATH_ACOSHF16_H
+#define LLVM_LIBC_SRC_MATH_ACOSHF16_H
+
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/types.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+float16 acoshf16(float16 x);
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC_MATH_ACOSHF16_H
diff --git a/libc/src/math/generic/CMakeLists.txt b/libc/src/math/generic/CMakeLists.txt
index 3114289bad486..fd5ecd72b765f 100644
--- a/libc/src/math/generic/CMakeLists.txt
+++ b/libc/src/math/generic/CMakeLists.txt
@@ -3944,6 +3944,27 @@ add_entrypoint_object(
     libc.src.__support.macros.optimization
 )
 
+add_entrypoint_object(
+  acoshf16
+  SRCS
+    acoshf16.cpp
+  HDRS
+    ../acoshf16.h
+  DEPENDS
+    .common_constants
+    .explogxf
+    libc.hdr.errno_macros
+    libc.hdr.fenv_macros
+    libc.src.__support.FPUtil.cast
+    libc.src.__support.FPUtil.fenv_impl
+    libc.src.__support.FPUtil.fp_bits
+    libc.src.__support.FPUtil.multiply_add
+    libc.src.__support.FPUtil.polyeval
+    libc.src.__support.FPUtil.sqrt
+    libc.src.__support.macros.optimization
+    libc.src.__support.macros.properties.types 
+)
+
 add_entrypoint_object(
   asinhf
   SRCS
diff --git a/libc/src/math/generic/acoshf16.cpp b/libc/src/math/generic/acoshf16.cpp
new file mode 100644
index 0000000000000..1a4f68987ee6b
--- /dev/null
+++ b/libc/src/math/generic/acoshf16.cpp
@@ -0,0 +1,88 @@
+//===-- Half-precision acoshf16 function ----------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/math/acoshf16.h"
+#include "src/__support/FPUtil/FEnvImpl.h"
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/__support/FPUtil/except_value_utils.h"
+#include "src/__support/FPUtil/generic/sqrt.h"
+#include "src/__support/FPUtil/multiply_add.h"
+#include "src/__support/macros/optimization.h"
+#include "src/math/generic/explogxf.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+static constexpr size_t N_EXCEPTS = 2;
+static constexpr fputil::ExceptValues<float16, N_EXCEPTS> ACOSHF16_EXCEPTS{
+    {// (input, RZ output, RU offset, RD offset, RN offset)
+     {0x41B7, 0x3ED8, 1, 0, 0},
+     {0x3CE4, 0x393E, 1, 0, 1}}};
+
+LLVM_LIBC_FUNCTION(float16, acoshf16, (float16 x)) {
+  using FPBits = fputil::FPBits<float16>;
+  FPBits xbits(x);
+  uint16_t x_u = xbits.uintval();
+  uint16_t x_abs = x_u & 0x7fff;
+
+  // Check for NaN input first.
+  if (LIBC_UNLIKELY(xbits.is_nan())) {
+    if (xbits.is_signaling_nan()) {
+      fputil::raise_except_if_required(FE_INVALID);
+      return FPBits::quiet_nan().get_val();
+    }
+    return x;
+  }
+
+  // Check for infinite inputs.
+  if (LIBC_UNLIKELY(xbits.is_inf())) {
+    if (xbits.is_neg()) {
+      fputil::set_errno_if_required(EDOM);
+      fputil::raise_except_if_required(FE_INVALID);
+      return FPBits::quiet_nan().get_val();
+    }
+    return x;
+  }
+
+  // Domain error for inputs less than 1.0.
+  if (LIBC_UNLIKELY(x_abs < 0x3c00U)) {
+    fputil::set_errno_if_required(EDOM);
+    fputil::raise_except_if_required(FE_INVALID);
+    return FPBits::quiet_nan().get_val();
+  }
+
+  // acosh(1.0) exactly equals 0.0
+  if (LIBC_UNLIKELY(x_u == 0x3c00U))
+    return float16(0.0f);
+
+  if (auto r = ACOSHF16_EXCEPTS.lookup(xbits.uintval());
+      LIBC_UNLIKELY(r.has_value()))
+    return r.value();
+
+  float xf32 = x;
+  // High precision for inputs very close to 1.0
+  if (LIBC_UNLIKELY(xf32 < 1.25f)) {
+    float delta = xf32 - 1.0f;
+    float sqrt_2_delta = fputil::sqrt<float>(2.0 * delta);
+    float x2 = delta;
+    float pe = fputil::polyeval(x2, 0x1.0000000000000p+0f,
+                                -0x1.55551a83a9472p-4f, 0x1.331601c4b8ecfp-6f,
+                                -0x1.6890f49eb0acbp-8f, 0x1.8f3a617040a6ap-10f);
+    float approx = sqrt_2_delta * pe;
+    return fputil::cast<float16>(approx);
+  }
+
+  // Standard computation for general case.
+  float sqrt_term =
+      fputil::sqrt<float>(fputil::multiply_add(xf32, xf32, -1.0f));
+  float result = static_cast<float>(log_eval(xf32 + sqrt_term));
+
+  return fputil::cast<float16>(result);
+}
+
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/test/src/math/CMakeLists.txt b/libc/test/src/math/CMakeLists.txt
index 53ddd301900c0..311d56a2a33ab 100644
--- a/libc/test/src/math/CMakeLists.txt
+++ b/libc/test/src/math/CMakeLists.txt
@@ -2173,6 +2173,17 @@ add_fp_unittest(
     libc.src.__support.FPUtil.fp_bits
 )
 
+add_fp_unittest(
+  acoshf16_test
+  NEED_MPFR
+  SUITE
+    libc-math-unittests
+  SRCS
+    acoshf16_test.cpp
+  DEPENDS
+    libc.src.math.acoshf16
+)
+
 add_fp_unittest(
   asinf_test
   NEED_MPFR
diff --git a/libc/test/src/math/acoshf16_test.cpp b/libc/test/src/math/acoshf16_test.cpp
new file mode 100644
index 0000000000000..a779d3110f329
--- /dev/null
+++ b/libc/test/src/math/acoshf16_test.cpp
@@ -0,0 +1,76 @@
+//===-- Unittests for acoshf16 --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/FPUtil/FPBits.h"
+#include "src/__support/FPUtil/cast.h"
+#include "src/errno/libc_errno.h"
+#include "src/math/acoshf16.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "utils/MPFRWrapper/MPFRUtils.h"
+#include <stdint.h>
+
+using LlvmLibcAcoshf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
+namespace mpfr = LIBC_NAMESPACE::testing::mpfr;
+
+static constexpr uint16_t START = 0x3c00U;
+static constexpr uint16_t STOP = 0x7bffU;
+
+TEST_F(LlvmLibcAcoshf16Test, SpecialNumbers) {
+  LIBC_NAMESPACE::libc_errno = 0;
+
+  EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::acoshf16(aNaN));
+  EXPECT_MATH_ERRNO(0);
+
+  EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::acoshf16(sNaN), FE_INVALID);
+  EXPECT_MATH_ERRNO(0);
+
+  EXPECT_FP_EQ_ALL_ROUNDING(float16(0.0f),
+                            LIBC_NAMESPACE::acoshf16(float16(1.0f)));
+  EXPECT_MATH_ERRNO(0);
+
+  EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::acoshf16(float16(0.5f)));
+  EXPECT_MATH_ERRNO(EDOM);
+
+  EXPECT_FP_EQ_ALL_ROUNDING(inf, LIBC_NAMESPACE::acoshf16(inf));
+  EXPECT_MATH_ERRNO(0);
+
+  EXPECT_FP_EQ_ALL_ROUNDING(aNaN, LIBC_NAMESPACE::acoshf16(neg_inf));
+  EXPECT_MATH_ERRNO(EDOM);
+}
+
+TEST_F(LlvmLibcAcoshf16Test, PositiveRange) {
+  for (uint16_t v = START; v <= STOP; ++v) {
+    float16 x = FPBits(v).get_val();
+
+    EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acosh, x,
+                                   LIBC_NAMESPACE::acoshf16(x), 0.5);
+  }
+}
+
+TEST_F(LlvmLibcAcoshf16Test, SpecificBitPatterns) {
+  constexpr int N = 12;
+  constexpr uint16_t INPUTS[N] = {
+      0x3C00, // x = 1.0
+      0x3C01, // x = just above 1.0 (minimally larger than 1)
+      0x3E00, // x = 1.5
+      0x4200, // x = 3.0
+      0x4500, // x = 5.0
+      0x4900, // x = 10.0
+      0x51FF, // x = ~47.94
+      0x5CB0, // x = ~300.0
+      0x643F, // x = ~1087.6
+      0x77FF, // x = just below next exponent interval (max for exponent 0x1D)
+      0x7801, // x = just above previous value (min for exponent 0x1E)
+      0x7BFF  // x = 65504.0 (max finite half)
+  };
+  for (int i = 0; i < N; ++i) {
+    float16 x = FPBits(INPUTS[i]).get_val();
+    EXPECT_MPFR_MATCH_ALL_ROUNDING(mpfr::Operation::Acosh, x,
+                                   LIBC_NAMESPACE::acoshf16(x), 0.5);
+  }
+}
diff --git a/libc/test/src/math/smoke/CMakeLists.txt b/libc/test/src/math/smoke/CMakeLists.txt
index 6f94440d826d9..4303afd242e22 100644
--- a/libc/test/src/math/smoke/CMakeLists.txt
+++ b/libc/test/src/math/smoke/CMakeLists.txt
@@ -3945,6 +3945,17 @@ add_fp_unittest(
     libc.src.__support.FPUtil.fp_bits
 )
 
+add_fp_unittest(
+  acoshf16_test
+  SUITE
+    libc-math-smoke-tests
+  SRCS
+    acoshf16_test.cpp
+  DEPENDS
+    libc.src.errno.errno
+    libc.src.math.acoshf16  
+)
+
 add_fp_unittest(
   asinf_test
   SUITE
diff --git a/libc/test/src/math/smoke/acoshf16_test.cpp b/libc/test/src/math/smoke/acoshf16_test.cpp
new file mode 100644
index 0000000000000..b8d13b9fe88c3
--- /dev/null
+++ b/libc/test/src/math/smoke/acoshf16_test.cpp
@@ -0,0 +1,41 @@
+//===-- Unittests for acoshf16 --------------------------------------------===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/errno/libc_errno.h"
+#include "src/math/acoshf16.h"
+#include "test/UnitTest/FPMatcher.h"
+#include "test/UnitTest/Test.h"
+
+using LlvmLibcAcoshf16Test = LIBC_NAMESPACE::testing::FPTest<float16>;
+
+TEST_F(LlvmLibcAcoshf16Test, SpecialNumbers) {
+  LIBC_NAMESPACE::libc_errno = 0;
+  EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::acoshf16(aNaN));
+  EXPECT_MATH_ERRNO(0);
+
+  EXPECT_FP_EQ_WITH_EXCEPTION(aNaN, LIBC_NAMESPACE::acoshf16(sNaN), FE_INVALID);
+  EXPECT_MATH_ERRNO(0);
+
+  EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::acoshf16(zero));
+  EXPECT_MATH_ERRNO(EDOM);
+
+  EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::acoshf16(neg_zero));
+  EXPECT_MATH_ERRNO(EDOM);
+
+  EXPECT_FP_EQ(inf, LIBC_NAMESPACE::acoshf16(inf));
+  EXPECT_MATH_ERRNO(0);
+
+  EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::acoshf16(neg_inf));
+  EXPECT_MATH_ERRNO(EDOM);
+
+  EXPECT_FP_EQ(float16(0.0f), LIBC_NAMESPACE::acoshf16(float16(1.0f)));
+  EXPECT_MATH_ERRNO(0);
+
+  EXPECT_FP_EQ(aNaN, LIBC_NAMESPACE::acoshf16(float16(0.5f)));
+  EXPECT_MATH_ERRNO(EDOM);
+}

@harrisonGPU harrisonGPU requested a review from lntue March 13, 2025 12:54
@overmighty
Copy link
Member

You don't need to force-push if you didn't rebase btw.

@harrisonGPU
Copy link
Contributor Author

You don't need to force-push if you didn't rebase btw.

Yes, I did rebase.

@harrisonGPU harrisonGPU requested a review from overmighty March 18, 2025 14:30
@harrisonGPU
Copy link
Contributor Author

ping @overmighty

@harrisonGPU harrisonGPU requested a review from lntue March 20, 2025 16:46
@harrisonGPU harrisonGPU requested a review from lntue March 22, 2025 13:51
Copy link
Contributor

@lntue lntue left a comment

Choose a reason for hiding this comment

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

LGTM. Please wait to see if @overmighty has any other comments.

@harrisonGPU harrisonGPU requested a review from overmighty March 22, 2025 16:05
@lntue lntue merged commit ee3e17d into llvm:main Mar 23, 2025
17 checks passed
@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 23, 2025

LLVM Buildbot has detected a new failure on builder libc-aarch64-ubuntu-fullbuild-dbg running on libc-aarch64-ubuntu while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/71/builds/18786

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[ RUN      ] LlvmLibcFMaxTest.InfArg
[       OK ] LlvmLibcFMaxTest.InfArg (2 us)
[ RUN      ] LlvmLibcFMaxTest.NegInfArg
[       OK ] LlvmLibcFMaxTest.NegInfArg (1 us)
[ RUN      ] LlvmLibcFMaxTest.BothZero
[       OK ] LlvmLibcFMaxTest.BothZero (1 us)
[ RUN      ] LlvmLibcFMaxTest.Range
[       OK ] LlvmLibcFMaxTest.Range (29 ms)
Ran 5 tests.  PASS: 5  FAIL: 0
[536/960] Running unit test libc.test.src.math.smoke.acoshf16_test.__unit__
FAILED: libc/test/src/math/smoke/CMakeFiles/libc.test.src.math.smoke.acoshf16_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/libc/test/src/math/smoke && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/libc/test/src/math/smoke/libc.test.src.math.smoke.acoshf16_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcAcoshf16Test.SpecialNumbers
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/test/src/math/smoke/acoshf16_test.cpp:22: FAILURE
      Expected: __llvm_libc_20_0_0_git::fputil::test_except( static_cast<int>((0x1 | 0x2 | 0x4 | 0x8 | 0x10))) & ((0x4) ? (0x4) : static_cast<int>((0x1 | 0x2 | 0x4 | 0x8 | 0x10)))
      Which is: 0
To be equal to: (0x4)
      Which is: 4
[  FAILED  ] LlvmLibcAcoshf16Test.SpecialNumbers
Ran 1 tests.  PASS: 0  FAIL: 1
[537/960] Running unit test libc.test.src.math.smoke.ilogbf128_test.__unit__
[==========] Running 5 tests from 1 test suite.
[ RUN      ] LlvmLibcIntLogbTest.SpecialNumbers
[       OK ] LlvmLibcIntLogbTest.SpecialNumbers (4 us)
[ RUN      ] LlvmLibcIntLogbTest.PowersOfTwo
[       OK ] LlvmLibcIntLogbTest.PowersOfTwo (6 us)
[ RUN      ] LlvmLibcIntLogbTest.SomeIntegers
[       OK ] LlvmLibcIntLogbTest.SomeIntegers (4 us)
[ RUN      ] LlvmLibcIntLogbTest.SubnormalRange
[       OK ] LlvmLibcIntLogbTest.SubnormalRange (6 ms)
[ RUN      ] LlvmLibcIntLogbTest.NormalRange
[       OK ] LlvmLibcIntLogbTest.NormalRange (6 ms)
Ran 5 tests.  PASS: 5  FAIL: 0
[538/960] Running unit test libc.test.src.math.smoke.fmax_test.__unit__.__NO_MISC_MATH_BASIC_OPS_OPT
[==========] Running 5 tests from 1 test suite.
[ RUN      ] LlvmLibcFMaxTest.NaN
[       OK ] LlvmLibcFMaxTest.NaN (3 us)
[ RUN      ] LlvmLibcFMaxTest.InfArg
[       OK ] LlvmLibcFMaxTest.InfArg (2 us)
[ RUN      ] LlvmLibcFMaxTest.NegInfArg
[       OK ] LlvmLibcFMaxTest.NegInfArg (1 us)
[ RUN      ] LlvmLibcFMaxTest.BothZero
[       OK ] LlvmLibcFMaxTest.BothZero (1 us)
[ RUN      ] LlvmLibcFMaxTest.Range
[       OK ] LlvmLibcFMaxTest.Range (30 ms)
Ran 5 tests.  PASS: 5  FAIL: 0
[539/960] Running unit test libc.test.src.math.smoke.fmaxf_test.__unit__.__NO_MISC_MATH_BASIC_OPS_OPT
[==========] Running 5 tests from 1 test suite.
Step 8 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[ RUN      ] LlvmLibcFMaxTest.InfArg
[       OK ] LlvmLibcFMaxTest.InfArg (2 us)
[ RUN      ] LlvmLibcFMaxTest.NegInfArg
[       OK ] LlvmLibcFMaxTest.NegInfArg (1 us)
[ RUN      ] LlvmLibcFMaxTest.BothZero
[       OK ] LlvmLibcFMaxTest.BothZero (1 us)
[ RUN      ] LlvmLibcFMaxTest.Range
[       OK ] LlvmLibcFMaxTest.Range (29 ms)
Ran 5 tests.  PASS: 5  FAIL: 0
[536/960] Running unit test libc.test.src.math.smoke.acoshf16_test.__unit__
FAILED: libc/test/src/math/smoke/CMakeFiles/libc.test.src.math.smoke.acoshf16_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/libc/test/src/math/smoke && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/libc/test/src/math/smoke/libc.test.src.math.smoke.acoshf16_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcAcoshf16Test.SpecialNumbers
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/test/src/math/smoke/acoshf16_test.cpp:22: FAILURE
      Expected: __llvm_libc_20_0_0_git::fputil::test_except( static_cast<int>((0x1 | 0x2 | 0x4 | 0x8 | 0x10))) & ((0x4) ? (0x4) : static_cast<int>((0x1 | 0x2 | 0x4 | 0x8 | 0x10)))
      Which is: 0
To be equal to: (0x4)
      Which is: 4
[  FAILED  ] LlvmLibcAcoshf16Test.SpecialNumbers
Ran 1 tests.  PASS: 0  FAIL: 1
[537/960] Running unit test libc.test.src.math.smoke.ilogbf128_test.__unit__
[==========] Running 5 tests from 1 test suite.
[ RUN      ] LlvmLibcIntLogbTest.SpecialNumbers
[       OK ] LlvmLibcIntLogbTest.SpecialNumbers (4 us)
[ RUN      ] LlvmLibcIntLogbTest.PowersOfTwo
[       OK ] LlvmLibcIntLogbTest.PowersOfTwo (6 us)
[ RUN      ] LlvmLibcIntLogbTest.SomeIntegers
[       OK ] LlvmLibcIntLogbTest.SomeIntegers (4 us)
[ RUN      ] LlvmLibcIntLogbTest.SubnormalRange
[       OK ] LlvmLibcIntLogbTest.SubnormalRange (6 ms)
[ RUN      ] LlvmLibcIntLogbTest.NormalRange
[       OK ] LlvmLibcIntLogbTest.NormalRange (6 ms)
Ran 5 tests.  PASS: 5  FAIL: 0
[538/960] Running unit test libc.test.src.math.smoke.fmax_test.__unit__.__NO_MISC_MATH_BASIC_OPS_OPT
[==========] Running 5 tests from 1 test suite.
[ RUN      ] LlvmLibcFMaxTest.NaN
[       OK ] LlvmLibcFMaxTest.NaN (3 us)
[ RUN      ] LlvmLibcFMaxTest.InfArg
[       OK ] LlvmLibcFMaxTest.InfArg (2 us)
[ RUN      ] LlvmLibcFMaxTest.NegInfArg
[       OK ] LlvmLibcFMaxTest.NegInfArg (1 us)
[ RUN      ] LlvmLibcFMaxTest.BothZero
[       OK ] LlvmLibcFMaxTest.BothZero (1 us)
[ RUN      ] LlvmLibcFMaxTest.Range
[       OK ] LlvmLibcFMaxTest.Range (30 ms)
Ran 5 tests.  PASS: 5  FAIL: 0
[539/960] Running unit test libc.test.src.math.smoke.fmaxf_test.__unit__.__NO_MISC_MATH_BASIC_OPS_OPT
[==========] Running 5 tests from 1 test suite.

@llvm-ci
Copy link
Collaborator

llvm-ci commented Mar 23, 2025

LLVM Buildbot has detected a new failure on builder libc-aarch64-ubuntu-dbg running on libc-aarch64-ubuntu while building libc at step 4 "annotate".

Full details are available at: https://lab.llvm.org/buildbot/#/builders/104/builds/18785

Here is the relevant piece of the build log for the reference
Step 4 (annotate) failure: 'python ../llvm-zorg/zorg/buildbot/builders/annotated/libc-linux.py ...' (failure)
...
[       OK ] LlvmLibcTotalOrderMagTest.QuietVsSignalingNaN (1 us)
[ RUN      ] LlvmLibcTotalOrderMagTest.NaNPayloads
[       OK ] LlvmLibcTotalOrderMagTest.NaNPayloads (2 us)
Ran 7 tests.  PASS: 7  FAIL: 0
[767/1023] Running unit test libc.test.src.math.smoke.tanhf_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcTanhfTest.SpecialNumbers
[       OK ] LlvmLibcTanhfTest.SpecialNumbers (5 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[768/1023] Running unit test libc.test.src.math.smoke.acoshf16_test.__unit__
FAILED: libc/test/src/math/smoke/CMakeFiles/libc.test.src.math.smoke.acoshf16_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build/libc/test/src/math/smoke && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build/libc/test/src/math/smoke/libc.test.src.math.smoke.acoshf16_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcAcoshf16Test.SpecialNumbers
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/src/math/smoke/acoshf16_test.cpp:22: FAILURE
      Expected: __llvm_libc_20_0_0_git::fputil::test_except( static_cast<int>((1 | 2 | 4 | 8 | 16))) & ((1) ? (1) : static_cast<int>((1 | 2 | 4 | 8 | 16)))
      Which is: 0
To be equal to: (1)
      Which is: 1
[  FAILED  ] LlvmLibcAcoshf16Test.SpecialNumbers
Ran 1 tests.  PASS: 0  FAIL: 1
[769/1023] Running unit test libc.test.src.math.smoke.nextupf16_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcNextUpTest.TestNaN
[       OK ] LlvmLibcNextUpTest.TestNaN (3 us)
[ RUN      ] LlvmLibcNextUpTest.TestBoundaries
[       OK ] LlvmLibcNextUpTest.TestBoundaries (3 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[770/1023] Running unit test libc.test.src.math.smoke.ddivf128_test.__unit__
[==========] Running 5 tests from 1 test suite.
[ RUN      ] LlvmLibcDivTest.SpecialNumbers
[       OK ] LlvmLibcDivTest.SpecialNumbers (10 us)
[ RUN      ] LlvmLibcDivTest.DivisionByZero
[       OK ] LlvmLibcDivTest.DivisionByZero (4 us)
[ RUN      ] LlvmLibcDivTest.InvalidOperations
[       OK ] LlvmLibcDivTest.InvalidOperations (11 us)
[ RUN      ] LlvmLibcDivTest.RangeErrors
[       OK ] LlvmLibcDivTest.RangeErrors (33 us)
[ RUN      ] LlvmLibcDivTest.InexactResults
[       OK ] LlvmLibcDivTest.InexactResults (2 us)
Ran 5 tests.  PASS: 5  FAIL: 0
[771/1023] Running unit test libc.test.src.math.smoke.fabsf_test.__unit__.__NO_MISC_MATH_BASIC_OPS_OPT
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFAbsTest.SpecialNumbers
[       OK ] LlvmLibcFAbsTest.SpecialNumbers (8 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[772/1023] Running unit test libc.test.src.math.smoke.fma_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFmaTest.SpecialNumbers
Step 7 (libc-unit-tests) failure: libc-unit-tests (failure)
...
[       OK ] LlvmLibcTotalOrderMagTest.QuietVsSignalingNaN (1 us)
[ RUN      ] LlvmLibcTotalOrderMagTest.NaNPayloads
[       OK ] LlvmLibcTotalOrderMagTest.NaNPayloads (2 us)
Ran 7 tests.  PASS: 7  FAIL: 0
[767/1023] Running unit test libc.test.src.math.smoke.tanhf_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcTanhfTest.SpecialNumbers
[       OK ] LlvmLibcTanhfTest.SpecialNumbers (5 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[768/1023] Running unit test libc.test.src.math.smoke.acoshf16_test.__unit__
FAILED: libc/test/src/math/smoke/CMakeFiles/libc.test.src.math.smoke.acoshf16_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build/libc/test/src/math/smoke && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/build/libc/test/src/math/smoke/libc.test.src.math.smoke.acoshf16_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcAcoshf16Test.SpecialNumbers
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu/llvm-project/libc/test/src/math/smoke/acoshf16_test.cpp:22: FAILURE
      Expected: __llvm_libc_20_0_0_git::fputil::test_except( static_cast<int>((1 | 2 | 4 | 8 | 16))) & ((1) ? (1) : static_cast<int>((1 | 2 | 4 | 8 | 16)))
      Which is: 0
To be equal to: (1)
      Which is: 1
[  FAILED  ] LlvmLibcAcoshf16Test.SpecialNumbers
Ran 1 tests.  PASS: 0  FAIL: 1
[769/1023] Running unit test libc.test.src.math.smoke.nextupf16_test.__unit__
[==========] Running 2 tests from 1 test suite.
[ RUN      ] LlvmLibcNextUpTest.TestNaN
[       OK ] LlvmLibcNextUpTest.TestNaN (3 us)
[ RUN      ] LlvmLibcNextUpTest.TestBoundaries
[       OK ] LlvmLibcNextUpTest.TestBoundaries (3 us)
Ran 2 tests.  PASS: 2  FAIL: 0
[770/1023] Running unit test libc.test.src.math.smoke.ddivf128_test.__unit__
[==========] Running 5 tests from 1 test suite.
[ RUN      ] LlvmLibcDivTest.SpecialNumbers
[       OK ] LlvmLibcDivTest.SpecialNumbers (10 us)
[ RUN      ] LlvmLibcDivTest.DivisionByZero
[       OK ] LlvmLibcDivTest.DivisionByZero (4 us)
[ RUN      ] LlvmLibcDivTest.InvalidOperations
[       OK ] LlvmLibcDivTest.InvalidOperations (11 us)
[ RUN      ] LlvmLibcDivTest.RangeErrors
[       OK ] LlvmLibcDivTest.RangeErrors (33 us)
[ RUN      ] LlvmLibcDivTest.InexactResults
[       OK ] LlvmLibcDivTest.InexactResults (2 us)
Ran 5 tests.  PASS: 5  FAIL: 0
[771/1023] Running unit test libc.test.src.math.smoke.fabsf_test.__unit__.__NO_MISC_MATH_BASIC_OPS_OPT
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFAbsTest.SpecialNumbers
[       OK ] LlvmLibcFAbsTest.SpecialNumbers (8 us)
Ran 1 tests.  PASS: 1  FAIL: 0
[772/1023] Running unit test libc.test.src.math.smoke.fma_test.__unit__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcFmaTest.SpecialNumbers

@harrisonGPU harrisonGPU deleted the libcAcoshf16 branch March 23, 2025 02:49
@lntue
Copy link
Contributor

lntue commented Mar 23, 2025

@harrisonGPU aarch64 failure:

FAILED: libc/test/src/math/smoke/CMakeFiles/libc.test.src.math.smoke.acoshf16_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/libc/test/src/math/smoke && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/libc/test/src/math/smoke/libc.test.src.math.smoke.acoshf16_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcAcoshf16Test.SpecialNumbers
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/test/src/math/smoke/acoshf16_test.cpp:22: FAILURE
      Expected: __llvm_libc_20_0_0_git::fputil::test_except( static_cast<int>((0x1 | 0x2 | 0x4 | 0x8 | 0x10))) & ((0x4) ? (0x4) : static_cast<int>((0x1 | 0x2 | 0x4 | 0x8 | 0x10)))
      Which is: 0
To be equal to: (0x4)
      Which is: 4

Can you investigate to see if it can be fixed quickly, or temporarily disable the assertion statement if you need more time?

@harrisonGPU
Copy link
Contributor Author

harrisonGPU commented Mar 23, 2025

@harrisonGPU aarch64 failure:

FAILED: libc/test/src/math/smoke/CMakeFiles/libc.test.src.math.smoke.acoshf16_test.__unit__ 
cd /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/libc/test/src/math/smoke && /home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/build/libc/test/src/math/smoke/libc.test.src.math.smoke.acoshf16_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcAcoshf16Test.SpecialNumbers
/home/libc-buildbot/libc-aarch64-ubuntu/libc-aarch64-ubuntu-fullbuild-dbg/llvm-project/libc/test/src/math/smoke/acoshf16_test.cpp:22: FAILURE
      Expected: __llvm_libc_20_0_0_git::fputil::test_except( static_cast<int>((0x1 | 0x2 | 0x4 | 0x8 | 0x10))) & ((0x4) ? (0x4) : static_cast<int>((0x1 | 0x2 | 0x4 | 0x8 | 0x10)))
      Which is: 0
To be equal to: (0x4)
      Which is: 4

Can you investigate to see if it can be fixed quickly, or temporarily disable the assertion statement if you need more time?

I will try to investigate this failing test, and for now, I have temporarily disabled it. #132580

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment