-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
8342103: C2 compiler support for Float16 type and associated scalar operations #22754
base: master
Are you sure you want to change the base?
Conversation
Some FAQs on the newly added ideal type for half-float IR nodes:- Q. Why do we not use existing TypeInt::SHORT instead of creating a new TypeH type? Q. Problem with ConF? All Float16 IR nodes now carry newly defined Type::HALF_FLOAT type instead of Type::FLOAT, thus we no longer need special handling in auto-vectorizer to prune their container type to short. |
👋 Welcome back jbhateja! A progress list of the required criteria for merging this PR into |
/contributor add @PaulSandoz |
/contributor add @Bhavana-Kilambi |
❗ This change is not yet ready to be integrated. |
@jatin-bhateja |
/contributor add @jddarcy |
/contributor add @rgiulietti |
@jatin-bhateja |
@jatin-bhateja |
@jatin-bhateja |
@jatin-bhateja The following labels will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing lists. If you would like to change these labels, use the /label pull request command. |
/label add hotspot-compiler-dev |
@jatin-bhateja |
Webrevs
|
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.
Can you quickly summarize what tests you have, and what they test?
@IR(applyIfCPUFeatureOr = {"f16c", "true", "avx512vl", "true", "zvfh", "true"}, counts = {IRNode.VECTOR_CAST_HF2F, IRNode.VECTOR_SIZE_ANY, ">= 1", IRNode.VECTOR_CAST_F2HF, IRNode.VECTOR_SIZE_ANY, " >= 1"}) | ||
@IR(applyIfCPUFeatureAnd = {"avx512_fp16", "false", "avx512vl", "true"}, | ||
counts = {IRNode.VECTOR_CAST_HF2F, IRNode.VECTOR_SIZE_ANY, ">= 1", IRNode.VECTOR_CAST_F2HF, IRNode.VECTOR_SIZE_ANY, " >= 1"}) | ||
@IR(applyIfCPUFeatureAnd = {"avx512_fp16", "false", "f16c", "true"}, | ||
counts = {IRNode.VECTOR_CAST_HF2F, IRNode.VECTOR_SIZE_ANY, ">= 1", IRNode.VECTOR_CAST_F2HF, IRNode.VECTOR_SIZE_ANY, " >= 1"}) | ||
@IR(applyIfCPUFeatureAnd = {"avx512_fp16", "false", "zvfh", "true"}, | ||
counts = {IRNode.VECTOR_CAST_HF2F, IRNode.VECTOR_SIZE_ANY, ">= 1", IRNode.VECTOR_CAST_F2HF, IRNode.VECTOR_SIZE_ANY, " >= 1"}) |
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 like this is having vector changes?
And this is pre-existing: but why are we using VECTOR_SIZE_ANY
here? Can we not know the vector size? Maybe we can introduce a new tag max_float16
or max_hf
. And do something like this:
IRNode.VECTOR_SIZE + "min(max_float, max_hf)", "> 0"
The downside with using ANY
is that the exact size is not tested, and that might mean that the size is much smaller than ideal.
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.
Hi @eme64 , Test modification looks ok to me, we intend to trigger these IR rules on non AVX512-FP16 targets.
On AVX512-FP16 target compiler will infer scalar float16 add operation which will not get auto-vectorized.
Patch includes functional and performance tests, as per your suggestions IR framework-based tests now cover various special cases for constant folding transformation. Let me know if you see any gaps. |
I was hoping that you could make a list of all optimizations that are included here, and tell me where the tests are for it. That would significantly reduce the review time on my end. Otherwise I have to correlate everything myself, and that will take me hours. |
|
/** | ||
* The class {@code Float16Math} constains intrinsic entry points corresponding | ||
* to scalar numeric operations defined in Float16 class. | ||
* @author |
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 remove all author tags. We haven't used them in new code in the JDK for some time.
@@ -1401,8 +1412,15 @@ public static Float16 fma(Float16 a, Float16 b, Float16 c) { | |||
// product is numerically exact in float before the cast to | |||
// double; not necessary to widen to double before the | |||
// multiply. | |||
double product = (double)(a.floatValue() * b.floatValue()); | |||
return valueOf(product + c.doubleValue()); | |||
short fa = float16ToRawShortBits(a); |
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 new implementations in fma and sqrt are comparatively long and obscure compared to the current versions. That might be the price of intrinsification, but it would be helpful to at least have a comment to the reader explaining why the more obvious code was not being used.
Hi All,
This patch adds C2 compiler support for various Float16 operations added by PR#22128
Following is the summary of changes included with this patch:-
Kindly review the patch and share your feedback.
Best Regards,
Jatin
Progress
Issue
Contributors
<psandoz@openjdk.org>
<bkilambi@openjdk.org>
<darcy@openjdk.org>
<rgiulietti@openjdk.org>
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/22754/head:pull/22754
$ git checkout pull/22754
Update a local copy of the PR:
$ git checkout pull/22754
$ git pull https://git.openjdk.org/jdk.git pull/22754/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 22754
View PR using the GUI difftool:
$ git pr show -t 22754
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/22754.diff
Using Webrev
Link to Webrev Comment