title: Measuring execution time of OpenCL kernels
body: <p>I have the following loop that measures the time of my kernels:</p>
  
  <pre><code>double elapsed = 0;
  cl_ulong time_start, time_end;
  for (unsigned i = 0; i &lt; NUMBER_OF_ITERATIONS; ++i)
  {
      err = clEnqueueNDRangeKernel(queue, kernel, 1, NULL, &amp;global, NULL, 0, NULL, &amp;event); checkErr(err, "Kernel run");
      err = clWaitForEvents(1, &amp;event); checkErr(err, "Kernel run wait fro event");
      err = clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_START, sizeof(time_start), &amp;time_start, NULL); checkErr(err, "Kernel run get time start");
      err = clGetEventProfilingInfo(event, CL_PROFILING_COMMAND_END, sizeof(time_end), &amp;time_end, NULL); checkErr(err, "Kernel run get time end");
      elapsed += (time_end - time_start);
  }
  </code></pre>
  
  <p>Then I divide <code>elapsed</code> by <code>NUMBER_OF_ITERATIONS</code> to get the final estimate. However, I am afraid the execution time of individual kernels is too small and hence can introduce uncertainty into my measurement. How can I measure the time taken by all <code>NUMBER_OF_ITERATIONS</code> kernels combined?</p>
  
  <p>Can you suggest a profiling tool, which could help with this, as I do not need to access this data programmatically. I use NVIDIA's OpenCL.</p>