title: cl::Event::waitForEvents returns -7 (CL_EXEC_STATUS_ERROR_ FOR_EVENTS_IN_WAIT_LIST)
body: <p>I am attempting to run the same kernel on two GPU devices concurrently within the same context.</p>
  
  <p>I have hit a snag, where when trying to profile the event object, I get a -7 (event object not available) for the second command queue.</p>
  
  <p>When I wait for events then it errors out with -7. This only seems to happen in command queue 2.</p>
  
  <p>Any idea why? Any help would be much apprecated. </p>
  
  <p>Code attached.</p>
  
  <pre><code>void *bytes;
  float *zeropad;
  float *output_f;
  
  void *outputbytes;
  int ret;
  
  ret = posix_memalign(&amp;bytes, total_alignment_requirement, cshape[level][1]*(size+2)*(size+2)*sizeof(float));
  zeropad = (float *)bytes;
  
  
  //float *output_f = (float *)calloc(cshape[level][0]*size*size,sizeof(float));  
  
  //SR assigning aligned memory
  ret = posix_memalign(&amp;outputbytes, total_alignment_requirement, cshape[level][1]*(size+2)*(size+2)*sizeof(float));
  output_f = (float *)outputbytes;
  
  unsigned int total=0;
  
  //prepare matrix for OpenCL    
  padding_input(matrix,zeropad,size,in_depth);
  
  cl::Buffer zeropad_buf(openclObjects.context,CL_MEM_READ_ONLY| CL_MEM_COPY_HOST_PTR,(size+2)*(size+2)*cshape[level][1]*sizeof(float),zeropad);
  
  cl::Buffer output_buf(openclObjects.context,CL_MEM_READ_WRITE | CL_MEM_USE_HOST_PTR  ,cshape[level][0]*size*size*sizeof(float),output_f);
  cl::Buffer bs(openclObjects.context,CL_MEM_READ_ONLY | CL_MEM_COPY_HOST_PTR,cshape[level][0]*sizeof(float),bc[level]);
  
  
  // SR using sub buffers only zeropad_buf and output_bf and to chunk up the buffer and submit the kernels twice...once to each device
  
  //Creating sub_buffers for zeropad_buf
  
  size_t zeropad_buf_size = (size+2)*(size+2)*cshape[level][1]*sizeof(float);
  size_t output_buf_size = cshape[level][0]*size*size*sizeof(float);
  
  
  size_t zeropad_split_pos = zeropad_buf_size / 2;
  zeropad_split_pos -= zeropad_split_pos % total_alignment_requirement;
  cl_buffer_region zero_rgn_4core = {0, zeropad_split_pos};
  cl_buffer_region zero_rgn_2core = {zeropad_split_pos, zeropad_buf_size - zeropad_split_pos};
  
  
  /*
  cl_buffer_region zero_rgn_4core = {0, zeropad_buf_size/2};
  cl_buffer_region zero_rgn_2core = {zeropad_buf_size/2, zeropad_buf_size/2};
  */
  
  
  cl_buffer_region output_rgn_4core = {0, output_buf_size/2};
  cl_buffer_region output_rgn_2core = {output_buf_size/2, output_buf_size/2};
  
  
  
  cl::Buffer zeropad_buf_4Core = zeropad_buf.createSubBuffer(CL_MEM_READ_ONLY,CL_BUFFER_CREATE_TYPE_REGION, &amp;zero_rgn_4core);
  std::cout&lt;&lt;"zero_pad sub-buffer region 1 created"&lt;&lt;std::endl;
  cl::Buffer zeropad_buf_2Core = zeropad_buf.createSubBuffer(CL_MEM_READ_ONLY,CL_BUFFER_CREATE_TYPE_REGION, &amp;zero_rgn_2core); 
  std::cout&lt;&lt;"zero_pad sub-buffer region 2 created"&lt;&lt;std::endl;
  
  cl::Buffer output_buf_4Core = output_buf.createSubBuffer(CL_MEM_READ_WRITE,CL_BUFFER_CREATE_TYPE_REGION, &amp;output_rgn_4core);
  cl::Buffer output_buf_2Core = output_buf.createSubBuffer(CL_MEM_READ_WRITE,CL_BUFFER_CREATE_TYPE_REGION, &amp;output_rgn_2core);
  
  cl::NDRange global(global_x, global_y, global_y);
  cl::NDRange local(1, group_size, group_size);   
  
  //cl::Event evt[2];//SR
  
  //SR use a vector events
  std::vector&lt;cl::Event&gt; events;
  cl::Event evt1, evt2;
  
  
  
  //SR Kernel after sub buffering - 4 core
  openclObjects.conv_gpu.setArg&lt;cl::Memory&gt;(0, zeropad_buf_4Core);
  openclObjects.conv_gpu.setArg&lt;cl::Memory&gt;(1, conv_weights[level]);
  openclObjects.conv_gpu.setArg&lt;cl::Memory&gt;(2, output_buf_4Core);
  openclObjects.conv_gpu.setArg&lt;cl::Memory&gt;(3, bs);
  openclObjects.conv_gpu.setArg&lt;int&gt;(4, size+2);
  openclObjects.conv_gpu.setArg&lt;int&gt;(5, cshape[level][1]);
  openclObjects.conv_gpu.setArg&lt;int&gt;(6, size);
  openclObjects.conv_gpu.setArg&lt;int&gt;(7, cshape[level][0]);
  openclObjects.conv_gpu.setArg&lt;int&gt;(8, CONV_SIZE);
  
  
  
  
  cl_int err=openclObjects.queue[0].enqueueNDRangeKernel( openclObjects.conv_gpu, cl::NullRange, global, local, NULL, &amp;evt1);  //SR
  events.push_back(evt1);
  </code></pre>
  
  <p>//   cl_int err=openclObjects.queue.enqueueNDRangeKernel( openclObjects.conv_gpu, cl::NullRange, global, local, NULL)</p>
  
  <pre><code>//SR Kernel after sub buffering - 2 core
  openclObjects.conv_gpu.setArg&lt;cl::Memory&gt;(0, zeropad_buf_2Core);
  openclObjects.conv_gpu.setArg&lt;cl::Memory&gt;(1, conv_weights[level]);
  openclObjects.conv_gpu.setArg&lt;cl::Memory&gt;(2, output_buf_2Core);
  openclObjects.conv_gpu.setArg&lt;cl::Memory&gt;(3, bs);
  openclObjects.conv_gpu.setArg&lt;int&gt;(4, size+2);
  openclObjects.conv_gpu.setArg&lt;int&gt;(5, cshape[level][1]);
  openclObjects.conv_gpu.setArg&lt;int&gt;(6, size);
  openclObjects.conv_gpu.setArg&lt;int&gt;(7, cshape[level][0]);
  openclObjects.conv_gpu.setArg&lt;int&gt;(8, CONV_SIZE);
  
  
  //SR Added for CQ2 (2 Core GPU)
  err=openclObjects.queue[1].enqueueNDRangeKernel( openclObjects.conv_gpu, cl::NullRange, global, local, NULL, &amp;evt2);
  events.push_back(evt2);
  
  std::cout&lt;&lt;"Enqueue CQ2"&lt;&lt;std::endl;
  
  //get event info
  cl::CommandQueue CQ;
  cl::Device CQ_device;
  
  evt2.getInfo(CL_EVENT_COMMAND_QUEUE,&amp;CQ);
  
  
  CQ.getInfo(CL_QUEUE_DEVICE, &amp;CQ_device);
  
  std::cout&lt;&lt;"New Code"&lt;&lt;std::endl;
  
  std::cout&lt;&lt;"Event attached to COmmand Q2"&lt;&lt;std::endl;
  std::cout&lt;&lt;"Device Name in Command Queue 1: "&lt;&lt;CQ_device.getInfo&lt;CL_DEVICE_NAME&gt;()&lt;&lt;std::endl;
  std::cout&lt;&lt;"Device Vendor: "&lt;&lt;CQ_device.getInfo&lt;CL_DEVICE_VENDOR&gt;()&lt;&lt;std::endl;
  std::cout&lt;&lt;"Device max CU: "&lt;&lt;CQ_device.getInfo&lt;CL_DEVICE_MAX_COMPUTE_UNITS&gt;()&lt;&lt;std::endl;
  
  
  
  cl::Event::waitForEvents(events);
  
  
  //openclObjects.queue[0].finish(); //SR
  std::cout&lt;&lt;"Command Queue 1 complete"&lt;&lt;std::endl;
  //openclObjects.queue[1].finish();//SR added for CQ2
  std::cout&lt;&lt;"Command Queue 2 complete"&lt;&lt;std::endl;
  </code></pre>
  
  <p>//      printf("global_x, global_y, global_y, error: %d %d %d %d\n",global_x, global_y, global_y, err);
  //  printf("%d\n",err);</p>
  
  <pre><code>cl_ulong elapsed=0;
  
  cl_ulong elapsed1=0; //SR calculate elapse per command queue
  cl_ulong elapsed0=0; //SR calculate elapse per command queue
  
  elapsed0 =evt1.getProfilingInfo&lt;CL_PROFILING_COMMAND_END&gt;()-evt1.getProfilingInfo&lt;CL_PROFILING_COMMAND_START&gt;(); //SR
  std::cout&lt;&lt;"Profile Info: Command Queue 1"&lt;&lt;std::endl;
  
  elapsed1 =evt2.getProfilingInfo&lt;CL_PROFILING_COMMAND_END&gt;()-evt2.getProfilingInfo&lt;CL_PROFILING_COMMAND_START&gt;(); //SR
  std::cout&lt;&lt;"Profile Info: Command Queue 2"&lt;&lt;std::endl;
  
  //std::cout&lt;&lt;"elapsed CQ0"&lt;&lt;elapsed0&lt;&lt;std::endl; //SR
  //std::cout&lt;&lt;"elapsed CQ1"&lt;&lt;elapsed1&lt;&lt;std::endl; //SR
  
  elapsed = elapsed0+elapsed1;
  </code></pre>