Skip to content
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

8317763: Follow-up to AVX512 intrinsics for Arrays.sort() PR #16124

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 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 make/modules/java.base/Lib.gmk
Original file line number Diff line number Diff line change
Expand Up @@ -227,7 +227,7 @@ ifeq ($(ENABLE_FALLBACK_LINKER), true)
NAME := fallbackLinker, \
CFLAGS := $(CFLAGS_JDKLIB) $(LIBFFI_CFLAGS), \
LDFLAGS := $(LDFLAGS_JDKLIB) \
$(call SET_SHARED_LIBRARY_ORIGIN), \
$(call SET_SHARED_LIBRARY_ORIGIN), \
vamsi-parasa marked this conversation as resolved.
Show resolved Hide resolved
LIBS := $(LIBFFI_LIBS), \
LIBS_windows := $(LIBFFI_LIBS) ws2_32.lib, \
))
Expand Down
2 changes: 1 addition & 1 deletion src/hotspot/cpu/x86/stubGenerator_x86_64.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4173,7 +4173,7 @@ void StubGenerator::generate_compiler_stubs() {
}

// Load x86_64_sort library on supported hardware to enable avx512 sort and partition intrinsics
if (UseAVX > 2 && VM_Version::supports_avx512dq()) {
if (VM_Version::is_intel() && VM_Version::supports_avx512dq()) {
void *libsimdsort = nullptr;
char ebuf_[1024];
char dll_name_simd_sort[JVM_MAXPATHLEN];
Expand Down
11 changes: 10 additions & 1 deletion src/java.base/linux/native/libsimdsort/avx512-common-qsort.h
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,18 @@
#include <cmath>
#include <cstdint>
#include <cstring>
#include <immintrin.h>
#include <limits>

/*
Workaround for the bug in GCC12 (that was fixed in GCC 12.3.1).
More details are available at: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=105593
*/
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wmaybe-uninitialized"
#pragma GCC diagnostic ignored "-Wuninitialized"
#include <immintrin.h>
#pragma GCC diagnostic pop

#define X86_SIMD_SORT_INFINITY std::numeric_limits<double>::infinity()
#define X86_SIMD_SORT_INFINITYF std::numeric_limits<float>::infinity()
#define X86_SIMD_SORT_INFINITYH 0x7c00
Expand Down
22 changes: 15 additions & 7 deletions src/java.base/share/classes/java/util/DualPivotQuicksort.java
Original file line number Diff line number Diff line change
Expand Up @@ -166,9 +166,9 @@ interface PartitionOperation<A> {
/**
* Partitions the specified range of the array using the given pivots.
*
* @param a the array to be sorted
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
* @param a the array to be partitioned
* @param low the index of the first element, inclusive, to be partitioned
* @param high the index of the last element, exclusive, to be partitioned
* @param pivotIndex1 the index of pivot1, the first pivot
* @param pivotIndex2 the index of pivot2, the second pivot
*/
Expand All @@ -178,13 +178,13 @@ interface PartitionOperation<A> {
/**
* Partitions the specified range of the array using the two pivots provided.
*
* @param elemType the class of the array to be sorted
* @param array the array to be sorted
* @param elemType the class of the array to be partitioned
* @param array the array to be partitioned
* @param offset the relative offset, in bytes, from the base address of
* the array to partition, otherwise if the array is {@code null},an absolute
* address pointing to the first element to partition from.
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
* @param low the index of the first element, inclusive, to be partitioned
* @param high the index of the last element, exclusive, to be partitioned
* @param pivotIndex1 the index of pivot1, the first pivot
* @param pivotIndex2 the index of pivot2, the second pivot
* @param po the method reference for the fallback implementation
Expand Down Expand Up @@ -569,6 +569,7 @@ private static int[] partitionSinglePivot(int[] a, int low, int high, int pivotI
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
*/
@ForceInline
private static void mixedInsertionSort(int[] a, int low, int high) {
int size = high - low;
int end = high - 3 * ((size >> 5) << 3);
Expand Down Expand Up @@ -684,6 +685,7 @@ private static void mixedInsertionSort(int[] a, int low, int high) {
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
*/
@ForceInline
private static void insertionSort(int[] a, int low, int high) {
for (int i, k = low; ++k < high; ) {
int ai = a[i = k];
Expand Down Expand Up @@ -1371,6 +1373,7 @@ private static int[] partitionSinglePivot(long[] a, int low, int high, int pivot
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
*/
@ForceInline
private static void mixedInsertionSort(long[] a, int low, int high) {
int size = high - low;
int end = high - 3 * ((size >> 5) << 3);
Expand Down Expand Up @@ -1486,6 +1489,7 @@ private static void mixedInsertionSort(long[] a, int low, int high) {
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
*/
@ForceInline
private static void insertionSort(long[] a, int low, int high) {
for (int i, k = low; ++k < high; ) {
long ai = a[i = k];
Expand Down Expand Up @@ -2959,6 +2963,7 @@ private static int[] partitionSinglePivot(float[] a, int low, int high, int pivo
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
*/
@ForceInline
private static void mixedInsertionSort(float[] a, int low, int high) {
int size = high - low;
int end = high - 3 * ((size >> 5) << 3);
Expand Down Expand Up @@ -3074,6 +3079,7 @@ private static void mixedInsertionSort(float[] a, int low, int high) {
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
*/
@ForceInline
private static void insertionSort(float[] a, int low, int high) {
for (int i, k = low; ++k < high; ) {
float ai = a[i = k];
Expand Down Expand Up @@ -3812,6 +3818,7 @@ private static int[] partitionSinglePivot(double[] a, int low, int high, int piv
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
*/
@ForceInline
private static void mixedInsertionSort(double[] a, int low, int high) {
int size = high - low;
int end = high - 3 * ((size >> 5) << 3);
Expand Down Expand Up @@ -3927,6 +3934,7 @@ private static void mixedInsertionSort(double[] a, int low, int high) {
* @param low the index of the first element, inclusive, to be sorted
* @param high the index of the last element, exclusive, to be sorted
*/
@ForceInline
private static void insertionSort(double[] a, int low, int high) {
for (int i, k = low; ++k < high; ) {
double ai = a[i = k];
Expand Down