From 16c4aaeb9002f9d79732648c1a15e9750c9de35c Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Mon, 20 Jun 2011 22:35:03 +0200 Subject: CLCommandQueuePool support for invokeAny(tasks). --- .../opencl/util/concurrent/CLMultiContextTest.java | 28 ++++++++++++++++++---- 1 file changed, 24 insertions(+), 4 deletions(-) (limited to 'test/com/jogamp') diff --git a/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java b/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java index 81d34907..68ca33f9 100644 --- a/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java +++ b/test/com/jogamp/opencl/util/concurrent/CLMultiContextTest.java @@ -78,6 +78,7 @@ public class CLMultiContextTest { this.data = buffer; } + @Override public Buffer execute(CLSimpleQueueContext qc) { CLCommandQueue queue = qc.getQueue(); @@ -134,27 +135,36 @@ public class CLMultiContextTest { out.println("invoking "+tasks.size()+" tasks on "+pool.getSize()+" queues"); // blocking invoke - pool.invokeAll(tasks); + List> results = pool.invokeAll(tasks); + assertNotNull(results); checkBuffer(1, data); // submit blocking emediatly for (CLTestTask task : tasks) { - pool.submit(task).get(); + Buffer ret = pool.submit(task).get(); + assertNotNull(ret); } checkBuffer(2, data); // submitAll using futures List> futures = pool.submitAll(tasks); for (Future future : futures) { - future.get(); + Buffer ret = future.get(); + assertNotNull(ret); } checkBuffer(3, data); // switching contexts using different program factory = CLQueueContextFactory.createSimple(programSource.replaceAll("\\+\\+", "--")); pool.switchContext(factory); - pool.invokeAll(tasks); + List> results2 = pool.invokeAll(tasks); + assertNotNull(results2); checkBuffer(2, data); + + // submit any + Buffer buffer = pool.invokeAny(tasks); + assertNotNull(buffer); + checkContains(1, data); pool.release(); }finally{ @@ -169,4 +179,14 @@ public class CLMultiContextTest { data.rewind(); } + private void checkContains(int expected, IntBuffer data) { + while(data.hasRemaining()) { + if(expected == data.get()){ + data.rewind(); + return; + } + } + fail(); + } + } -- cgit v1.2.3