title: How to calculate the speedup of a GPU program?
body: <p><strong>Motivation:</strong> I have been tasked with measuring the <a href="http://en.wikipedia.org/wiki/Karp%E2%80%93Flatt_metric" rel="noreferrer">Karp-Flatt metric</a> and <a href="http://en.wikipedia.org/wiki/Parallel_efficiency" rel="noreferrer">parallel efficiency</a> of my CUDA C code, which requires computation of speedup. In particular, I need to plot all these metrics as a function of the number of processors <em><code>p</code></em>.</p>
  
  <p><strong>Definition:</strong> <a href="http://en.wikipedia.org/wiki/Speedup" rel="noreferrer">Speedup</a> refers to how much a parallel algorithm is faster than a corresponding sequential algorithm, and is defined as:</p>
  
  <p><img src="https://i.stack.imgur.com/HChEE.gif" alt="enter image description here"></p>
  
  <p><strong>Issue:</strong> I have implemented my algorithm in <strong>CUDA C</strong>, and have timed it to get <em><code>Tp</code></em>. However, there remains some issues in determining <em><code>Sp</code></em>:</p>
  
  <ul>
  <li>How to observe <em><code>T1</code></em> without completely rewriting my code from scratch?
  
  <ul>
  <li>Can I execute CUDA code in serial???</li>
  </ul></li>
  <li>What is <em><code>p</code></em> when I run different kernels with different numbers of threads?
  
  <ul>
  <li>Does it refer to no. of threads or no. of processors used throughout runtime?</li>
  <li>Since both of these quantities will also vary throughout runtime, is it the maximum or the average used?</li>
  <li>How do I even restrict my code to run on a subset of processors or with fewer threads!?</li>
  </ul></li>
  </ul>
  
  <p>Many thanks.</p>