[libc][math] Tracking Issue - Refactor Higher Math Functions to Header Only
This is tracking issue to refactor all higher math functions in single and double precision currently implemented in LLVM libc to be header-only.
Status:
-
[x] acos
- [x] acos #148409
- [x] acosf16 #148412
- [x] acosf #148411
-
[x] acosh
- [x] acoshf16 #148568
- [x] acoshf #148418
-
[ ] acospi
- [ ] acospi
- [x] acospif #183661
- [x] acospif16 #148574
-
[x] asin
- [x] asin #148578
- [x] asinf16 #150800
- [x] asinf #150697
-
[x] asinh
- [x] asinhf16 #150849
- [x] asinhf #150843
-
[ ] asinpi
- [ ] asinpi
- [x] asinpif #181511
- [x] asinpif16 #178103
-
[x] atan
- [x] atan #150852
- [x] atanf16 #150868
- [x] atanf #150854
-
[x] atan2
- [x] atan2 #150968
- [x] atan2f128 #151012
- [x] atan2f #150993
- [ ] atan2l
-
[ ] ~atan2pi~
-
[x] atanh
- [x] atanhf16 #151779
- [x] atanhf #151399
-
[ ] ~atanpi~
- [x] atanpif16 #178105
-
[x] bf16add #181016
- [x] bf16addf #181017
- [x] bf16addf128 #181018
- [x] bf16addl #181019
-
[x] bf16div #181022
- [x] bf16divf #181023
- [x] bf16divf128 #181024
- [x] bf16divl #181025
-
[x] bf16mul #182017
- [x] bf16mul
- [x] bf16mulf
- [x] bf16mulf128
- [x] bf16mull
-
[x] bf16sub #182114
- [x] bf16sub
- [x] bf16subf
- [x] bf16subf128
- [x] bf16subl
-
[x] bf16fma
- [x] bf16fma #181625
- [x] bf16fmaf #181626
- [x] bf16fmaf128 #181627
- [x] bf16fmal #181628
-
[x] cbrt
- [x] cbrt #151837
- [x] cbrtf #151846
-
[x] ceil #182120
- [x] ceil
- [x] ceilbf16
- [x] ceilf
- [x] ceilf128
- [x] ceilf16
- [x] ceill
-
[ ] ~compoundn~
-
[x] copysign #182136
- [x] copysign
- [x] copysignbf16
- [x] copysignf
- [x] copysignf128
- [x] copysignf16
- [x] copysignl
-
[x] cos
- [x] cos #151883
- [x] cosf16 #152871
- [x] cosf #152069
-
[x] cosh
- [x] coshf16 #153582
- [x] coshf #153427
-
[x] cospi
- [x] cospif16 #154222
- [x] cospif #154215
-
[x] dadd #182141
- [x] daddf128
- [x] daddl
-
[x] ddiv #182148
- [x] ddivf128
- [x] ddivl
-
[x] dmul #182150
- [x] dmulf128
- [x] dmull
-
[x] dsqrt
- [x] dsqrtf128
- [x] dsqrtl #154868
-
[x] dsub #182159
- [x] dsubf128
- [x] dsubl
-
[X] erff #148413
-
[ ] ~erfc~
-
[X] exp #148091
- [X] expf #143790
- [x] expf16 #147428
- [x] frexpf128 #147822
- [x] frexpf16 #147889
- [x] frexpf #147893
- [x] ldexpf128 #147895
- [x] ldexpf16 #147901
- [x] ldexpf #147906
-
[x] exp10
- [X] exp10 #148400
- [x] exp10f16 #148408
- [x] exp10f #148405
-
[x] exp10m1
- [x] exp10m1f16 #161119
- [x] exp10m1f #159897
-
[x] exp2
- [x] exp2f16 #161993
- [x] exp2f #161992
- [x] exp2 #161297
-
[x] exp2m1
- [x] exp2m1f16 #162019
- [x] exp2m1f #162017
-
[x] expm1
- [x] expm1f16 #162132
- [x] expm1f #162131
- [x] expm1 #162127
-
[x] f16add #181744
- [x] f16add
- [x] f16addf
- [x] f16addf128
- [x] f16addl
-
[x] f16div #181744
- [x] f16div
- [x] f16divf
- [x] f16divf128
- [x] f16divl
-
[x] f16mul #181744
- [x] f16mul
- [x] f16mulf
- [x] f16mulf128
- [x] f16mull
-
[x] f16sub #181744
- [x] f16sub
- [x] f16subf
- [x] f16subf128
- [x] f16subl
-
[ ] fabs #182172
- [ ] fabs
- [ ] fabsbf16
- [ ] fabsf
- [ ] fabsf128
- [ ] fabsf16
- [ ] fabsl
-
[x] fadd #182193
- [x] fadd
- [x] faddf128
- [x] faddl
-
[x] fdim #182188
- [x] fdim
- [x] fdimbf16
- [x] fdimf
- [x] fdimf128
- [x] fdimf16
- [x] fdiml
-
[ ] fdiv #182191
- [ ] fdiv
- [ ] fdivf128
- [ ] fdivl
-
[x] floor #182184
- [x] floor
- [x] floorbf16
- [x] floorf
- [x] floorf128
- [x] floorf16
- [x] floorl
-
[x] fma #175313
- [x] dfmaf128 #175315
- [x] dfmal #175316
- [x] f16fmaf128 #175318
- [x] f16fmaf #175319
- [x] f16fma #175320
- [x] f16fmal #175324
- [x] ffmaf128 #175325
- [x] ffma #175304
- [x] ffmal #175326
- [x] fmaf16 #163977
- [x] fmaf #163970
- [x] fma #163968
-
[x] fmax https://github.com/llvm/llvm-project/issues/182164
- [x] fmax
- [x] fmaxbf16
- [x] fmaxf
- [x] fmaxf128
- [x] fmaxf16
- [x] fmaxl
-
[x] fmaximum_mag_num https://github.com/llvm/llvm-project/issues/182168
- [x] fmaximum_mag_num
- [x] fmaximum_mag_numbf16
- [x] fmaximum_mag_numf
-
[x] f16sqrt #175327
- [x] f16sqrtf128 #175328
- [x] f16sqrtf #175329
- [x] f16sqrt #175330
- [x] f16sqrtl #175331
-
[x] fsqrt #175332
- [x] fsqrtf128 #175333
- [x] fsqrt #175334
- [x] fsqrtl #175335
-
[x] hypot #175336
- [x] hypotf16 #175337
- [x] hypotf #175338
- [x] hypot #175339
-
[x] lgamma #175340
- [x] lgamma #175341
- [x] lgamma_r #175343
-
[x] log #175344
- [x] ilogbf128 #175345
- [x] ilogbf16 #175346
- [x] ilogbf #175347
- [x] ilogb #175348
- [x] ilogbl #175349
- [x] llogbf128 #175350
- [x] llogbf16 #175351
- [x] llogbf #175354
- [x] llogb #175360
- [x] llogbl #175361
- [x] logbf128 #175362
- [x] logbf16 #175363
- [x] logbf #175364
- [x] logb #175365
- [x] logbl #175366
- [x] logf16 #175367
- [x] logf #175368
- [x] log #175369
-
[x] log10 #176506
- [x] log10f16 #176510
- [x] log10f #176511
- [x] log10 #176089
-
[ ] ~log10p1~
-
[x] log1p #176507
- [x] log1p #176089
- [x] log1pf #176512
-
[x] log2 #176508
- [x] log2f16 #176513
- [x] log2f #176514
- [x] log2 #176089
-
[ ] ~log2p1~
-
[ ] ~logp1~
-
[x] pow #176509
- [x] pow #176516
- [x] powf #176517
-
[ ] powi
- [ ] powi
- [ ] powif
-
[ ] ~pown~
-
[ ] ~powr~
-
[ ] ~rootn~
-
[x] rsqrt
- [x] rsqrtf
- [x] rsqrtf16
-
[x] sin
- [x] sin #175200
- [x] sinf16 #178062
- [x] sinf #177963
-
[x] sincos #177637
- [x] sincosf #177640
- [x] sincos #177638
-
[x] sinh #177642
- [x] sinhf16 #177645
- [x] sinhf #177644
- [x] sinh #177643
-
[x] sinpi #176475
- [ ] sinpi
- [x] sinpif #176477
- [x] sinpif16 #176476
-
[x] sqrt #177647
- [x] sqrtf128 #177652
- [x] sqrtf16 #177651
- [x] sqrtf #177649
- [x] sqrt #177648
- [ ] sqrtl
-
[x] tan
- [x] tanf16 #181523
- [x] tanf https://github.com/llvm/llvm-project/pull/177730
- [x] tan https://github.com/llvm/llvm-project/pull/177224
-
[x] tanh #178491
- [x] tanhf16 #178492
- [x] tanhf #178493
- [ ] tanh
-
[x] tanpif16 #181207
-
[ ] ~tgamma~
- [ ] ~tgamma~
- [ ] ~tgammaf~
-
[x] canonicalize
- [x] canonicalize #181466
- [x] canonicalizebf16
- [x] canonicalizef
- [x] canonicalizef128
- [x] canonicalizef16
- [x] canonicalizel
@lntue
@llvm/issue-subscribers-libc
Author: Muhammad Bassiouni (bassiounix)
Status:
- [ ] acos
- [ ] acosh
- [ ] acospi
- [ ] asin
- [ ] asinh
- [ ] asinpi
- [ ] atan
- [ ] atan2
- [ ] atan2pi
- [ ] atanh
- [ ] atanpi
- [ ] cbrt
- [ ] compoundn
- [ ] cos
- [ ] cosh
- [ ] cospi
- [ ] dsqrt
- [ ] erf
- [ ] erfc
- [ ] exp
- [X] expf #143790
- [ ] exp10
- [ ] exp10m1
- [ ] exp2
- [ ] exp2m1
- [ ] expm1
- [ ] fma
- [ ] f16sqrt
- [ ] fsqrt
- [ ] hypot
- [ ] lgamma
- [ ] log
- [ ] log10
- [ ] log10p1
- [ ] log1p
- [ ] log2
- [ ] log2p1
- [ ] logp1
- [ ] pow
- [ ] powi*
- [ ] pown
- [ ] powr
- [ ] rootn
- [ ] rsqrt
- [ ] sin
- [ ] sincos
- [ ] sinh
- [ ] sinpi
- [ ] sqrt
- [ ] tan
- [ ] tanh
- [ ] tanpi
- [ ] tgamma
@lntue
Hi!
This issue may be a good introductory issue for people new to working on LLVM. If you would like to work on this issue, your first steps are:
- Check that no other contributor is working on this issue. If someone is assigned to the issue or claimed to be working on it, ping the person. After one week without a response, the assignee may be changed.
- Leave a comment indicating that you are working on the issue, or just create a pull request after following the steps below. Mention this issue in the description of the pull request.
- Fix the issue locally.
- Run the test suite locally. Remember that the subdirectories under
test/create fine-grained testing targets, so you can e.g. usemake check-clang-astto only run Clang's AST tests. - Create a Git commit.
- Run
git clang-format HEAD~1to format your changes. - Open a pull request to the upstream repository on GitHub. Detailed instructions can be found in GitHub's documentation. Mention this issue in the description of the pull request.
If you have any further questions about this issue, don't hesitate to ask via a comment in the thread below.
@llvm/issue-subscribers-good-first-issue
Author: Muhammad Bassiouni (bassiounix)
Status:
- [x] acos
- [x] acos #148409
- [x] acosf16 #148412
- [x] acosf #148411
- [x] acosh
- [x] acoshf16 #148568
- [x] acoshf #148418
- [x] acospif16 #148574
- [x] asin
- [x] asin #148578
- [x] asinf16 #150800
- [x] asinf #150697
- [x] asinh
- [x] asinhf16 #150849
- [x] asinhf #150843
- [ ] ~asinpi~
- [x] atan
- [x] atan #150852
- [x] atanf16 #150868
- [x] atanf #150854
- [x] atan2
- [x] atan2 #150968
- [x] atan2f128 #151012
- [x] atan2f #150993
- [ ] ~atan2l~
- [ ] ~atan2pi~
- [x] atanh
- [x] atanhf16 #151779
- [x] atanhf #151399
- [ ] ~atanpi~
- [x] cbrt
- [x] cbrt #151837
- [x] cbrtf #151846
- [ ] ~compoundn~
- [x] cos
- [x] cos #151883
- [x] cosf16 #152871
- [x] cosf #152069
- [x] cosh
- [x] coshf16 #153582
- [x] coshf #153427
- [x] cospi
- [x] cospif16 #154222
- [x] cospif #154215
- [ ] dsqrt
- [ ] dsqrtf128
- [x] dsqrtl #154868
- [X] erff #148413
- [ ] ~erfc~
- [X] exp #148091
- [X] expf #143790
- [x] expf16 #147428
- [x] frexpf128 #147822
- [x] frexpf16 #147889
- [x] frexpf #147893
- [x] ldexpf128 #147895
- [x] ldexpf16 #147901
- [x] ldexpf #147906
- [x] exp10
- [X] exp10 #148400
- [x] exp10f16 #148408
- [x] exp10f #148405
- [x] exp10m1
- [x] exp10m1f16 #161119
- [x] exp10m1f #159897
- [x] exp2
- [x] exp2f16 #161993
- [x] exp2f #161992
- [x] exp2 #161297
- [x] exp2m1
- [x] exp2m1f16 #162019
- [x] exp2m1f #162017
- [x] expm1
- [x] expm1f16 #162132
- [x] expm1f #162131
- [x] expm1 #162127
- [ ] fma
- [ ] dfmaf128
- [ ] dfmal
- [ ] f16fmaf128
- [ ] f16fmaf
- [ ] f16fma
- [ ] f16fmal
- [ ] ffmaf128
- [ ] ffma #175304
- [ ] ffmal
- [x] fmaf16 #163977
- [x] fmaf #163970
- [x] fma #163968
- [ ] f16sqrt
- [ ] f16sqrtf128
- [ ] f16sqrtf
- [ ] f16sqrt
- [ ] f16sqrtl
- [ ] fsqrt
- [ ] fsqrtf128
- [ ] fsqrt
- [ ] fsqrtl
- [ ] hypot
- [ ] hypotf16
- [ ] hypotf
- [ ] hypot
- [ ] lgamma
- [ ] lgamma
- [ ] lgamma_r
- [ ] log
- [ ] ilogbf128
- [ ] ilogbf16
- [ ] ilogbf
- [ ] ilogb
- [ ] ilogbl
- [ ] llogbf128
- [ ] llogbf16
- [ ] llogbf
- [ ] llogb
- [ ] llogbl
- [ ] logbf128
- [ ] logbf16
- [ ] logbf
- [ ] logb
- [ ] logbl
- [ ] logf16
- [ ] logf
- [ ] log
- [ ] log10
- [ ] log10f16
- [ ] log10f
- [ ] log10
- [ ] ~log10p1~
- [ ] log1p
- [ ] log1p
- [ ] log1pf
- [ ] log2
- [ ] log2f16
- [ ] log2f
- [ ] log2
- [ ] ~log2p1~
- [ ] ~logp1~
- [ ] pow
- [ ] pow
- [ ] powf
- [ ] powi*
- [ ] powi
- [ ] powif
- [ ] ~pown~
- [ ] ~powr~
- [ ] ~rootn~
- [ ] ~rsqrt~
- [ ] sin
- [x] sin #175200
- [ ] sinf16
- [ ] sinf
- [ ] sincos
- [ ] sincosf
- [ ] sincos
- [ ] sinh
- [ ] sinhf16
- [ ] sinhf
- [ ] sinh
- [ ] sinpi
- [ ] sinpi
- [ ] sinpif
- [ ] sqrt
- [ ] sqrtf128
- [ ] sqrtf16
- [ ] sqrtf
- [ ] sqrt
- [ ] sqrtl
- [ ] tan
- [ ] tanf16
- [ ] tanf
- [ ] tan
- [ ] tanh
- [ ] tanhf16
- [ ] tanhf
- [ ] tanh
- [ ] tanpif16
- [ ] tgamma
- [ ] tgamma
- [ ] tgammaf
@lntue
Can I work on sinpi and sinpif? I check all sub issues and they seem to be still open?
looks like there's only sinpif and sinpif16.
Not seeing issues for sincos.
EDIT: it actually seems like a lot of these functions still don't have subissues, so some good targets. Are we mostly waiting for dependencies...?
Not seeing issues for sincos.
EDIT: it actually seems like a lot of these functions still don't have subissues, so some good targets. Are we mostly waiting for dependencies...?
If you would like to work on these just mention the function and I'd open an issue for you to work on.
Ok, sounds good. I have a branch that I believe is ready for sincosf here.
EDIT: I also have a new one for sincos here. @bassiounix I would love any feedback on these; I'd submit the issue myself but I'm unsure of the standard procedure with subissues in this context for LLVM.
I have been working on sinhf and sinhf16. I have a branch ready for sinhf here and sinhf16 here. I do not think there is a cpp for sinh as such.
@bassiounix - Could you create appropriate issues for these?
@bassiounix Hi! Could you open a sub-issue for sqrt and assign sqrtf and sqrtf16 to me? I’d be happy to handle those.
Hi @bassiounix , I would love to work on this issue
tgamma and tgammaf both seem to be returning a constant 0. Are these non-issues, or is there something I'm missing with these functions?
https://github.com/llvm/llvm-project/blob/a10062d675128fc03476ea01cb42d723701a6677/libc/src/math/nvptx/tgamma.cpp#L16 https://github.com/llvm/llvm-project/blob/a10062d675128fc03476ea01cb42d723701a6677/libc/src/math/amdgpu/tgamma.cpp#L16 https://github.com/llvm/llvm-project/blob/a10062d675128fc03476ea01cb42d723701a6677/libc/src/math/amdgpu/tgammaf.cpp#L16 https://github.com/llvm/llvm-project/blob/a10062d675128fc03476ea01cb42d723701a6677/libc/src/math/nvptx/tgammaf.cpp#L16
EDIT: on checking the blames, these seem to be explicitly not implemented.
Hi @bassiounix , I would love to work on this issue
Please mention the function you want to work on.
tgamma and tgammaf both seem to be returning a constant 0. Are these non-issues, or is there something I'm missing with these functions?
llvm-project/libc/src/math/nvptx/tgamma.cpp
Line 16 in a10062d
LLVM_LIBC_FUNCTION(double, tgamma, (double)) { return 0.0; }
llvm-project/libc/src/math/amdgpu/tgamma.cpp
Line 16 in a10062d
LLVM_LIBC_FUNCTION(double, tgamma, (double)) { return 0.0; }
llvm-project/libc/src/math/amdgpu/tgammaf.cpp
Line 16 in a10062d
LLVM_LIBC_FUNCTION(float, tgammaf, (float)) { return 0.0f; }
llvm-project/libc/src/math/nvptx/tgammaf.cpp
Line 16 in a10062d
LLVM_LIBC_FUNCTION(float, tgammaf, (float)) { return 0.0; } EDIT: on checking the blames, these seem to be explicitly not implemented.
We want to refactor the generic implementation (if exists).
We want to refactor the generic implementation (if exists).
Grepping through libc/src/math/generic for tgamma and tgammaf gives no results, I used those links as those were the only instances I saw of those functions in libc/src/math.
We want to refactor the generic implementation (if exists).
Grepping through
libc/src/math/genericfortgammaandtgammafgives no results, I used those links as those were the only instances I saw of those functions inlibc/src/math.
I'll investigate.
Those are not implemented yet, so you can safely ignore them.
@bassiounix Hi, could you please create a sub-issue for tanh? I'd like to take on tanhf and tanhf16 if that works.
updates: Here is my draft submit about tanfh which I have checked libc-math-unittests and libc-math-smoke-tests~
IMPORTANT: This refactor is on pause at the moment, we won't accept current or new PRs until the size issues on baremetal is resolved. Once it's resolved we will continue with your contributions.
Thank you all for understanding and patience! :)
We are so back! I need each and every current and new PRs to comply with these changes https://github.com/llvm/llvm-project/commit/823e3e001724ca2e93ce410a675f3b538f8a74b3
Please rebase your code onto main and modify your code accordingly, there are breaking (signature) changes which I need you all to make to your PRs.
Thank you!
Hi i'd like to work on tanpif16.