aboutsummaryrefslogtreecommitdiffstats
path: root/test/com/jogamp/opencl/TestUtils.java
diff options
context:
space:
mode:
authorMichael Bien <[email protected]>2010-04-12 22:18:39 +0200
committerMichael Bien <[email protected]>2010-04-12 22:18:39 +0200
commitbf07b44ed6a8958dd321cc4c08fd2bdd08299611 (patch)
treee24b7c4e4197a80e0ecaad75b9b3667299fd8323 /test/com/jogamp/opencl/TestUtils.java
parent7680472b21ec1e2deacb49addae65c820a2e2a4d (diff)
renamed package com.mbien.* in com.jogamp.* JOCL is now officially a JogAmp team player ;).
Diffstat (limited to 'test/com/jogamp/opencl/TestUtils.java')
-rw-r--r--test/com/jogamp/opencl/TestUtils.java52
1 files changed, 52 insertions, 0 deletions
diff --git a/test/com/jogamp/opencl/TestUtils.java b/test/com/jogamp/opencl/TestUtils.java
new file mode 100644
index 00000000..e2ef16f3
--- /dev/null
+++ b/test/com/jogamp/opencl/TestUtils.java
@@ -0,0 +1,52 @@
+package com.jogamp.opencl;
+
+import java.nio.ByteBuffer;
+import java.util.Random;
+
+import static java.lang.System.*;
+import static org.junit.Assert.*;
+
+/**
+ * @author Michael Bien
+ */
+public class TestUtils {
+
+ //decrease this value on systems with few memory.
+ final static int ONE_MB = 1048576;
+
+ final static int NUM_ELEMENTS = 10000000;
+
+ public static final void fillBuffer(ByteBuffer buffer, int seed) {
+
+ Random rnd = new Random(seed);
+
+ while(buffer.remaining() != 0)
+ buffer.putInt(rnd.nextInt());
+
+ buffer.rewind();
+ }
+
+ public static final int roundUp(int groupSize, int globalSize) {
+ int r = globalSize % groupSize;
+ if (r == 0) {
+ return globalSize;
+ } else {
+ return globalSize + groupSize - r;
+ }
+ }
+
+ public static final void checkIfEqual(ByteBuffer a, ByteBuffer b, int elements) {
+ for(int i = 0; i < elements; i++) {
+ int aVal = a.getInt();
+ int bVal = b.getInt();
+ if(aVal != bVal) {
+ out.println("a: "+aVal);
+ out.println("b: "+bVal);
+ out.println("position: "+a.position());
+ fail("a!=b");
+ }
+ }
+ a.rewind();
+ b.rewind();
+ }
+}