title: OpenCL measure kernels time
body: <p>I have a problem. I have two kernels in the loop, which is at the top. I want to see the total time of all running kernels, even though the first kernel will be run for example 10 times a second for example 5 times. </p>
  
  <p>Thank you very much.</p>
  
  <pre class="lang-c prettyprint-override"><code>for (int arrayLength = minLengthArray; arrayLength &lt;= N; arrayLength *= 2)
  {
      int threadCount = 0;
      int batchSize = N / arrayLength;
      int  GroupCount = (batchSize * arrayLength) / SHARED_SIZE_LIMIT;
      size_t local = SHARED_SIZE_LIMIT / 2;
      size_t global = local * GroupCount;
  
      if (arrayLength &lt;= SHARED_SIZE_LIMIT)
      {
          err = clEnqueueNDRangeKernel(commands, ddEvenMergeSortSharedKernel, 1, NULL, &amp;global, &amp;local, 0, NULL,  NULL);
      }
      else
      {
          clSetKernelArg(oddEvenMergeSortSharedKernel, 5, sizeof(unsigned int), &amp;SHARED_SIZE_LIMIT);
          err = clEnqueueNDRangeKernel(commands, oddEvenMergeSortSharedKernel, 1, NULL, &amp;global, &amp;local, 0, NULL,  NULL);
  
          for (int size = 2 * SHARED_SIZE_LIMIT; size &lt;= arrayLength; size &lt;&lt;= 1)
              for (unsigned stride = size / 2; stride &gt; 0; stride &gt;&gt;= 1)
              {
                  global = batchSize * arrayLength;
                  local = 256;
  
                  err = clEnqueueNDRangeKernel(commands, oddEvenMergeSortGlobalKernel, 1, NULL, &amp;global, &amp;local, 0, NULL,  NULL);
              }
      }
  }
  </code></pre>