1

I am trying to apply filters in sequence base image -> filter1 -> filter2 -> read image. I used to use CL1.1 (C) in which I had events so filter2 would need to wait for filter1 event to finish and read would need to wait for filter2 event to finish.

In CL 1.2 (C++) this is no longer the case as it asks for a vector of events now. But my code below still works and produces the correct result and I don't understand why as with CL1.1 (C) this wouldn't have worked.

cl::CommandQueue queue(context, device, CL_QUEUE_OUT_OF_ORDER_EXEC_MODE_ENABLE, &err);
...
err = queue.enqueueNDRangeKernel(filter1Kernel, cl::NullRange, globalWorkSize, cl::NullRange, nullptr, nullptr);
err = queue.enqueueNDRangeKernel(filter2Kernel, cl::NullRange, globalWorkSize, cl::NullRange, nullptr, nullptr);
err = queue.enqueueReadImage(filter2Image, CL_FALSE, origin, region, 0, 0, ResultImage, nullptr, nullptr);

I can access the image even with a non blocking call and getting the correct output. Is synchronisation no longer needed?

user1031204
  • 701
  • 1
  • 8
  • 30

1 Answers1

3

Just because you say a queue is enabled for out-of-order execution doesn't mean it will be, or if it is that it would run kernels out of order for no reason. So you either ended up with an in-order queue, or an out-of-order queue that is running your kernels in the order you submitted them.

If your work is serial, why are you requesting an out-of-order capable queue?

P.S. You could use the C++ wrapper with 1.1 or 1.2, and you can use the C API with 1.1 and 1.2.

Dithermaster
  • 6,223
  • 1
  • 12
  • 20
  • Because with C calls I used to have event triggers as the last two enqueueNDRangeKernel() parameters were used to wait for an event and control current event. So I would enqueue all my filters at the same time and use the events to synchronise and control the order. But it seems that with C++ this is a bit different as the last two parameters are an event vector and current event object. – user1031204 Feb 09 '18 at 08:07
  • 1
    Is your intention that execution should be a different order than enqueue? If not, just use an in-order queue. Out-of-order queue isn't heavy used, nor widely supported. It seems like for some graph-like workflows or something; I've never had a need for it. Yes, the API is different between C API and C++ wrapper but you have the source to the C++ wrapper and can see how it unwraps the vector into a list for the C API. It just uses the C API inside. – Dithermaster Feb 09 '18 at 10:13