-
Notifications
You must be signed in to change notification settings - Fork 5.8k
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
8350835: C2 SuperWord: assert/wrong result when using Float.float16ToFloat with byte instead of short input #23939
Conversation
…Float with byte instead of short input
👋 Welcome back sviswanathan! A progress list of the required criteria for merging this PR into |
@sviswa7 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 120 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 |
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.
Good.
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 @sviswa7, The Fix looks reasonable to me. Kindly consider including applicable suggestions.
Best Regards
goldL = testLongKernel(aL); | ||
} | ||
|
||
@Test |
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.
@Test | |
@Test | |
@IR(failOn = { IRNode.VECTOR_CAST_HF2F }, applyIfCPUFeatureOr = { "avx512vl", "true", "f16c", "true" }) |
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 left out the IR check because we do intend to vectorize this going forward. Instead the bug fix is verified by checkResult. Also the fix is not specific to Intel platform so if we do add IR check it will need to be generic.
@eme64 your thoughts please? Would you like to see an IR check here that vectorization is not happening?
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.
Personally, I generally prefer to have failOn
IR rules, if we expect that at least for now there should be no vectorization. But add a comment why we expect no vectorization, so that if it ever does vectorize and the IR rule fails the person has a hint, and does not have to reverse-engineer too much. And if it turns out that we should one day vectorize, then we already have all these tests ready to just flip the failOn
into count
.
return res; | ||
} | ||
|
||
@Test |
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.
@Test | |
@Test | |
@IR(counts = { IRNode.VECTOR_CAST_HF2F, " >0 " }, applyIfCPUFeatureOr = { "avx512vl", "true", "f16c", "true" }) |
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.
Used the IR test from compiler/vectorization/TestFloatConversionsVector.java to include other architectures as well.
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.
Thanks @sviswa7 , these operations are also supported on PPC.
return res; | ||
} | ||
|
||
@Test |
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.
@Test | |
/* | |
* C2 handles i2s conversion by constraining the value range of the integral argument; thus | |
* argument fed to ConvHF2F is of type T_INT. Fix for JDK-8350835 skips over vectorizing such a case | |
* for now. | |
*/ | |
@Test | |
@IR(failOn = { IRNode.VECTOR_CAST_HF2F }, applyIfCPUFeatureOr = { "avx512vl", "true", "f16c", "true" }) |
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 see any harm in including the above suggested comment as you mentioned we plan to support these auto vrctoriizations in future
return res; | ||
} | ||
|
||
@Test |
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.
@Test | |
/* | |
* C2 handles this in two steps: l2i handling creates ConvL2I IR ,followed by i2s conversion which onstrains the | |
* value range of the integral argument; thus, the argument fed to ConvHF2F is of type T_INT. Fix for | |
* JDK-8350835 skip over vectorizing such a case for now. | |
*/ | |
@Test | |
@IR(failOn = { IRNode.VECTOR_CAST_HF2F }, applyIfCPUFeatureOr = { "avx512vl", "true", "f16c", "true" }) |
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.
Thanks, added the generic failOn tests for byte, int, and long test cases as it is applicable across architectures.
Thanks a lot @vnkozlov for the review and approval. |
* @key randomness | ||
* @bug 8350835 | ||
* @summary Test bug fix for JDK-8350835 discovered through Template Framework | ||
* @requires vm.compiler2.enabled |
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.
* @requires vm.compiler2.enabled |
Is this restriction necessary? I generally prefer running tests on all platforms, and only restricting IR rules. That way we can get more test coverage with result verification.
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 restriction is not necessary, removed.
* @summary Test bug fix for JDK-8350835 discovered through Template Framework | ||
* @requires vm.compiler2.enabled | ||
* @library /test/lib / | ||
* @run main/othervm -XX:-TieredCompilation -XX:CompileOnly=compiler.vectorization.TestFloat16ToFloatConv::test* compiler.vectorization.TestFloat16ToFloatConv |
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.
Are the additional flags really necessary for reproducing the bug? I would suspect not really. The IR framework already takes care of ensuring we run with C2 compilation.
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.
Removed the additional flags.
private static byte[] aB = new byte[SIZE]; | ||
private static short[] aS = new short[SIZE]; | ||
private static int[] aI = new int[SIZE]; | ||
private static long[] aL = new long[SIZE]; | ||
private static float[] goldB, goldS, goldI, goldL; |
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.
Are you testing for char
as well?
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.
Added test for char.
for (int i = 0; i < aB.length; i++) { | ||
aB[i] = (byte)RANDOM.nextInt(); | ||
aS[i] = (short)RANDOM.nextInt(); | ||
aI[i] = RANDOM.nextInt(); | ||
aL[i] = RANDOM.nextLong(); | ||
} |
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 would prefer if we could start using Generators
. There is a fill
method for arrays. It generates more "interesting" values. It is not super relevant here, but it would be nice if we made this common practice now ;)
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 Generators don't support the bytes, shorts, and chars yet so ended up not using them for this PR.
goldL = testLongKernel(aL); | ||
} | ||
|
||
@Test |
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.
Personally, I generally prefer to have failOn
IR rules, if we expect that at least for now there should be no vectorization. But add a comment why we expect no vectorization, so that if it ever does vectorize and the IR rule fails the person has a hint, and does not have to reverse-engineer too much. And if it turns out that we should one day vectorize, then we already have all these tests ready to just flip the failOn
into count
.
@sviswa7 thanks for looking at this! The fix looks good, there are just a few comments about the test :) |
@eme64 @jatin-bhateja Your review comments are addressed, please take a look. |
@Test | ||
@IR(counts = {IRNode.VECTOR_CAST_HF2F, "> 0"}, | ||
applyIfOr = {"UseCompactObjectHeaders", "false", "AlignVector", "false"}, | ||
applyIfPlatformOr = {"x64", "true", "aarch64", "true", "riscv64", "true"}, |
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 kindly justify the need for compressed object header usage, it will mainly impact the pre-loop trip count compuation. AlignVector should be sufficient since it's a whitelisted option
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 check is taken from compiler/vectorization/TestFloatConversionsVector.java which also has float16 conversion tests to be in sync.
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.
If I remove UseCompressedHeaders check then the test will start failing for folks working on compressed headers so good to keep it there and as I mentioned before it is good to be in sync with other Float16ToFloat conversion test.
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 much better :)
You are right Generators
are missing cases for short
, byte
, char
. You could leave those cases with regular Random
, but the int
and long
cases with Generators
, to make sure interesing values are added to the mix more frequently.
} | ||
|
||
@Test | ||
// Not vectorized due to JDK-8350835 |
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.
That's very non-descriptive. Actually, that is the current bug, so this is not even a future RFE that intends to fix it.
Can you please say why it is not vectorizing now, and what might be possible conditions when it would be ok to vectorize in the future? Could we even file an RFE for this?
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.
Added descriptive comments. RFE filed at https://bugs.openjdk.org/browse/JDK-8352093.
* @bug 8350835 | ||
* @summary Test bug fix for JDK-8350835 discovered through Template Framework | ||
* @library /test/lib / | ||
* @run main/othervm compiler.vectorization.TestFloat16ToFloatConv |
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.
* @run main/othervm compiler.vectorization.TestFloat16ToFloatConv | |
* @run driver compiler.vectorization.TestFloat16ToFloatConv |
I don't think you need a new VM if you have no additional flags ;)
@eme64 @jatin-bhateja Your review comments are handled. Please take a look. |
@sviswa7 The code and test looks good to me now. I'm re-running testing. Please ping me in a day for the results :) |
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.
Tests are passing. Approved.
@sviswa7 Thanks for the work 😊
Thanks a lot @eme64. |
/integrate |
Going to push as commit 3239919.
Your commit was automatically rebased without conflicts. |
Float.float16ToFloat generates wrong vectorized code in product build and asserts in fastdebug/debug when argument is of type byte, int, or long array. The short term solution is to not auto vectorize in these cases.
Review comments are welcome.
Best Regards,
Sandhya
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/23939/head:pull/23939
$ git checkout pull/23939
Update a local copy of the PR:
$ git checkout pull/23939
$ git pull https://git.openjdk.org/jdk.git pull/23939/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 23939
View PR using the GUI difftool:
$ git pr show -t 23939
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/23939.diff
Using Webrev
Link to Webrev Comment