diff options
author | Michael Bien <[email protected]> | 2011-07-07 23:32:28 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2011-07-07 23:32:28 +0200 |
commit | 4fe7110357d2631960e23861a3221489d313c467 (patch) | |
tree | 40f1ff4ddef2cd151e22b7d1c496ce3f6b4d9e76 /test/com/jogamp/opencl/TestUtils.java | |
parent | 25b19e390a0a6a3cae8d129a579f16ffd5d4e2e5 (diff) |
CLKernel utility methods for setting vector arguments with up to 4 elements + test.
Diffstat (limited to 'test/com/jogamp/opencl/TestUtils.java')
-rw-r--r-- | test/com/jogamp/opencl/TestUtils.java | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/test/com/jogamp/opencl/TestUtils.java b/test/com/jogamp/opencl/TestUtils.java index bf1fd153..efe6855e 100644 --- a/test/com/jogamp/opencl/TestUtils.java +++ b/test/com/jogamp/opencl/TestUtils.java @@ -29,6 +29,7 @@ package com.jogamp.opencl; import java.nio.ByteBuffer; +import java.nio.FloatBuffer; import java.util.Random; import static java.lang.System.*; @@ -44,7 +45,7 @@ public class TestUtils { final static int NUM_ELEMENTS = 10000000; - public static final void fillBuffer(ByteBuffer buffer, int seed) { + public static ByteBuffer fillBuffer(ByteBuffer buffer, int seed) { Random rnd = new Random(seed); @@ -52,9 +53,23 @@ public class TestUtils { buffer.putInt(rnd.nextInt()); buffer.rewind(); + + return buffer; } - public static final int roundUp(int groupSize, int globalSize) { + public static FloatBuffer fillBuffer(FloatBuffer buffer, int seed) { + + Random rnd = new Random(seed); + + while(buffer.remaining() != 0) + buffer.put(rnd.nextFloat()); + + buffer.rewind(); + + return buffer; + } + + public static int roundUp(int groupSize, int globalSize) { int r = globalSize % groupSize; if (r == 0) { return globalSize; @@ -63,7 +78,7 @@ public class TestUtils { } } - public static final void checkIfEqual(ByteBuffer a, ByteBuffer b, int elements) { + public static void checkIfEqual(ByteBuffer a, ByteBuffer b, int elements) { for(int i = 0; i < elements; i++) { int aVal = a.getInt(); int bVal = b.getInt(); |