diff --git a/CHANGELOG.md b/CHANGELOG.md index 2477f610620aba0b58420df10bbb49b0e8ad452a..595a5a87e65af0bb9c669f63d4e27d5dbfff6699 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,8 @@ * (JNI) Aparapi now supports efficient execution on discrete GPU and other devices with dedicated memory * Support for OpenCLDevice configurator/configure API +* (JNI) Fixed local arrays handling 1D and ND, to cope with arrays resizing across kernel executions + ## 1.8.0 * Updated KernelManager to facilitate class extensions having constructors with non static parameters diff --git a/src/test/java/com/aparapi/runtime/MultiDimensionalLocalArrayTest.java b/src/test/java/com/aparapi/runtime/MultiDimensionalLocalArrayTest.java index dd0cb0f58d12b7f23875049bd62f2686ccf6fc0d..8cc14518b82a5a9e7c8393711d7ed2baaceb40c0 100644 --- a/src/test/java/com/aparapi/runtime/MultiDimensionalLocalArrayTest.java +++ b/src/test/java/com/aparapi/runtime/MultiDimensionalLocalArrayTest.java @@ -117,6 +117,44 @@ public class MultiDimensionalLocalArrayTest assertEquals(3840, RESULT[0], 1E-6F); } + @Test + public void singleDimensionMultipleExecutionTest() + { + final Device device = getDevice(); + final int SIZE = 16; + final float[] RESULT = new float[2]; + Kernel kernel = new Kernel() + { + @Local final float[] localArray = new float[SIZE*SIZE]; + + @Override + public void run() + { + int row = getGlobalId(0); + int column = getGlobalId(1); + localArray[row + column*SIZE] = row + column; + localBarrier(); + float value = 0; + for (int x = 0; x < SIZE; x++) + { + for (int y = 0; y < SIZE; y++) + { + value += localArray[x + y*SIZE]; + } + } + RESULT[0] = value; + } + }; + try { + kernel.execute(Range.create2D(device, SIZE, SIZE, SIZE, SIZE)); + assertEquals(3840, RESULT[0], 1E-6F); + kernel.execute(Range.create2D(device, SIZE, SIZE, SIZE, SIZE)); + assertEquals(3840, RESULT[0], 1E-6F); + } finally { + kernel.dispose(); + } + } + @Test public void twoDimensionTest() { @@ -153,7 +191,6 @@ public class MultiDimensionalLocalArrayTest assertEquals(3840, RESULT[0][0], 1E-6F); } - @Ignore("Aparapi fails to re-execute kernel with local NDarrays") @Test public void twoDimensionMultipleExecutionTest() { @@ -267,7 +304,6 @@ public class MultiDimensionalLocalArrayTest } } - @Ignore("Aparapi-native fails to resize 1D arrays across executions") @Test public void resizableOneDimensionTest() { @@ -283,14 +319,13 @@ public class MultiDimensionalLocalArrayTest assertEquals(3840, RESULT[0], 1E-6F); kernel.setArray(2*SIZE, new float[2*SIZE*2*SIZE]); kernel.execute(Range.create2D(device, 2*SIZE, 2*SIZE, 2*SIZE, 2*SIZE)); - assertTrue("Result is not greater then 2840", RESULT[0]>3840); + assertTrue("Result is not greater then 3840", RESULT[0]>3840); } finally { kernel.dispose(); } } - @Ignore("Aparapi-native fails to resize NDarray across kernel executions") @Test public void resizableTwoDimensionTest() { @@ -305,7 +340,7 @@ public class MultiDimensionalLocalArrayTest assertEquals(3840, RESULT[0], 1E-6F); kernel.setArray(2*SIZE, new float[2*SIZE][2*SIZE]); kernel.execute(Range.create2D(device, SIZE, SIZE, SIZE, SIZE)); - assertTrue("Result is not greater than 2840", RESULT[0]>3840); + assertTrue("Result is not greater than 3840", RESULT[0]>3840); } finally { kernel.dispose(); }