Skip to content

Commit 8cbadf7

Browse files
Rohit Arul RajSendaoYan
authored andcommitted
8317976: Optimize SIMD sort for AMD Zen 4
Reviewed-by: psandoz, vlivanov
1 parent b9d7a75 commit 8cbadf7

File tree

3 files changed

+17
-4
lines changed

3 files changed

+17
-4
lines changed

src/hotspot/cpu/x86/matcher_x86.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@
256256

257257
// Is SIMD sort supported for this CPU?
258258
static bool supports_simd_sort(BasicType bt) {
259-
if (VM_Version::supports_avx512dq()) {
259+
if (VM_Version::supports_avx512_simd_sort()) {
260260
return true;
261261
}
262262
else if (VM_Version::supports_avx2() && !is_double_word_type(bt)) {

src/hotspot/cpu/x86/stubGenerator_x86_64.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4312,7 +4312,7 @@ void StubGenerator::generate_compiler_stubs() {
43124312

43134313
// Load x86_64_sort library on supported hardware to enable SIMD sort and partition intrinsics
43144314

4315-
if (VM_Version::is_intel() && (VM_Version::supports_avx512dq() || VM_Version::supports_avx2())) {
4315+
if (VM_Version::supports_avx512dq() || VM_Version::supports_avx2()) {
43164316
void *libsimdsort = nullptr;
43174317
char ebuf_[1024];
43184318
char dll_name_simd_sort[JVM_MAXPATHLEN];
@@ -4323,10 +4323,10 @@ void StubGenerator::generate_compiler_stubs() {
43234323
if (libsimdsort != nullptr) {
43244324
log_info(library)("Loaded library %s, handle " INTPTR_FORMAT, JNI_LIB_PREFIX "simdsort" JNI_LIB_SUFFIX, p2i(libsimdsort));
43254325

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

4329-
snprintf(ebuf_, sizeof(ebuf_), VM_Version::supports_avx512dq() ? "avx512_partition" : "avx2_partition");
4329+
snprintf(ebuf_, sizeof(ebuf_), VM_Version::supports_avx512_simd_sort() ? "avx512_partition" : "avx2_partition");
43304330
StubRoutines::_array_partition = (address)os::dll_lookup(libsimdsort, ebuf_);
43314331
}
43324332
}

src/hotspot/cpu/x86/vm_version_x86.hpp

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -432,6 +432,8 @@ class VM_Version : public Abstract_VM_Version {
432432
enum Extended_Family {
433433
// AMD
434434
CPU_FAMILY_AMD_11H = 0x11,
435+
CPU_FAMILY_AMD_17H = 0x17, /* Zen1 & Zen2 */
436+
CPU_FAMILY_AMD_19H = 0x19, /* Zen3 & Zen4 */
435437
// ZX
436438
CPU_FAMILY_ZX_CORE_F6 = 6,
437439
CPU_FAMILY_ZX_CORE_F7 = 7,
@@ -771,6 +773,17 @@ class VM_Version : public Abstract_VM_Version {
771773
//
772774
static bool cpu_supports_evex() { return (_cpu_features & CPU_AVX512F) != 0; }
773775

776+
static bool supports_avx512_simd_sort() {
777+
if (supports_avx512dq()) {
778+
// Disable AVX512 version of SIMD Sort on AMD Zen4 Processors.
779+
if (is_amd() && cpu_family() == CPU_FAMILY_AMD_19H) {
780+
return false;
781+
}
782+
return true;
783+
}
784+
return false;
785+
}
786+
774787
// Intel features
775788
static bool is_intel_family_core() { return is_intel() &&
776789
extended_cpu_family() == CPU_FAMILY_INTEL_CORE; }

0 commit comments

Comments
 (0)