-
Notifications
You must be signed in to change notification settings - Fork 6.2k
8317976: Optimize SIMD sort for AMD Zen 4 #24053
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 rraj! A progress list of the required criteria for merging this PR into |
@rohitarulraj 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 318 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. As you do not have Committer status in this project an existing Committer must agree to sponsor your change. Possible candidates are the reviewers of this PR (@PaulSandoz, @iwanowww) but any other Committer may sponsor as well. ➡️ To flag this PR as ready for integration with the above commit message, type |
@rohitarulraj The following label 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 list. If you would like to change these labels, use the /label pull request command. |
Webrevs
|
snprintf(ebuf_, sizeof(ebuf_), | ||
((VM_Version::is_intel() || (VM_Version::is_amd() && (VM_Version::cpu_family() > 0x19))) | ||
&& VM_Version::supports_avx512dq()) ? "avx512_sort" : "avx2_sort"); |
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.
Perhaps factor the expression to a separate method rather than repeat it three times?
Can we add some constant with a descriptive name for the CPU family rather than directly using 0x19?
/reviewers 2 reviewer |
@PaulSandoz |
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, thank you for updating. I am not a proper HotSpot reviewer so i bumped up the number of required reviewers, and a HotSpot developer needs to quickly review it.
@@ -771,6 +773,10 @@ class VM_Version : public Abstract_VM_Version { | |||
// | |||
static bool cpu_supports_evex() { return (_cpu_features & CPU_AVX512F) != 0; } | |||
|
|||
static bool supports_avx512_simd_sort() { | |||
// Disable AVX512 version of SIMD Sort on AMD Zen4 Processors |
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 you forgot to remove the comment: // Disable AVX512 version of SIMD Sort on AMD Zen4 Processors
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.
For Zen4, we are disabling AVX512 version of SIMD Sort and using AVX2 version. So the comment is valid.
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.
Got it!
@@ -4315,7 +4315,7 @@ void StubGenerator::generate_compiler_stubs() { | |||
|
|||
// Load x86_64_sort library on supported hardware to enable SIMD sort and partition intrinsics | |||
|
|||
if (VM_Version::is_intel() && (VM_Version::supports_avx512dq() || VM_Version::supports_avx2())) { | |||
if (VM_Version::supports_avx512dq() || VM_Version::supports_avx2()) { |
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.
Shouldn't you check for VM_Version::supports_avx512_simd_sort()
here 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.
The above condition will hold for all AMD processors. Only for Zen4, even though AVX512 is supported, we want to pick AVX2 version of SIMD sort (due to the regression) which is handled by the code below:
snprintf(ebuf_, sizeof(ebuf_), VM_Version::supports_avx512_simd_sort() ? "avx512_sort" : "avx2_sort");
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 for the clarification!
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.
Also, please update the PR description summarizing the main high-level changes in this PR. Will make it easy for others.
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 Vamsi, updated the PR description accordingly.
@PaulSandoz @vamsi-parasa : Can I integrate this patch? |
No, before you can do that need another review from a HotSpot reviewer. |
@vamsi-parasa : Could you please review or provide feedback on this patch? |
Srinivas does not currently have openjdk reviewer status. @iwanowww if you have a few moments can you help review? |
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.
Overall, looks good.
@@ -771,6 +773,10 @@ class VM_Version : public Abstract_VM_Version { | |||
// | |||
static bool cpu_supports_evex() { return (_cpu_features & CPU_AVX512F) != 0; } | |||
|
|||
static bool supports_avx512_simd_sort() { | |||
// Disable AVX512 version of SIMD Sort on AMD Zen4 Processors | |||
return ((is_intel() || (is_amd() && (cpu_family() > CPU_FAMILY_AMD_19H))) && supports_avx512dq()); } |
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.
It's quite hard to parse. The following looks clearer to me:
if (supports_avx512dq()) {
// Disable AVX512 version of SIMD Sort on AMD Zen4 Processors.
if (is_amd() && cpu_family() == CPU_FAMILY_AMD_19H) {
return false;
}
return true;
}
return false;
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 second the suggested refactoring. Need to make sure the original is_intel()
check is also included appropriately in the logic :)
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.
It's quite hard to parse. The following looks clearer to me:
if (supports_avx512dq()) { // Disable AVX512 version of SIMD Sort on AMD Zen4 Processors. if (is_amd() && cpu_family() == CPU_FAMILY_AMD_19H) { return false; } return true; } return false;
Done.
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.
/integrate |
@rohitarulraj |
/sponsor |
Going to push as commit 8cbadf7.
Your commit was automatically rebased without conflicts. |
@sendaoYan @rohitarulraj Pushed as commit 8cbadf7. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
In JDK-8309130, Array sort was optimized using AVX512 SIMD instructions for x86_64. Currently, this optimization has been disabled for AMD Zen 4 [JDK-8317763] due to bad performance of compressstoreu.
Ref: https://www.reddit.com/r/java/comments/171t5sj/heads_up_openjdk_implementation_of_avx512_based/.
This patch enables Zen 4 to pick optimized AVX2 version of SIMD sort and Zen 5 picks the AVX512 version.
JTREG Tests: Completed Tier1 & Tier2 tests on Zen4 & Zen5 - No Regressions.
Attaching ArraySort performance data for Zen4 & Zen5.
Zen4-ArraySort-Data.txt
Zen5-ArraySort-Data.txt
Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk.git pull/24053/head:pull/24053
$ git checkout pull/24053
Update a local copy of the PR:
$ git checkout pull/24053
$ git pull https://git.openjdk.org/jdk.git pull/24053/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 24053
View PR using the GUI difftool:
$ git pr show -t 24053
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/24053.diff
Using Webrev
Link to Webrev Comment