-
-
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
[RFC/WIP] Leverage compiler-rt for builtins support of llvm intrinsics #17344
Conversation
Some timings on
And with this PR:
|
@@ -14,7 +14,7 @@ const NaN = NaN64 | |||
## conversions to floating-point ## | |||
convert(::Type{Float16}, x::Integer) = convert(Float16, convert(Float32,x)) | |||
for t in (Int8,Int16,Int32,Int64,Int128,UInt8,UInt16,UInt32,UInt64,UInt128) | |||
@eval promote_rule(::Type{Float16}, ::Type{$t}) = Float32 | |||
@eval promote_rule(::Type{Float16}, ::Type{$t}) = Float16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This should probably be a different PR
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes I should have noted that this is #17297
@tkelman thanks for the review and I hope I addressed most of your comments. One point that I would like to discuss is if we want to put the shared library version of compiler-rt to go into |
Why would we put it in |
The place I would think is appropriate is lib/julia to emphasise that we On Sun, 10 Jul 2016, 11:23 Tony Kelman, notifications@github.com wrote:
|
Shared libraries will be put in |
This allows us the more freely use llvm intrinsics and have fallbacks in place for systems where they don't map to instructions. Currently this requires building with a Make.user containing ``` override BUILD_COMPILER-RT = 1 override LLVM_USE_CMAKE = 1 override USE_LLVM_SHLIB = 0 ``` TODO: * Allow for a system installation * Figure out what is needed to make this work without LLVM_USE_CMAKE
LLVM intrinsics either map to instructions or to functions in compiler-rt. If we can't find a symbol look into a shared version of compiler-rt and resolve the functions there.
We need a cmake build that also works with SHLIB=1 for compiler-rt
I will leave this branch up for now, but I currently don't see a way of doing this properly (and not lose shlib support), without switching to 3.9 |
@@ -1,4 +1,4 @@ | |||
LLVM_VER = 3.7.1 | |||
LLVM_VER = 3.8.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we'll probably do 3.8.1 some time not too long after branching for 0.6-dev, but it'll need CI preparation
edit: and checksum updates
For the build-system we could try to use the Makefile from https://github.com/ReservedField/arm-compiler-rt/ to make your lifes easier (not using cmake) |
#18734 has the basic support for compiler-rt and I plan to add PR for full Float16 support after that got merged |
Note:
This feature will remain unavailable until we compile LLVM with cmake and bump our llvm version to
3.83.9Reason
llvm will only build
compiler-rt
with cmake and turns building it with autotools explicitly off. We currently build llvm as a shlib and that only works in combination with cmake from version 3.8 upwards.Compiler-rt (builtins) provides low-level support for llvm intrinsics that don't map to an appropriate cpu instructions.
It provides fallbacks for llvm intrinsics on platfroms, where they don't map to an appropriate instruction. As an example we could use the cpu instructions to convert Float16 -> Float32 on any platform that supports
f16c
.Caveats
Todo
LLVM_USE_CMAKE = 0
~~USE_SYSTEM_LLVM = 1