Skip to content
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

Fix using roundeven intrinsic on darwin #10479

Merged
merged 3 commits into from
Mar 10, 2021
Merged

Fix using roundeven intrinsic on darwin #10479

merged 3 commits into from
Mar 10, 2021

Conversation

straight-shoota
Copy link
Member

Resolves #10475

Based on #10476 to make sure it actually works (and continues to work).

For some reason the `roundeven` intrinsic is not available in LLVM 11 on
macos, so we fall back to `rint`.
@straight-shoota straight-shoota added kind:bug A bug in the code. Does not apply to documentation, specs, etc. topic:stdlib:numeric platform:darwin labels Mar 6, 2021
@straight-shoota straight-shoota added this to the 1.0.0 milestone Mar 6, 2021
@asterite
Copy link
Member

asterite commented Mar 6, 2021

Thank you!

Do you know why that function isn't there on Mac? And what's the benefit of using that over the alternative?

@straight-shoota
Copy link
Member Author

I have no idea why it's missing on macos. But it should be available in LLVM 11 (https://releases.llvm.org/11.0.0/docs/LangRef.html#llvm-roundeven-intrinsic) and it does on linux.
Maybe we shouldn't use it altogether, or just for linux explicitly?

As far as I understand, roundeven was introduced for slightly improved semantics (it's about specific error conditions IIRC). rint might be removed at some point, but might not. It definitely feels better to use the more recent roundeven when it's available.

@asterite
Copy link
Member

asterite commented Mar 6, 2021

Well, the docs say it's not supported on all target. Maybe this is one case.

@straight-shoota
Copy link
Member Author

Could be. But when a major platform doesn't support even the main float types, I'd expect a more clear message that it's only supported on some targets at all.
Btw. the same is said about rint so you could assume it should be unavailable on similar targets.

@asterite
Copy link
Member

asterite commented Mar 7, 2021

Is there a performance difference or something else? I think that if they are equivalent but one works in more platforms, we should use that alternative.

@straight-shoota
Copy link
Member Author

Well roundeven is supposed to habe the better, standard-conformant semantics. Not sure if that really matters for our use case, but on platforms that support it, I don't think there's any reason to use rint over roundeven.

Since we don't know about other platforms, I'd limit usage to LLVM >= 11 on linux. That should be good.

Copy link
Member

@bcardiff bcardiff left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since llvm@11 support still has it's gotchas (ref: #10359). I think this is fine as is. The official releases does not use llvm@11 and we can even fallback to llvm@9 in homebrew. Meanwhile this can be merged.

Worst-case, if roundeven_f32 is missing on some platform, the method can easily be monkey-patched and a PR submitted.

@straight-shoota
Copy link
Member Author

I actually think we should use rint for now on every platform. That seems to be more widely available. As Ary said there's no real downside to using rint over roundeven. So we should just go with that and not block ourselves for improving LLVM 11 support.
We can introduce roundeven later when it has more support.

@asterite
Copy link
Member

@straight-shoota Thank you! And just to be clear, it might have looked like I'm totally against using roundeven but that's not the case. I'm sure eventually we'll want to use it, it just seems that it's poorly supported right now.

@SlayerShadow
Copy link

@straight-shoota, thank you! It fixes compiler at least on Alpine and with latest LLVM versions. Compiler compiled with --release flag still doesn't work but it seems unrelated issue.

@bcardiff bcardiff merged commit 2588dc5 into master Mar 10, 2021
@straight-shoota straight-shoota deleted the fix/darwin-roundeven branch March 10, 2021 16:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind:bug A bug in the code. Does not apply to documentation, specs, etc. platform:darwin topic:stdlib:numeric
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bug: Undefined symbol _roundeven
4 participants