RFR: 8309130: x86_64 AVX512 intrinsics for Arrays.sort methods (int, long, float and double arrays) [v13]
Andrew Haley
aph at openjdk.org
Sun Jul 30 08:26:59 UTC 2023
On Sat, 29 Jul 2023 15:59:52 GMT, David Schlosnagle <duke at openjdk.org> wrote:
>> Srinivas Vamsi Parasa has updated the pull request incrementally with one additional commit since the last revision:
>>
>> add special cases to float and double arrays
>
> src/java.base/share/classes/java/util/Arrays.java line 100:
>
>> 98: else if (elemType == float.class) DualPivotQuicksort.sort((float[]) array, 0, fromIndex, toIndex);
>> 99: else if (elemType == double.class) DualPivotQuicksort.sort((double[]) array, 0, fromIndex, toIndex);
>> 100: else throw new UnsupportedOperationException("arraySort intrinsic not supported for this type: " + elemType.toString());
>
> I'm curious if there is a performance difference using switch pattern on element type that would generate an `invokedynamic typeSwitch` over the primitive array types e.g.:
>
> Suggestion:
>
> switch (array) {
> case int[] arr -> DualPivotQuicksort.sort(arr, 0, fromIndex, toIndex);
> case long[] arr -> DualPivotQuicksort.sort(arr, 0, fromIndex, toIndex);
> case float[] arr -> DualPivotQuicksort.sort(arr, 0, fromIndex, toIndex);
> case double[] arr -> DualPivotQuicksort.sort(arr, 0, fromIndex, toIndex);
> default -> throw new UnsupportedOperationException(
> "arraySort intrinsic not supported for this type: " + elemType);
> }
What is the reasoning behind this new public API? It doesn't follow the usual Java convention, which is to have overloads for each type. And it doesn't seem to provide anything not already provided by `Arrays.sort()`.
-------------
PR Review Comment: https://git.openjdk.org/jdk/pull/14227#discussion_r1278530013
More information about the hotspot-compiler-dev
mailing list