-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Remove openlibm #26434
Comments
Aren't we also convincing LLVM to call Openlibm instead of the system libm? |
Are we? I remember talking about it, but did we ever make that happen? |
I can't find any reference to it in the source code so we are probably not doing that and I just remember the same discussion. |
Could we get them to resolve to specific Julia methods? That would be ideal.
|
Ideally we should figure out a generic mechanism to have LLVM request a function be constant folded with the implementation we have available in the compiler. |
Speculating here, but it looks like it might be possible to use
`setAvailableWithName` after using `getLibFunc`
http://llvm.org/doxygen/TargetLibraryInfo_8h_source.html to force a
particular triple to use a different version of a library function (and it
might even allow us to insert vectorised versions?)
Also see https://github.com/llvm-mirror/llvm/blob/master/tools/llc/llc.cpp#L472-L478
|
I have code for |
@pkofod If you get the chance I recommend just opening PRs with your changes, and if you need to be away for a while, someone who knows what they're doing can push to the branch with any necessary changes if applicable. |
Regarding fastmath point, I have this PR still waiting for review: #24031. If it's good, I can add the missing functions |
@pkofod Would you be able to push through your PRs? Things like SpecialFunctions should be easy to update, and the fastmath could just fallback to the system libm initially perhaps? |
What do you mean? If I can pr the remaining, or if the existing can be be finished soon ? |
I was actually referring to bumping the existing ones if someone needs to review or do something about those. How far do you think we are from excising the remaining ones? |
The above checklist with no check marks makes it look like none of this is done which I'm fairly sure it not the case at this point. @pkofod, would you mind updating the checkmarks here? Should be very satisfying since everyone knows that getting to check the boxes is why people make check lists. |
Well, I think it might actually be quite accurate, as this was made after most of my prs were merged. The three open PRs are quite done as far as I remember, but I'm just waiting for feedback. I guess they have to be rebased by now, but I'd be happy to help get them merged asap to the extent that someone agrees to review. I'm on a quite tight time budget these months, so I can really only justify spending time on something that has a high chance of moving forward. edit: Maybe I should clarify something. I know the potential people who could review the PRs are also busy, so this was not supposed to be me pointing fingers at anyone. |
Let's tag folks who could help review and move things along. Perhaps @simonbyrne ? |
I’ll rebase the existing PRs so we have something to work off of edit: they're rebased. I hope tests go through, and if they do, I suggest we do nanosoldier runs on them. |
The thing I need help with the most is if people agree that the test sets are sufficient (coverage and correctness). |
I can't edit @simonbyrne 's post, but #27137 covers log2 and log10 |
It would be nice to get the outstanding PRs merged. It seems that we are almost ready to do so in many cases. |
I found these two lines in the file base/special/hyperbolic.jl Does it mean v1.0.0 has to be built with openlibm? |
Correct. Julia's build system builds and bundles openlibm. It's largely invisible to the user. |
then it might be better to disable USE_INTEL_LIBM from Make.inc |
Sorry, I misread. No it doesn't have to be built with openlibm, but we strongly encourage it. Every |
I thought USE_INTEL_LIBM is to configure intel tools. |
@einzigsue ah yes I can see why that would be an issue if you try to swap out the const |
__ldexp_exp can be crossed off the list |
I believe your summary is about right. |
|
What about |
Doesn't llvm do something there, like fallback to the non-fma version or something? I mean having openlibm does not solve that problem anyways, right? |
I'm not the right person to ask here. I've done pretty much all my work assuming 64 bit x86... |
I'll submit a PR that removes openlibm, and we'll see where it goes. |
As seen in #42299 Linux32 seems to have a lot of failures when not using openlibm. It seems that we should move |
The fma bug that is linked to #9847 was fixed in 2014: https://sourceware.org/bugzilla/show_bug.cgi?id=16064. I wonder if it is still relevant. |
Can we count on llvm to provide the right version always? @vchuravy perhaps may know. |
I'll take a look at a native Julia version by next weekend. If we want Julia to do it, we do need to figure out how to do the versioning. |
I started on a native implementation of |
Or we could tell people to use a glibc that is newer than 6 years old? |
Can we emulate FMA with compensated arithmetic? |
[He says, then realizing he has no idea how to do compensated multiplication] |
Yes, but FMAs are notoriously difficult to get right for all the edge cases. A simpler idea is to just call the |
I thought we already merged FMA though: #42783? |
yeah. it is a total pain to get right, but we now have it in Base. |
Oh, or we could do that... |
This is more of a "Do we want to move in this direction RFC". As mentioned in #43786, we currently have three implementations of these intrinsics: 1. The code generated by LLVM for the intrinsic 2. The code LLVM uses for constant folding the intrinsic 3. Our own runtime intrinsic used by the interpreter This basically removes the third one, which will be required if we want to do something about #26434 because we just forward these to libm. Of course we'll still have to do something to teach LLVM how to constant fold these in a manner compatible with what will actually end up running, but that's a separate issue.
This is more of a "Do we want to move in this direction RFC". As mentioned in #43786, we currently have three implementations of these intrinsics: 1. The code generated by LLVM for the intrinsic 2. The code LLVM uses for constant folding the intrinsic 3. Our own runtime intrinsic used by the interpreter This basically removes the third one, which will be required if we want to do something about #26434 because we just forward these to libm. Of course we'll still have to do something to teach LLVM how to constant fold these in a manner compatible with what will actually end up running, but that's a separate issue.
Can't we just remove openlibm, and ditch those users, without fma hardware (or force to use LTS or 1.8 for a little longer)? Or use the emulated one? [Or if it matters copy those two C functions from libm?]
I think it may be actually CPUs older than June 2013, so 9+ years old.
ARM Cortex-A5 with fma was announced in 2009. EDIT:
That seems to be an argument for not using (its) libm, rather dropping those users (or copy those C libm functions, as stated above, from Linux libm, should work on Windows?). I went looking if Python supports fma, and found it planned for 3.7, issue still open, they link to Go implementation and have one in Python too:
https://bugs.python.org/issue29282
|
It kind of looks like Base Julia doesn't need to depend on OpenLibm anymore? At least based on the checkmark list at the top. Is that the case now? (@oscardssmith, @simonbyrne) |
See #42299 |
Thanks to @pkofod we're quite close, but there are a couple of places left:
libm
in a few placescbrt
Add Julia port of cbrt from Openlibm. #25948exp2
Add exp2 port of Openlibm exp2. #24859expm1
Julia port of Openlibm expm1. #25903log2
Replace log2 and log10 with Julia ports. #27137log10
Replace log2 and log10 with Julia ports. #27137rem
Implementrem(float, float, RoundNearest)
in Julia #42380modf
Implementmodf
in Julia #42392fma
to deal with broken system libms (test/numbers.jl fails on 32-bit platform #9847)_ldexp_exp
SpecialFunctions.jl also calls a few. Note however that SpecialFunctions now uses OpenLibm_jll and no longer relies on Julia providing openlibm.
lgamma
lgamma_r
gamma
erf
/erfc
besselj0
/besselj1
/bessly0
/bessely1
besselj
bessely
The text was updated successfully, but these errors were encountered: