From cb859fd580d3e1f5afb3c0f77cee0a5e82a394bb Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Wed, 25 May 2011 00:50:26 +0200 Subject: fixed event-condition test which failed sporadically with out-of-order queues. --- test/com/jogamp/opencl/CLCommandQueueTest.java | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) (limited to 'test/com') diff --git a/test/com/jogamp/opencl/CLCommandQueueTest.java b/test/com/jogamp/opencl/CLCommandQueueTest.java index c8c028af..5636a40d 100644 --- a/test/com/jogamp/opencl/CLCommandQueueTest.java +++ b/test/com/jogamp/opencl/CLCommandQueueTest.java @@ -191,25 +191,24 @@ public class CLCommandQueueTest { }else{ queue = device.createCommandQueue(); } - - CLEventList writeEvent = new CLEventList(1); - CLEventList kernelEvents = new CLEventList(2); + + // simulate in-order queue by accumulating events of prior commands + CLEventList events = new CLEventList(3); // (1+1)*2 = 4; conditions enforce propper order CLKernel addKernel = program.createCLKernel("add").putArg(buffer).putArg(1).putArg(elements); CLKernel mulKernel = program.createCLKernel("mul").putArg(buffer).putArg(2).putArg(elements); - queue.putWriteBuffer(buffer, false, writeEvent); + queue.putWriteBuffer(buffer, false, events); - queue.put1DRangeKernel(addKernel, 0, elements, 1, writeEvent, kernelEvents); - queue.put1DRangeKernel(mulKernel, 0, elements, 1, writeEvent, kernelEvents); + queue.put1DRangeKernel(addKernel, 0, elements, 1, events, events); + queue.put1DRangeKernel(mulKernel, 0, elements, 1, events, events); - queue.putReadBuffer(buffer, false, kernelEvents, null); + queue.putReadBuffer(buffer, false, events, null); queue.finish(); - writeEvent.release(); - kernelEvents.release(); + events.release(); for (int i = 0; i < elements; i++) { assertEquals(4, buffer.getBuffer().get(i)); @@ -372,7 +371,7 @@ public class CLCommandQueueTest { final CountDownLatch countdown = new CountDownLatch(1); customEvent.registerCallback(new CLEventListener() { - + @Override public void eventStateChanged(CLEvent event, int status) { out.println("event received: "+event); assertEquals(event, customEvent); -- cgit v1.2.3