diff options
author | Michael Bien <[email protected]> | 2011-05-09 17:30:19 +0200 |
---|---|---|
committer | Michael Bien <[email protected]> | 2011-05-09 17:30:19 +0200 |
commit | 1c38b7ef96910260b64843214279ac4683005609 (patch) | |
tree | d0d2c38da50a94e13f7ed2c90db0f44a1b678ae4 /test/com | |
parent | c59bc50229181ab9cb0e5012d7bb5caf2faa781f (diff) |
added submitAll() utility method
junit test now covering queue contexts switching
improved javadoc.
Diffstat (limited to 'test/com')
-rw-r--r-- | test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java | 34 |
1 files changed, 18 insertions, 16 deletions
diff --git a/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java b/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java index e5bcb1c5..81d34907 100644 --- a/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java +++ b/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java @@ -62,13 +62,13 @@ public class CLMultiContextTest { } private final static String programSource = - "kernel void increment(global int* array, int numElements) { \n" - + " int index = get_global_id(0); \n" - + " if (index >= numElements) { \n" - + " return; \n" - + " } \n" - + " array[index]++; \n" - + "} \n"; + "kernel void compute(global int* array, int numElements) { \n" + + " int index = get_global_id(0); \n" + + " if (index >= numElements) { \n" + + " return; \n" + + " } \n" + + " array[index]++; \n" + + "} \n"; private final class CLTestTask implements CLTask<CLSimpleQueueContext, Buffer> { @@ -82,7 +82,7 @@ public class CLMultiContextTest { CLCommandQueue queue = qc.getQueue(); CLContext context = qc.getCLContext(); - CLKernel kernel = qc.getKernel("increment"); + CLKernel kernel = qc.getKernel("compute"); CLBuffer<Buffer> buffer = null; try{ @@ -133,26 +133,28 @@ public class CLMultiContextTest { out.println("invoking "+tasks.size()+" tasks on "+pool.getSize()+" queues"); + // blocking invoke pool.invokeAll(tasks); checkBuffer(1, data); - + // submit blocking emediatly for (CLTestTask task : tasks) { pool.submit(task).get(); } checkBuffer(2, data); - - List<Future<Buffer>> futures = new ArrayList<Future<Buffer>>(taskCount); - for (CLTestTask task : tasks) { - futures.add(pool.submit(task)); - } + // submitAll using futures + List<Future<Buffer>> futures = pool.submitAll(tasks); for (Future<Buffer> future : futures) { future.get(); } checkBuffer(3, data); - -// pool.switchContext(factory); + + // switching contexts using different program + factory = CLQueueContextFactory.createSimple(programSource.replaceAll("\\+\\+", "--")); + pool.switchContext(factory); + pool.invokeAll(tasks); + checkBuffer(2, data); pool.release(); }finally{ |