[all-commits] [llvm/llvm-project] 5ee978: [libc][math] Improve the performance of sqrtf128. ...

lntue via All-commits all-commits at lists.llvm.org
Thu Feb 13 14:50:14 PST 2025


  Branch: refs/heads/main
  Home:   https://github.com/llvm/llvm-project
  Commit: 5ee97877308e8617a2c42bb120f0a90e594eba31
      https://github.com/llvm/llvm-project/commit/5ee97877308e8617a2c42bb120f0a90e594eba31
  Author: lntue <lntue at google.com>
  Date:   2025-02-13 (Thu, 13 Feb 2025)

  Changed paths:
    M libc/src/__support/big_int.h
    M libc/src/math/generic/CMakeLists.txt
    M libc/src/math/generic/sqrtf128.cpp
    M libc/test/UnitTest/FPMatcher.h
    M libc/test/src/math/SqrtTest.h
    M libc/test/src/math/performance_testing/CMakeLists.txt
    A libc/test/src/math/performance_testing/sqrtf128_perf.cpp
    M libc/test/src/math/smoke/SqrtTest.h
    M libc/test/src/math/smoke/generic_sqrt_test.cpp
    M libc/test/src/math/smoke/generic_sqrtf128_test.cpp
    M libc/test/src/math/smoke/generic_sqrtf_test.cpp
    M libc/test/src/math/smoke/generic_sqrtl_test.cpp
    M libc/test/src/math/smoke/sqrt_test.cpp
    M libc/test/src/math/smoke/sqrtf128_test.cpp
    M libc/test/src/math/smoke/sqrtf16_test.cpp
    M libc/test/src/math/smoke/sqrtf_test.cpp
    M libc/test/src/math/smoke/sqrtl_test.cpp

  Log Message:
  -----------
  [libc][math] Improve the performance of sqrtf128. (#122578)

Use a combination of polynomial approximation and Newton-Raphson
iterations in 64-bit and 128-bit integers to improve the performance of
sqrtf128. The correct rounding is provided by squaring the result and
comparing it with the argument.

Performance improvement using the newly added perf test:
- My function = the improved implementation from this PR
- Other function = current implementation using
`libc/src/__support/FPUtil/generic/sqrt.h`
```
 Performance tests with inputs in denormal range:
-- My function --
     Total time      : 1260765265 ns 
     Average runtime : 125.951 ns/op 
     Ops per second  : 7939623 op/s 
-- Other function --
     Total time      : 7160726518 ns 
     Average runtime : 715.357 ns/op 
     Ops per second  : 1397902 op/s 
-- Average runtime ratio --
     Mine / Other's  : 0.176067 

 Performance tests with inputs in normal range:
-- My function --
     Total time      : 373003808 ns 
     Average runtime : 37.2631 ns/op 
     Ops per second  : 26836189 op/s 
-- Other function --
     Total time      : 7353398916 ns 
     Average runtime : 734.605 ns/op 
     Ops per second  : 1361275 op/s 
-- Average runtime ratio --
     Mine / Other's  : 0.0507254 
```

---------

Co-authored-by: Alexei Sibidanov <sibid at uvic.ca>



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