Skip to content
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/hotspot/cpu/x86/matcher_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@

// Is SIMD sort supported for this CPU?
static bool supports_simd_sort(BasicType bt) {
if (VM_Version::supports_avx512dq()) {
if (VM_Version::supports_avx512_simd_sort()) {
return true;
}
else if (VM_Version::supports_avx2() && !is_double_word_type(bt)) {
Expand Down
6 changes: 3 additions & 3 deletions src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()) {
Copy link
Contributor

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?

Copy link
Contributor Author

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");

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the clarification!

Copy link
Contributor

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.

Copy link
Contributor Author

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.

void *libsimdsort = nullptr;
char ebuf_[1024];
char dll_name_simd_sort[JVM_MAXPATHLEN];
Expand All @@ -4326,10 +4326,10 @@ void StubGenerator::generate_compiler_stubs() {
if (libsimdsort != nullptr) {
log_info(library)("Loaded library %s, handle " INTPTR_FORMAT, JNI_LIB_PREFIX "simdsort" JNI_LIB_SUFFIX, p2i(libsimdsort));

snprintf(ebuf_, sizeof(ebuf_), VM_Version::supports_avx512dq() ? "avx512_sort" : "avx2_sort");
snprintf(ebuf_, sizeof(ebuf_), VM_Version::supports_avx512_simd_sort() ? "avx512_sort" : "avx2_sort");
StubRoutines::_array_sort = (address)os::dll_lookup(libsimdsort, ebuf_);

snprintf(ebuf_, sizeof(ebuf_), VM_Version::supports_avx512dq() ? "avx512_partition" : "avx2_partition");
snprintf(ebuf_, sizeof(ebuf_), VM_Version::supports_avx512_simd_sort() ? "avx512_partition" : "avx2_partition");
StubRoutines::_array_partition = (address)os::dll_lookup(libsimdsort, ebuf_);
}
}
Expand Down
6 changes: 6 additions & 0 deletions src/hotspot/cpu/x86/vm_version_x86.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -432,6 +432,8 @@ class VM_Version : public Abstract_VM_Version {
enum Extended_Family {
// AMD
CPU_FAMILY_AMD_11H = 0x11,
CPU_FAMILY_AMD_17H = 0x17, /* Zen1 & Zen2 */
CPU_FAMILY_AMD_19H = 0x19, /* Zen3 & Zen4 */
// ZX
CPU_FAMILY_ZX_CORE_F6 = 6,
CPU_FAMILY_ZX_CORE_F7 = 7,
Expand Down Expand Up @@ -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
Copy link
Contributor

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

Copy link
Contributor Author

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Got it!

return ((is_intel() || (is_amd() && (cpu_family() > CPU_FAMILY_AMD_19H))) && supports_avx512dq()); }
Copy link
Contributor

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;

Copy link
Contributor

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 :)

Copy link
Contributor Author

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.


// Intel features
static bool is_intel_family_core() { return is_intel() &&
extended_cpu_family() == CPU_FAMILY_INTEL_CORE; }
Expand Down