[all-commits] [llvm/llvm-project] 16903a: [libc][math] Implement double precision sin correc...

lntue via All-commits all-commits at lists.llvm.org
Mon Jun 24 14:57:29 PDT 2024


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 16903ace180755b7558234ff2b2e8d89b00dcb88
      https://github.com/llvm/llvm-project/commit/16903ace180755b7558234ff2b2e8d89b00dcb88
  Author: lntue <35648136+lntue at users.noreply.github.com>
  Date:   2024-06-24 (Mon, 24 Jun 2024)

  Changed paths:
    M libc/config/darwin/arm/entrypoints.txt
    M libc/config/linux/aarch64/entrypoints.txt
    M libc/config/linux/arm/entrypoints.txt
    M libc/config/linux/riscv/entrypoints.txt
    M libc/docs/math/index.rst
    M libc/src/__support/FPUtil/double_double.h
    M libc/src/__support/FPUtil/dyadic_float.h
    M libc/src/__support/macros/optimization.h
    M libc/src/math/generic/CMakeLists.txt
    A libc/src/math/generic/range_reduction_double_common.h
    A libc/src/math/generic/range_reduction_double_fma.h
    A libc/src/math/generic/range_reduction_double_nofma.h
    A libc/src/math/generic/sin.cpp
    A libc/src/math/generic/sincos_eval.h
    M libc/src/math/x86_64/CMakeLists.txt
    R libc/src/math/x86_64/sin.cpp
    M libc/test/src/math/sin_test.cpp
    M libc/test/src/math/smoke/CMakeLists.txt
    A libc/test/src/math/smoke/sin_test.cpp

  Log Message:
  -----------
  [libc][math] Implement double precision sin correctly rounded to all rounding modes. (#95736)

- Algorithm:
- Step 1 - Range reduction: for a double precision input `x`, return `k`
and `u` such that
    - k is an integer
    - u = x - k * pi / 128, and |u| < pi/256
- Step 2 - Calculate `sin(u)` and `cos(u)` in double-double using Taylor
polynomials with errors < 2^-70 with FMA or < 2^-66 w/o FMA.
- Step 3 - Calculate `sin(x) = sin(k*pi/128) * cos(u) + cos(k*pi/128) *
sin(u)` using look-up table for `sin(k*pi/128)` and `cos(k*pi/128)`.
- Step 4 - Use Ziv's rounding test to decide if the result is correctly
rounded.
- Step 4' - If the Ziv's rounding test failed, redo step 1-3 using
128-bit precision.
- Currently, without FMA instructions, the large range reduction only
works correctly for the default rounding mode (FE_TONEAREST).
- Provide `LIBC_MATH` flag so that users can set `LIBC_MATH =
LIBC_MATH_SKIP_ACCURATE_PASS` to build the `sin` function without step 4
and 4'.



To unsubscribe from these emails, change your notification settings at https://github.com/llvm/llvm-project/settings/notifications


More information about the All-commits mailing list