diff --git a/src/test/java/com/aparapi/runtime/BufferTransfer.java b/src/test/java/com/aparapi/runtime/BufferTransferTest.java similarity index 99% rename from src/test/java/com/aparapi/runtime/BufferTransfer.java rename to src/test/java/com/aparapi/runtime/BufferTransferTest.java index 00fdc3d91c2a7b43558d6745ad1724c63ec2bdbd..3ca1bf623658469d0a8cd0c486d8efce0b7890eb 100644 --- a/src/test/java/com/aparapi/runtime/BufferTransfer.java +++ b/src/test/java/com/aparapi/runtime/BufferTransferTest.java @@ -28,7 +28,7 @@ import java.util.Arrays; import static org.junit.Assert.assertTrue; import static org.junit.Assert.fail; -public class BufferTransfer { +public class BufferTransferTest { static OpenCLDevice openCLDevice = null; diff --git a/src/test/java/com/aparapi/runtime/CallStaticFromAnonymousKernel.java b/src/test/java/com/aparapi/runtime/CallStaticFromAnonymousKernelTest.java similarity index 85% rename from src/test/java/com/aparapi/runtime/CallStaticFromAnonymousKernel.java rename to src/test/java/com/aparapi/runtime/CallStaticFromAnonymousKernelTest.java index 854f3edb788cb7bd62ad3822a8be7e9552f81f45..33d5aa166e14eef070febe735cbe60f265f0b9a6 100644 --- a/src/test/java/com/aparapi/runtime/CallStaticFromAnonymousKernel.java +++ b/src/test/java/com/aparapi/runtime/CallStaticFromAnonymousKernelTest.java @@ -21,13 +21,7 @@ import org.junit.Test; import static org.junit.Assert.assertTrue; -class AnotherClass { - static public int foo(int i) { - return i + 42; - } -}; - -public class CallStaticFromAnonymousKernel { +public class CallStaticFromAnonymousKernelTest { static final int size = 256; @@ -38,7 +32,7 @@ public class CallStaticFromAnonymousKernel { } public static void main(String args[]) { - CallStaticFromAnonymousKernel k = new CallStaticFromAnonymousKernel(); + CallStaticFromAnonymousKernelTest k = new CallStaticFromAnonymousKernelTest(); k.test(); } @@ -62,7 +56,7 @@ public class CallStaticFromAnonymousKernel { int gid = getGlobalId(); // Call a static in the containing class and call a kernel method // that calls a static in another class - results[gid] = CallStaticFromAnonymousKernel.fooBar(values[gid]) + doodoo(gid); + results[gid] = CallStaticFromAnonymousKernelTest.fooBar(values[gid]) + doodoo(gid); } }; kernel.execute(size); @@ -72,4 +66,10 @@ public class CallStaticFromAnonymousKernel { assertTrue("results == fooBar", results[i] == (fooBar(values[i]) + AnotherClass.foo(i))); } } + + static class AnotherClass { + static public int foo(int i) { + return i + 42; + } + } } diff --git a/src/test/java/com/aparapi/runtime/Issue102.java b/src/test/java/com/aparapi/runtime/Issue102.java deleted file mode 100644 index 88b573132536dabea239edd39b1231c302fb6fbf..0000000000000000000000000000000000000000 --- a/src/test/java/com/aparapi/runtime/Issue102.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2016 - 2017 Syncleus, Inc. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ -package com.aparapi.runtime; - -import com.aparapi.Kernel; -import org.junit.Test; - -import static org.junit.Assert.assertTrue; - - -final class BugDataObject { - int value = 7; - - public int getValue() { - return value; - } - - public void setValue(int value) { - this.value = value; - } -} - - -public class Issue102 extends Kernel { - static final int size = 32; - - static BugDataObject[] objects = new BugDataObject[size]; - int[] target = new int[size]; - - public Issue102() { - for (int i = 0; i < size; ++i) { - objects[i] = new BugDataObject(); - target[i] = 99; - } - } - - public static void main(String[] args) { - Issue102 b = new Issue102(); - b.test(); - } - - @Override - public void run() { - int id = getGlobalId(); - target[id] = objects[id].getValue(); - } - - void validate() { - for (int i = 0; i < size; i++) { - System.out.println(target[i] + " ... " + objects[i].getValue()); - assertTrue("target == objects", target[i] == objects[i].getValue()); - } - } - - @Test - public void test() { - execute(size); - validate(); - } -} diff --git a/src/test/java/com/aparapi/runtime/Issue102Test.java b/src/test/java/com/aparapi/runtime/Issue102Test.java new file mode 100644 index 0000000000000000000000000000000000000000..b3892d934f030d8a9fe554f78167c3ce37560127 --- /dev/null +++ b/src/test/java/com/aparapi/runtime/Issue102Test.java @@ -0,0 +1,75 @@ +/** + * Copyright (c) 2016 - 2017 Syncleus, Inc. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package com.aparapi.runtime; + +import com.aparapi.Kernel; +import org.junit.Test; + +import static org.junit.Assert.assertTrue; + + +public class Issue102Test { + + @Test + public void test() { + Issue102Kernel b = new Issue102Kernel(); + b.test(); + } + + protected static class Issue102Kernel extends Kernel { + private static final int SIZE = 32; + + private static BugDataObject[] objects = new BugDataObject[SIZE]; + int[] target = new int[SIZE]; + + public Issue102Kernel() { + for (int i = 0; i < SIZE; ++i) { + objects[i] = new BugDataObject(); + target[i] = 99; + } + } + + @Override + public void run() { + int id = getGlobalId(); + target[id] = objects[id].getValue(); + } + + void validate() { + for (int i = 0; i < SIZE; i++) { + System.out.println(target[i] + " ... " + objects[i].getValue()); + assertTrue("target == objects", target[i] == objects[i].getValue()); + } + } + + public void test() { + execute(SIZE); + validate(); + } + + static final class BugDataObject { + int value = 7; + + public int getValue() { + return value; + } + + public void setValue(int value) { + this.value = value; + } + } + } +} diff --git a/src/test/java/com/aparapi/runtime/Issue103.java b/src/test/java/com/aparapi/runtime/Issue103Test.java similarity index 57% rename from src/test/java/com/aparapi/runtime/Issue103.java rename to src/test/java/com/aparapi/runtime/Issue103Test.java index cf1ebad3361667ab6ed93871571bbb18463e3b2f..5b4a6fe5ee911a814b4bc63098af2d4ad4878e94 100644 --- a/src/test/java/com/aparapi/runtime/Issue103.java +++ b/src/test/java/com/aparapi/runtime/Issue103Test.java @@ -21,41 +21,43 @@ import org.junit.Test; import static org.junit.Assert.assertArrayEquals; -public class Issue103 extends Kernel { - static final int size = 32; +public class Issue103Test { + @Test + public void test() { + Issue103Kernel b = new Issue103Kernel(); + b.test(); + } - static int[] source = new int[size]; - static int[] target = new int[size]; + public static class Issue103Kernel extends Kernel { + static final int size = 32; - public Issue103() { - for (int i = 0; i < size; ++i) { - source[i] = 7; - target[i] = 99; - } - } + static int[] source = new int[size]; + static int[] target = new int[size]; - public static void main(String[] args) { - Issue103 b = new Issue103(); - b.test(); - } + public Issue103Kernel() { + for (int i = 0; i < size; ++i) { + source[i] = 7; + target[i] = 99; + } + } - @Override - public void run() { - int id = getGlobalId(); - target[id] = source[id]; - } + @Override + public void run() { + int id = getGlobalId(); + target[id] = source[id]; + } - void validate() { - assertArrayEquals("target == source", target, source); + void validate() { + assertArrayEquals("target == source", target, source); // for (int i = 0; i < size; i++) { // System.out.println(target[i] + " ... " + source[i]); // assertTrue("target == source", target[i] == source[i]); // } - } + } - @Test - public void test() { - execute(size); - validate(); + public void test() { + execute(size); + validate(); + } } } diff --git a/src/test/java/com/aparapi/runtime/Issue68.java b/src/test/java/com/aparapi/runtime/Issue68Test.java similarity index 86% rename from src/test/java/com/aparapi/runtime/Issue68.java rename to src/test/java/com/aparapi/runtime/Issue68Test.java index ac302127a8948051a006df544f7a279dfc24b4d1..fbc9e0dcd1101da88439fabff35cbac2871711eb 100644 --- a/src/test/java/com/aparapi/runtime/Issue68.java +++ b/src/test/java/com/aparapi/runtime/Issue68Test.java @@ -16,47 +16,17 @@ package com.aparapi.runtime; import com.aparapi.Kernel; +import org.junit.Ignore; +import org.junit.Test; -abstract class ArrayAccess { - private final int offset; - private final int length; - - protected ArrayAccess(int offset, int length) { - this.offset = offset; - this.length = length; - } - - public abstract int[] getIntData(); - - public int getOffset() { - return offset; - } - - public int getLength() { - return length; - } -} - -class IntMemoryArrayAccess extends ArrayAccess { - private final int[] data; - - public IntMemoryArrayAccess(int[] data, int offset, int length) { - super(offset, length); - this.data = data; - } - - @Override - public int[] getIntData() { - return data; - } -} - -public class Issue68 { - public static void main(String[] args) { +public class Issue68Test { + @Ignore("Ported over but not working yet") + @Test + public void test() { final int SQRT_LENGTH = 1024; final int LENGTH = SQRT_LENGTH * SQRT_LENGTH; final ArrayAccess arrayAccess = new IntMemoryArrayAccess(new int[LENGTH], 0, LENGTH); - new Issue68().transformColumns(SQRT_LENGTH, SQRT_LENGTH, false, arrayAccess, new int[SQRT_LENGTH], null); + new Issue68Test().transformColumns(SQRT_LENGTH, SQRT_LENGTH, false, arrayAccess, new int[SQRT_LENGTH], null); } private void transformColumns(final int length, final int count, final boolean isInverse, final ArrayAccess arrayAccess, @@ -231,4 +201,38 @@ public class Issue68 { this.modulus = modulus; } } + + static class IntMemoryArrayAccess extends ArrayAccess { + private final int[] data; + + public IntMemoryArrayAccess(int[] data, int offset, int length) { + super(offset, length); + this.data = data; + } + + @Override + public int[] getIntData() { + return data; + } + } + + abstract static class ArrayAccess { + private final int offset; + private final int length; + + protected ArrayAccess(int offset, int length) { + this.offset = offset; + this.length = length; + } + + public abstract int[] getIntData(); + + public int getOffset() { + return offset; + } + + public int getLength() { + return length; + } + } } diff --git a/src/test/java/com/aparapi/runtime/Issue69.java b/src/test/java/com/aparapi/runtime/Issue69Test.java similarity index 95% rename from src/test/java/com/aparapi/runtime/Issue69.java rename to src/test/java/com/aparapi/runtime/Issue69Test.java index 3c12deb015404873dad921ba2b7c93095bb178d2..f0b0aae55a6a1fdb207641f9e4ecc75db6863085 100644 --- a/src/test/java/com/aparapi/runtime/Issue69.java +++ b/src/test/java/com/aparapi/runtime/Issue69Test.java @@ -17,10 +17,12 @@ package com.aparapi.runtime; import com.aparapi.Kernel; import com.aparapi.Range; +import org.junit.Test; -public class Issue69 { +public class Issue69Test { - public static void main(String[] args) { + @Test + public void test() { final int globalArray[] = new int[512]; Kernel kernel = new Kernel() { @Override diff --git a/src/test/java/com/aparapi/runtime/LoadCL.java b/src/test/java/com/aparapi/runtime/LoadClTest.java similarity index 95% rename from src/test/java/com/aparapi/runtime/LoadCL.java rename to src/test/java/com/aparapi/runtime/LoadClTest.java index 49fa4066844386f2460c0a8322754cd5e04f1176..60adc75579ba8b4395171da4dc6992cb7d3e83ee 100644 --- a/src/test/java/com/aparapi/runtime/LoadCL.java +++ b/src/test/java/com/aparapi/runtime/LoadClTest.java @@ -21,12 +21,14 @@ import com.aparapi.device.OpenCLDevice; import com.aparapi.internal.kernel.KernelManager; import com.aparapi.opencl.OpenCL; import com.aparapi.opencl.OpenCL.Resource; +import org.junit.Ignore; import org.junit.Test; import static org.junit.Assert.assertTrue; -public class LoadCL { +public class LoadClTest { + @Ignore("Ported over but not working yet") @Test public void test() { final int size = 32; diff --git a/src/test/java/com/aparapi/runtime/RangeSize.java b/src/test/java/com/aparapi/runtime/RangeSizeTest.java similarity index 98% rename from src/test/java/com/aparapi/runtime/RangeSize.java rename to src/test/java/com/aparapi/runtime/RangeSizeTest.java index 0cac50f3c99125c78025d01f36ae0cc00d6a8d8f..b9fa6614592d7368c2fa887319733d45a3f692fa 100644 --- a/src/test/java/com/aparapi/runtime/RangeSize.java +++ b/src/test/java/com/aparapi/runtime/RangeSizeTest.java @@ -20,7 +20,7 @@ import org.junit.Test; import static org.junit.Assert.assertTrue; -public class RangeSize { +public class RangeSizeTest { @Test public void test384x384() { diff --git a/src/test/java/com/aparapi/runtime/UseStaticArray.java b/src/test/java/com/aparapi/runtime/UseStaticArrayTest.java similarity index 56% rename from src/test/java/com/aparapi/runtime/UseStaticArray.java rename to src/test/java/com/aparapi/runtime/UseStaticArrayTest.java index 2b0f631e1958bd1349b872495b07f9b4bf9e2b13..c5d0ccb9e436cdbe791b1c59458221bd1f80bd43 100644 --- a/src/test/java/com/aparapi/runtime/UseStaticArray.java +++ b/src/test/java/com/aparapi/runtime/UseStaticArrayTest.java @@ -22,40 +22,43 @@ import org.junit.Test; import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertTrue; -public class UseStaticArray extends Kernel { +public class UseStaticArrayTest { + @Test + public void test() { + UseStaticArrayKernel k = new UseStaticArrayKernel(); + k.test(); + } - static final int size = 256; + protected static class UseStaticArrayKernel extends Kernel { - static final int[] values = new int[size]; + static final int size = 256; - static final int[] results = new int[size]; + static final int[] values = new int[size]; - public static void main(String args[]) { - UseStaticArray k = new UseStaticArray(); - k.test(); - } + static final int[] results = new int[size]; - @Override - public void run() { - int gid = getGlobalId(); - results[gid] = values[gid]; - } + @Override + public void run() { + int gid = getGlobalId(); + results[gid] = values[gid]; + } - @Test - public void test() { + @Test + public void test() { - for (int i = 0; i < size; i++) { - values[i] = i; - results[i] = 0; - } + for (int i = 0; i < size; i++) { + values[i] = i; + results[i] = 0; + } - execute(size); + execute(size); - assertTrue("ran on GPU", getTargetDevice().getType() == Device.TYPE.GPU); + assertTrue("ran on GPU", getTargetDevice().getType() == Device.TYPE.GPU); - assertArrayEquals("results == fooBar", results, values); + assertArrayEquals("results == fooBar", results, values); // for (int i = 0; i < size; i++) { // assertTrue("results == fooBar", results[i] == values[i]); // } + } } }