-
Notifications
You must be signed in to change notification settings - Fork 10.5k
Add Float16 to stdlib #30130
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
Add Float16 to stdlib #30130
Conversation
@swift-ci please test |
@swift-ci please test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
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.
Looks good! I caught one typo 🎣
@@ -58,6 +67,7 @@ else: | |||
% end | |||
|
|||
${SelfDocComment} | |||
${Availability(bits)} |
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.
The extra line here won't interfere with tools extracting doc comments, right?
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.
I don't think so.
Update: ubuntu seems to be missing the float <-> float16 conversion functions in its libgcc, so we'll probably have to build them into the Swift runtime lib on Linux (and likely some other platforms, as well). I'll add a patch to do that sometime in the next few days. |
@swift-ci please smoke test Linux |
(Local build for Linux isn't working quite right, so rebuilding on CI to get a list of exactly the symbols required.) |
Looks like we need to provide:
|
@swift-ci smoke test |
@tbkka can you review the new runtime/Float16Support.cpp? |
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.
Minor suggestions.
@@ -0,0 +1,164 @@ | |||
//===------------- Float16Support.cpp - Swift Float16 Support -------------===// |
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 seems like the right place for this.
7f8f62b
to
2d11922
Compare
Getting back to this, let's run a test on Linux and see where we stand ... |
@swift-ci test |
Build failed |
This isn't quite right, because it introduces double-rounding, but it will do in the short-term.
2d11922
to
1aefc71
Compare
@swift-ci test |
Build failed |
Build failed |
Add an actual float16ToString operation, that we can give a real implemention for down the road.
@swift-ci test |
Build failed |
Build failed |
@swift-ci test |
Build failed |
Build failed |
@swift-ci please test |
Build failed |
Build failed |
0030880
to
232a78b
Compare
@swift-ci please test |
Build failed |
Build failed |
Implementation was merged to Swift in swiftlang/swift#30130.
This caused a regression on the android builds :-( The new Float16 support requires runtime support from the compiler runtime. In particular, the AEABI provides the runtime functions |
@compnerd Yes, you'll need to update stdlib/public/runtime/Float16Support.cpp to expose The implementation should work essentially unchanged, though you may need to replace the call to |
Yeah, why would the system provide the (system) required symbols? sigh On the bright side, at least it is supposed to be there in future versions. I'll see if I can get the shims in place for ARMv7. |
Implement IEEE 754 binary16 as Float16 in the stdlib conforming to BinaryFloatingPoint and SIMDScalar.
Evolution proposal: https://github.com/apple/swift-evolution/blob/master/proposals/0277-float16.md
SE thread: https://forums.swift.org/t/se-0277-float16/33546