[libc-commits] [libc] [libc][math][c23] Implement higher math function `cbrtf16` in LLVM libc (PR #132484)

Krishna Pandey via libc-commits libc-commits at lists.llvm.org
Fri Mar 21 16:39:37 PDT 2025


krishna2803 wrote:

uh oh nvm we do have a failure for _some_ $x > 1.0$ as well:
```
[3/3] Running unit test libc.test.src.math.cbrtf16_test.__unit__
FAILED: libc/test/src/math/CMakeFiles/libc.test.src.math.cbrtf16_test.__unit__ /home/krishna/OpenSource/llvm-project/build/libc/test/src/math/CMakeFiles/libc.test.src.math.cbrtf16_test.__unit__ 
cd /home/krishna/OpenSource/llvm-project/build/libc/test/src/math && /home/krishna/OpenSource/llvm-project/build/libc/test/src/math/libc.test.src.math.cbrtf16_test.__unit__.__build__
[==========] Running 1 test from 1 test suite.
[ RUN      ] LlvmLibcCbrtf16Test.PositiveRange
/home/krishna/OpenSource/llvm-project/libc/test/src/math/cbrtf16_test.cpp:33: FAILURE
Failed to match __llvm_libc_21_0_0_git::cbrtf16(x) against LIBC_NAMESPACE::testing::mpfr::get_mpfr_matcher<mpfr::Operation::Cbrt>( x, __llvm_libc_21_0_0_git::cbrtf16(x), 0.5, mpfr::RoundingMode::Upward).
Match value not within tolerance value of MPFR result:
  Input decimal: 3.16210937500000000000000000000000000000000000000000
     Input bits: 0x4253 = (S: 0, E: 0x0010, M: 0x0253)

  Match decimal: 1.46875000000000000000000000000000000000000000000000
     Match bits: 0x3DE0 = (S: 0, E: 0x000F, M: 0x01E0)

    MPFR result: 1.46777343750000000000000000000000000000000000000000
   MPFR rounded: 0x3DDF = (S: 0, E: 0x000F, M: 0x01DF)

      ULP error: 1.00000000000000000000000000000000000000000000000000
/home/krishna/OpenSource/llvm-project/libc/test/src/math/cbrtf16_test.cpp:33: FAILURE
Failed to match __llvm_libc_21_0_0_git::cbrtf16(x) against LIBC_NAMESPACE::testing::mpfr::get_mpfr_matcher<mpfr::Operation::Cbrt>( x, __llvm_libc_21_0_0_git::cbrtf16(x), 0.5, mpfr::RoundingMode::Upward).
Match value not within tolerance value of MPFR result:
  Input decimal: 25.29687500000000000000000000000000000000000000000000
     Input bits: 0x4E53 = (S: 0, E: 0x0013, M: 0x0253)

  Match decimal: 2.93750000000000000000000000000000000000000000000000
     Match bits: 0x41E0 = (S: 0, E: 0x0010, M: 0x01E0)

    MPFR result: 2.93554687500000000000000000000000000000000000000000
   MPFR rounded: 0x41DF = (S: 0, E: 0x0010, M: 0x01DF)

      ULP error: 1.00000000000000000000000000000000000000000000000000
/home/krishna/OpenSource/llvm-project/libc/test/src/math/cbrtf16_test.cpp:33: FAILURE
Failed to match __llvm_libc_21_0_0_git::cbrtf16(x) against LIBC_NAMESPACE::testing::mpfr::get_mpfr_matcher<mpfr::Operation::Cbrt>( x, __llvm_libc_21_0_0_git::cbrtf16(x), 0.5, mpfr::RoundingMode::Upward).
Match value not within tolerance value of MPFR result:
  Input decimal: 202.37500000000000000000000000000000000000000000000000
     Input bits: 0x5A53 = (S: 0, E: 0x0016, M: 0x0253)

  Match decimal: 5.87500000000000000000000000000000000000000000000000
     Match bits: 0x45E0 = (S: 0, E: 0x0011, M: 0x01E0)

    MPFR result: 5.87109375000000000000000000000000000000000000000000
   MPFR rounded: 0x45DF = (S: 0, E: 0x0011, M: 0x01DF)

      ULP error: 1.00000000000000000000000000000000000000000000000000
/home/krishna/OpenSource/llvm-project/libc/test/src/math/cbrtf16_test.cpp:33: FAILURE
Failed to match __llvm_libc_21_0_0_git::cbrtf16(x) against LIBC_NAMESPACE::testing::mpfr::get_mpfr_matcher<mpfr::Operation::Cbrt>( x, __llvm_libc_21_0_0_git::cbrtf16(x), 0.5, mpfr::RoundingMode::Upward).
Match value not within tolerance value of MPFR result:
  Input decimal: 1619.00000000000000000000000000000000000000000000000000
     Input bits: 0x6653 = (S: 0, E: 0x0019, M: 0x0253)

  Match decimal: 11.75000000000000000000000000000000000000000000000000
     Match bits: 0x49E0 = (S: 0, E: 0x0012, M: 0x01E0)

    MPFR result: 11.74218750000000000000000000000000000000000000000000
   MPFR rounded: 0x49DF = (S: 0, E: 0x0012, M: 0x01DF)

      ULP error: 1.00000000000000000000000000000000000000000000000000
/home/krishna/OpenSource/llvm-project/libc/test/src/math/cbrtf16_test.cpp:33: FAILURE
Failed to match __llvm_libc_21_0_0_git::cbrtf16(x) against LIBC_NAMESPACE::testing::mpfr::get_mpfr_matcher<mpfr::Operation::Cbrt>( x, __llvm_libc_21_0_0_git::cbrtf16(x), 0.5, mpfr::RoundingMode::Upward).
Match value not within tolerance value of MPFR result:
  Input decimal: 12952.00000000000000000000000000000000000000000000000000
     Input bits: 0x7253 = (S: 0, E: 0x001C, M: 0x0253)

  Match decimal: 23.50000000000000000000000000000000000000000000000000
     Match bits: 0x4DE0 = (S: 0, E: 0x0013, M: 0x01E0)

    MPFR result: 23.48437500000000000000000000000000000000000000000000
   MPFR rounded: 0x4DDF = (S: 0, E: 0x0013, M: 0x01DF)

      ULP error: 1.00000000000000000000000000000000000000000000000000
[  FAILED  ] LlvmLibcCbrtf16Test.PositiveRange
Ran 1 tests.  PASS: 0  FAIL: 1
ninja: build stopped: subcommand failed.
```

https://github.com/llvm/llvm-project/pull/132484


More information about the libc-commits mailing list