title: CUDA: Difference between CPU timer and CUDA timer event?
body: <p>What is the difference between using a <strong>CPU timer</strong> and the <strong>CUDA timer event</strong> to measure the time taken for the execution of some CUDA code?<br />
  Which of these should a CUDA programmer use？<br />
  And why?</p>
  <hr />
  <p><em>what I know</em>:</p>
  <p><strong>CPU timer</strong> usage would involve calling <code>cudaThreadSynchronize</code> before any time is noted.
  For noting the time, one of these could be used:</p>
  <ol>
  <li><code>clock()</code></li>
  <li>high-resolution performance counter like <a href="http://msdn.microsoft.com/en-us/library/ms644904.aspx" rel="nofollow noreferrer"><code>QueryPerformanceCounter</code></a> (on Windows)</li>
  </ol>
  <p><strong>CUDA timer event</strong> would involve recording before and after by using <code>cudaEventRecord</code>. At a later time, the elapsed time would be obtained by calling <code>cudaEventSynchronize</code> on the events, followed by <code>cudaEventElapsedTime</code> to obtain the elapsed time.</p>