OverMighty
edbe698ead
[libc][math][c23] Add f16divf C23 math function ( #96131 )
...
Part of #93566 .
2024-06-25 08:48:28 -04:00
lntue
16903ace18
[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'.
2024-06-24 17:57:08 -04:00
OverMighty
b5efd21429
[libc][math][c23] Add {ldexp,scalbn,scalbln}f16 C23 math functions ( #94797 )
...
Part of #93566 .
2024-06-21 09:01:47 -04:00
OverMighty
1107575c95
[libc][math][c23] Add {getpayload,setpayload,setpayloadsig}f16 C23 math functions ( #95159 )
...
Part of #93566 .
2024-06-20 13:33:34 -04:00
OverMighty
f3aceeee8a
[libc][math][c23] Add f16fmaf C23 math function ( #95483 )
...
Part of #93566 .
2024-06-14 12:31:32 -04:00
OverMighty
a239343521
[libc][math][c23] Add f16sqrtf C23 math function ( #95251 )
...
Part of #95250 .
2024-06-13 12:57:24 -04:00
OverMighty
f5dcfb9968
[libc][math][c23] Add {totalorder,totalordermag}f16 C23 math functions ( #95014 )
...
Part of #93566 .
2024-06-11 11:04:48 -04:00
OverMighty
7683a16dbf
[libc][math][c23] Add {remainder,remquo}f16 C23 math functions ( #94773 )
...
Part of #93566 .
2024-06-10 11:02:09 -04:00
OverMighty
10cd96dd33
[libc][math][c23] Add {frexp,ilogb,llogb,logb,modf}f16 C23 math functions ( #94758 )
...
Part of #93566 .
2024-06-10 08:38:47 -04:00
OverMighty
cb1a727dea
[libc][math][c23] Add nanf16 C23 math function ( #94767 )
...
Part of #93566 .
2024-06-10 00:19:22 -04:00
Hendrik Hübner
44aecca020
[libc][math][C23] Implemented remquof128 function ( #94809 )
...
Added remquof128 function. Closes #94312
2024-06-08 15:08:45 -04:00
Job Henandez Lara
263be9fb00
[libc][math][c23] fmul correcly rounded to all rounding modes ( #91537 )
...
This is an implementation of floating point multiplication:
It will consist of
- `double x double -> float`
2024-06-08 15:07:27 -04:00
OverMighty
0cdb0b7473
[libc][math][c23] Add fmodf16 C23 math function ( #94629 )
...
Part of #93566 .
2024-06-07 18:26:58 -04:00
OverMighty
dd1cd02a43
[libc][math][c23] Add {fmaximum,fminimum}{,_mag,_mag_num,_num} C23 math functions ( #94510 )
...
#93566
2024-06-06 11:20:29 -04:00
OverMighty
63cda2d19c
[libc][math][c23] Add {nextafter,nexttoward,nextup,nextdown}f16 C23 math functions ( #94535 )
...
#93566
2024-06-05 23:06:48 -04:00
Hendrik Hübner
8e67495326
[libc][math][c23] Implement fmaxf16 and fminf16 function ( #94131 )
...
Implements fmaxf16 and fminf16, which are two missing functions listed
here: #93566
2024-06-05 22:44:44 -04:00
OverMighty
c537f35646
[libc][math][c23] Add fdimf16 C23 math function ( #94354 )
...
#93566
2024-06-05 10:37:55 -04:00
OverMighty
6c97303681
[libc][math][c23] Add copysignf16 C23 math function ( #94351 )
...
#93566
2024-06-05 09:46:36 -04:00
OverMighty
3614beede1
[libc][math][c23] Add canonicalizef16 C23 math function ( #94341 )
...
#93566
2024-06-05 08:24:23 -04:00
OverMighty
6b5ae148e5
[libc][math][c23] Add {fromfp,fromfpx,ufromfp,ufromfpx}f16 C23 math functions ( #94254 )
...
https://github.com/llvm/llvm-project/issues/93566
2024-06-04 18:29:53 -04:00
OverMighty
2635d0419e
[libc][math][c23] Add {nearbyint,rint,lrint,llrint,lround,llround}f16 C23 math functions ( #94218 )
...
https://github.com/llvm/llvm-project/issues/93566
2024-06-04 10:03:31 -04:00
OverMighty
25b037bdb5
[libc][math][c23] Add {ceil,floor,round,roundeven,trunc}f16 C23 math functions ( #94001 )
2024-06-03 14:28:51 -04:00
OverMighty
0eb9e021b1
[libc][math][c23] Add fabsf16 C23 math function ( #93567 )
...
cc @lntue
2024-05-30 15:37:15 -04:00
Michael Flanders
5e9937d1b3
[libc][math] Adds entrypoint and tests for nearbyintf128,scalbnf128 ( #88443 )
...
Closes #84689 .
Adding @lntue for review.
I was curious about the implementation of
`round_using_current_rounding_mode` used for the `nearbyint` functions.
It has one of the rounding modes as unreachable
([here](https://github.com/llvm/llvm-project/blob/main/libc/src/__support/FPUtil/NearestIntegerOperations.h#L243 )),
and I was wondering if this was okay for the `nearbyint` functions.
---------
Co-authored-by: Michael Flanders <mkf727@cs.washington.edu >
2024-04-29 19:25:45 -04:00
Vinayak Dev
3b961d113e
[libc] Implement roundeven C23 math functions ( #87678 )
...
Implements the functions `roundeven()`, `roundevenf()`, `roundevenl()`
from the roundeven family of functions introduced in C23. Also
implements `roundevenf128()`.
2024-04-05 08:36:12 -04:00
OverMighty
a8c59750d9
[libc][math][c23] Add exp2m1f C23 math function ( #86996 )
...
Fixes #86502 .
cc @lntue
2024-04-04 08:22:45 -04:00
Vinayak Dev
986435c765
[libc] Move {f,d}sqrt to higher functions in docs ( #87445 )
...
Moves the functions `fsqrt()` and `dsqrt()` from basic functions to
higher math functions in math docs
2024-04-02 22:39:48 -04:00
Vinayak Dev
2fb5440e76
[libc] Re-organize the math function tables in docs ( #87412 )
...
Re-organizes the tables that listed libc's support for math functions,
and adds two new columns to the tables indicating where the respective
function definitions and error handling methods are located in the C23
standard draft WG14-N3096.
2024-04-02 22:23:35 -04:00
lntue
2be722587f
[libc][math] Implement atan2f correctly rounded to all rounding modes. ( #86716 )
...
We compute atan2f(y, x) in 2 stages:
- Fast step: perform computations in double precision , with relative
errors < 2^-50
- Accurate step: if the result from the Fast step fails Ziv's rounding
test, then we perform computations in double-double precision, with
relative errors < 2^-100.
On Ryzen 5900X, worst-case latency is ~ 200 clocks, compared to average
latency ~ 60 clocks, and average reciprocal throughput ~ 20 clocks.
2024-04-01 13:31:07 -04:00
Nick Desaulniers
8a071678a9
Revert "[libc][math][c23] Add remaining linux/* entrypoints for {,u}fromfp{,x}* ( #86692 )"
...
This reverts commit cd17082b24 because the newly
added tests fail on 32b ARM.
Link: #86692
Link: https://lab.llvm.org/buildbot/#/builders/229/builds/24458
2024-03-27 13:28:26 -07:00
OverMighty
cd17082b24
[libc][math][c23] Add remaining linux/* entrypoints for {,u}fromfp{,x}* ( #86692 )
2024-03-27 12:28:27 -07:00
Shourya Goel
19ca79e867
[libc][math][c23] Implement canonicalize functions ( #85940 )
...
Fixes : #85286
2024-03-26 08:28:22 -04:00
OverMighty
b282259711
[libc][math][c23] Add {,u}fromfp{,x}{,f,l,f128} functions ( #86003 )
...
Fixes #85279 .
cc @lntue
2024-03-25 10:26:22 -04:00
OverMighty
85b6af198f
[libc][math][c23] Add linux/* entrypoints for nextup* and nextdown* ( #85803 )
...
See
https://github.com/llvm/llvm-project/pull/85484#discussion_r1526971653 .
There already were entrypoints for linux/x86_64. I haven't tested on the other
targets and will rely on the buildbots.
2024-03-19 12:47:01 -07:00
OverMighty
a2bad75879
[libc][math][c23] Add nextupl and nextdownl functions ( #85484 )
...
Fixes #85283 .
cc @lntue
2024-03-16 17:21:07 -04:00
Michael Flanders
b43965adac
[libc][math][c23] adds nanf128 ( #85201 )
...
Continuing #84689 , this one required more changes than the others, so I
am making it a separate PR.
Extends some stuff in `str_to_float.h`, `str_to_integer.h` to work on
types wider than `unsigned long long` and `uint64_t`.
cc @lntue for review.
2024-03-15 13:31:50 -04:00
Michael Flanders
15a55486a5
[libc][math] Adds entrypoint and test for nextafterf128 ( #84882 )
2024-03-12 23:25:05 -04:00
lntue
4d21e75210
[libc][math][c23] Add fmodl and fmodf128 math functions. ( #84600 )
...
- Allow `FMod` template to have different computational types and make
it work for 80-bit long double.
- Switch to use `uint64_t` as the intermediate computational types for
`float`, significantly reduce the latency of `fmodf` when the exponent
difference is large.
2024-03-11 16:27:42 -04:00
lntue
d99bb01422
[libc][NFC] Clean up test/src/math/differential_testing folder, renaming it to performance_testing. ( #84646 )
...
Removing all the diff tests.
2024-03-11 11:38:39 -04:00
lntue
99f5e9634b
[libc][math][c23] Add modff128 C23 math function. ( #84532 )
2024-03-09 11:47:22 -05:00
lntue
60d7bf3dbe
[libc][math][c23] Add (l|ll)rintf128 and (l|ll)roundf128 math functions. ( #84504 )
2024-03-08 12:15:02 -05:00
lntue
14171b87a3
[libc][stdfix] Add exp function for short _Accum and _Accum types. ( #84391 )
2024-03-07 17:58:28 -05:00
lntue
ad33fe1281
[libc][stdfix] Add integer square root with fixed point output functions. ( #83959 )
...
Fix https://github.com/llvm/llvm-project/issues/83924 .
2024-03-06 18:35:44 -05:00
lntue
aa95aa69b9
[libc][math][c23] Add C23 math functions ilogbf128, logbf128, and llogb(f|l|f128). ( #82144 )
2024-02-27 12:23:19 -05:00
lntue
ded4ea9752
[libc][stdfix] Add sqrt for fixed point types. ( #83042 )
2024-02-26 19:36:30 -05:00
Joseph Huber
69c0b2febe
[libc][NFC] Remove all trailing spaces from libc ( #82831 )
...
Summary:
There are a lot of random training spaces on various lines. This patch
just got rid of all of them with `sed 's/\ \+$//g'.
2024-02-23 16:34:00 -06:00
lntue
f01ed3bc88
[libc][stdfix] Add round functions for fixed point types. ( #81994 )
2024-02-16 12:45:26 -05:00
lntue
2c45bda802
[libc][stdfix] Add abs functions for signed fixed point types. ( #81823 )
2024-02-15 18:09:40 -05:00
lntue
ff409d39ce
[libc][math] Add C23 ldexpf128 math function and fix DyadicFloat conversions for subnormal ranges and 80-bit floating points. ( #81780 )
2024-02-14 21:35:00 -05:00
lntue
84277fe90f
[libc][stdfix] Generate stdfix.h header with fixed point precision macros according to ISO/IEC TR 18037:2008 standard, and add fixed point type support detection. ( #81255 )
...
Fixed point extension standard:
https://standards.iso.org/ittf/PubliclyAvailableStandards/c051126_ISO_IEC_TR_18037_2008.zip
2024-02-13 16:48:14 -05:00