Skip to content

Commit

Permalink
Add java.util.Arrays patch to use gpu module code
Browse files Browse the repository at this point in the history
Signed-off-by: Theresa Mammarella <[email protected]>
  • Loading branch information
theresa-m committed Mar 23, 2018
1 parent b6fe698 commit 7ff7e19
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 2 deletions.
5 changes: 3 additions & 2 deletions closed/make/CompileJavaModules.gmk
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# ===========================================================================
# (c) Copyright IBM Corp. 2017 All Rights Reserved
# (c) Copyright IBM Corp. 2017, 2018 All Rights Reserved
# ===========================================================================
#
# This code is free software; you can redistribute it and/or modify it
Expand All @@ -17,5 +17,6 @@
#
# ===========================================================================

java.base_COPY += ExternalMessages.properties ibm_gpu_thresholds.properties
java.base_COPY += ExternalMessages.properties
openj9.gpu_COPY += ibm_gpu_thresholds.properties

29 changes: 29 additions & 0 deletions src/java.base/share/classes/java/util/Arrays.java
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
/*
* ===========================================================================
* (c) Copyright IBM Corp. 2018, 2018 All Rights Reserved.
* ===========================================================================
*/
/*
* Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
Expand Down Expand Up @@ -143,6 +148,9 @@ static void rangeCheck(int arrayLength, int fromIndex, int toIndex) {
* @param a the array to be sorted
*/
public static void sort(int[] a) {
if (GPUAssistHolder.instance.trySort(a, 0, a.length)) {
return;
}
DualPivotQuicksort.sort(a, 0, a.length - 1, null, 0, 0);
}

Expand All @@ -168,6 +176,9 @@ public static void sort(int[] a) {
*/
public static void sort(int[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
if (GPUAssistHolder.instance.trySort(a, fromIndex, toIndex)) {
return;
}
DualPivotQuicksort.sort(a, fromIndex, toIndex - 1, null, 0, 0);
}

Expand All @@ -183,6 +194,9 @@ public static void sort(int[] a, int fromIndex, int toIndex) {
* @param a the array to be sorted
*/
public static void sort(long[] a) {
if (GPUAssistHolder.instance.trySort(a, 0, a.length)) {
return;
}
DualPivotQuicksort.sort(a, 0, a.length - 1, null, 0, 0);
}

Expand All @@ -208,6 +222,9 @@ public static void sort(long[] a) {
*/
public static void sort(long[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
if (GPUAssistHolder.instance.trySort(a, fromIndex, toIndex)) {
return;
}
DualPivotQuicksort.sort(a, fromIndex, toIndex - 1, null, 0, 0);
}

Expand Down Expand Up @@ -351,6 +368,9 @@ public static void sort(byte[] a, int fromIndex, int toIndex) {
* @param a the array to be sorted
*/
public static void sort(float[] a) {
if (GPUAssistHolder.instance.trySort(a, 0, a.length)) {
return;
}
DualPivotQuicksort.sort(a, 0, a.length - 1, null, 0, 0);
}

Expand Down Expand Up @@ -384,6 +404,9 @@ public static void sort(float[] a) {
*/
public static void sort(float[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
if (GPUAssistHolder.instance.trySort(a, fromIndex, toIndex)) {
return;
}
DualPivotQuicksort.sort(a, fromIndex, toIndex - 1, null, 0, 0);
}

Expand All @@ -407,6 +430,9 @@ public static void sort(float[] a, int fromIndex, int toIndex) {
* @param a the array to be sorted
*/
public static void sort(double[] a) {
if (GPUAssistHolder.instance.trySort(a, 0, a.length)) {
return;
}
DualPivotQuicksort.sort(a, 0, a.length - 1, null, 0, 0);
}

Expand Down Expand Up @@ -440,6 +466,9 @@ public static void sort(double[] a) {
*/
public static void sort(double[] a, int fromIndex, int toIndex) {
rangeCheck(a.length, fromIndex, toIndex);
if (GPUAssistHolder.instance.trySort(a, fromIndex, toIndex)) {
return;
}
DualPivotQuicksort.sort(a, fromIndex, toIndex - 1, null, 0, 0);
}

Expand Down

0 comments on commit 7ff7e19

Please sign in to comment.