title: OpenCL Events and Command Queues
body: <p>I'm working on translating a CUDA application (<a href="http://github.com/Ken-g6/PSieve-CUDA" rel="noreferrer">this if you must know</a>) to OpenCL.  The original application uses the C-style CUDA API, with a single stream just to avoid the automatic busy-wait when reading the results.</p>
  
  <p>Now I notice that OpenCL command queues look a lot like CUDA streams.  But in <a href="http://www.khronos.org/registry/cl/sdk/1.0/docs/man/xhtml/clEnqueueReadBuffer.html" rel="noreferrer">the device read command</a>, and likewise in the write and kernel execute commands, I notice parameters for events too.  So I'm wondering, what does it take to execute a device write, a number of kernels (e.g. one call to one kernel then 100 calls to another kernel), and a device read, all sequentially?</p>
  
  <ol>
  <li>If I just enqueue them sequentially into the same queue, will they execute sequentially like they do in CUDA?</li>
  <li>If that doesn't work, can/should I daisy-chain events, making each call's wait list the previous call's event?</li>
  <li>Or should I add all previous events to each call's wait list, like if there's an N^2 search for dependencies or something?</li>
  <li>Or do I just have to event.wait() for each call individually, like it says to in <a href="http://developer.amd.com/gpu/ATIStreamSDK/pages/TutorialOpenCL.aspx" rel="noreferrer">AMD's tutorial</a>?</li>
  </ol>
  
  <p>Thanks!</p>