[libc-commits] [PATCH] D127046: [libc][math] fmod/fmodf implementation.

Kirill Okhotnikov via Phabricator via libc-commits libc-commits at lists.llvm.org
Sat Jun 4 04:29:38 PDT 2022


orex created this revision.
orex added reviewers: michaelrj, lntue.
Herald added subscribers: libc-commits, ecnelises, tschuett, mgorny.
Herald added projects: libc-project, All.
orex edited the summary of this revision.
orex published this revision for review.

This is a implementation of find remainder fmod function from standard libm.
The underline algorithm is developed by myself, but probably it was first 
invented before. 
Some features of the implementation:

1. The code is written on more-or-less modern C++.
2. One general implementation for both float and double precision numbers.
3. Spitted platform/architecture dependent and independent code and tests.
4. Tests covers 100% of the code for both float and double numbers. Tests cases with NaN/Inf etc is copied from glibc.
5. The new implementation in general 2-4 times faster for “regular” x,y values. It can be 20 times faster for x/y huge value, but can also be 2 times slower for double denormalized range (according to perf tests provided).
6. Two different implementation of division loop are provided. In some platforms division can be very time consuming operation. Depend on platform it can be 3-10 times slower than multiplication.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D127046

Files:
  libc/config/darwin/arm/entrypoints.txt
  libc/config/linux/aarch64/entrypoints.txt
  libc/config/linux/x86_64/entrypoints.txt
  libc/config/windows/entrypoints.txt
  libc/spec/stdc.td
  libc/src/__support/FPUtil/FPBits.h
  libc/src/__support/FPUtil/FloatProperties.h
  libc/src/__support/FPUtil/generic/CMakeLists.txt
  libc/src/__support/FPUtil/generic/FMod.h
  libc/src/__support/FPUtil/generic/sqrt.h
  libc/src/math/CMakeLists.txt
  libc/src/math/fmod.h
  libc/src/math/fmodf.h
  libc/src/math/generic/CMakeLists.txt
  libc/src/math/generic/fmod.cpp
  libc/src/math/generic/fmodf.cpp
  libc/test/src/math/CMakeLists.txt
  libc/test/src/math/FModTest.h
  libc/test/src/math/differential_testing/BinaryOpSingleOutputDiff.h
  libc/test/src/math/differential_testing/CMakeLists.txt
  libc/test/src/math/differential_testing/fmod_diff.cpp
  libc/test/src/math/differential_testing/fmod_perf.cpp
  libc/test/src/math/differential_testing/fmodf_diff.cpp
  libc/test/src/math/differential_testing/fmodf_perf.cpp
  libc/test/src/math/exhaustive/CMakeLists.txt
  libc/test/src/math/exhaustive/FMod_test.cpp
  libc/test/src/math/fmod_test.cpp
  libc/test/src/math/fmodf_test.cpp
  libc/utils/MPFRWrapper/MPFRUtils.cpp
  libc/utils/MPFRWrapper/MPFRUtils.h

-------------- next part --------------
A non-text attachment was scrubbed...
Name: D127046.434258.patch
Type: text/x-patch
Size: 51233 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/libc-commits/attachments/20220604/74879f52/attachment-0001.bin>


More information about the libc-commits mailing list