-
Notifications
You must be signed in to change notification settings - Fork 6.1k
8341260: Add Float16 to jdk.incubator.vector #21574
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
Conversation
|
👋 Welcome back darcy! A progress list of the required criteria for merging this PR into |
|
@jddarcy This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be: You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 26 new commits pushed to the
As there are no conflicts, your changes will automatically be rebased on top of these commits when integrating. If you prefer to avoid this automatic rebasing, please check the documentation for the /integrate command for further details. ➡️ To integrate this PR with the above commit message to the |
|
/contributor add @rgiulietti |
|
/contributor add @jatin-bhateja |
|
@jddarcy |
|
@jddarcy |
|
Add as contributors other engineers who worked on Float16 on the lworld+fp16 branch in Valhalla. |
|
To ease review, diffs of corresponding files from the current, at time of writing, state of files in lworld+fp16 vs a port to jdk.incubator.vector, starting with Float16: |
|
|
Initially, I left the tests for the BigDecimal -> Float16 conversion in the tests for the base module to ease review compared to their location in the Valhalla branch. The tests can be extracted and moved to a jdk.incubator.vector area subsequently. |
As initially done here, the port of Float16 omits any VM intrinsification; that would need to be done by subsequent work. Subsequent work may also adapt the Java implementations to be more amenable to being intrinsified. |
Webrevs
|
|
Joe, our revised and now-current thinking about JIT support for the Float16 (both as a pre-Valhalla VBC and Valhalla value class) is that there should be zero need for any The two existing intrinsics in So, unless there is some reason I am not aware of, there does not need to be any intrinsic definition in Note the economy of the resulting design: Two intrinsics at the Java level provide the JIT with ample opportunity (if it so desires) to organize an IR with a full FP16 type and all its typed operations. There is no need to surface such complexity in the Java source code. |
|
Somebody might ask as a followup, "But what about calling sequences? Without intrinsics, how does the JIT know to store Float16 values in the correct type of argument register?" Presumably some platforms may wish to store arguments (and return values) in floating point registers, not in the integer registers used by a typical value class (such as Float16, containing a single That question might be motivated by the observation that, while FP16 stored in temps might well be stored in FPU registers, simply due to proximity to decode/encode intrinsics, changing the calling sequence requires that we give the Float16 class a little extra magic. (More detail: There are fundamentally 3 different places that FP16 values might need type-specific storage: IR temps, argument/return registers, and heap variables. The first can often be FPU regs. The last can be untyped memory words and a In any case, getting those details right does not require any |
|
Comparing with #21490 we can see that there are more than minimum number of intrinsics I recommended above, but (crucially) the intrinsics are decoupled from the box type, and refactored into For example, see the max intrinsics line 53. These intrinsics are better structured for the JIT, because there is no extraneous boxing to deal with. (Boxes involve null checks and heap allocation and other details which are just extra overhead.) Apart from intrinsic classification, a simpler thing to do that may help the box methods to fold up correctly would be a |
I'm agnostic toward how the intrinsification of Float16 is implemented. I've removed the commented-out intrinsics annotations in a subsequent push. As noted, for review purposes I wanted to have a least one iteration of Float16 in the incubator that was as close as possible to the version of Float16 that has been in use in the lworld+fp16 branch. |
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16.java
Show resolved
Hide resolved
|
Updated the implementation with Float16 -> string conversion code from @rgiulietti and added various supporting tests. |
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16.java
Outdated
Show resolved
Hide resolved
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16.java
Outdated
Show resolved
Hide resolved
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16.java
Outdated
Show resolved
Hide resolved
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16.java
Outdated
Show resolved
Hide resolved
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.
Approving the current status.
Are there plans for other small additions?
Subsequent to this comment, I did a light clean-up pass over the tests. I'll do a pass over the Float16 implementation too to make sure previous comments are all addressed. |
PS Pushed another clean-up pass over the implementation and tests. |
| // expected to be aligned with Value Classes and Object as described in | ||
| // JEP-401 (https://openjdk.org/jeps/401). | ||
| // @jdk.internal.MigratedValueClass | ||
| // @jdk.internal.ValueBased |
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.
Please uncomment value-based class annotation.
Float16 does comply with the semantics of value-based classes.
https://docs.oracle.com/en/java/javase/22/docs/api/java.base/java/lang/doc-files/ValueBased.html
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 jdk.internal.ValueBased annotation is not exported for use outside of the java.base module.
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 can do this in a subsequent PR and export the package jdk.internal to module jdk.incubating.vector like we do for other java.base internal packages. I believe no other changes should be necessary, but we should double check.
Classes in the jdk.incubating.vector module are loaded in the boot class loader and are considered privileged, therefore the internal @ValueBased annotation will not be ignored by the runtime.
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.
LGTM
src/jdk.incubator.vector/share/classes/jdk/incubator/vector/Float16.java
Show resolved
Hide resolved
|
/integrate |
|
Going to push as commit dbf2346.
Your commit was automatically rebased without conflicts. |
Port of Float16 from java.lang in the lworld+fp16 branch to jdk.incubabor.vector.
Progress
Issues
Reviewers
Contributors
<rgiulietti@openjdk.org><jbhateja@openjdk.org>Reviewing
Using
gitCheckout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/21574/head:pull/21574$ git checkout pull/21574Update a local copy of the PR:
$ git checkout pull/21574$ git pull https://git.openjdk.org/jdk.git pull/21574/headUsing Skara CLI tools
Checkout this PR locally:
$ git pr checkout 21574View PR using the GUI difftool:
$ git pr show -t 21574Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/21574.diff
Using Webrev
Link to Webrev Comment