title: OpenMP to CUDA: Reduction
body: <p>I'm trying to figure out how I can use OpenMP's <code>for reduction()</code> equivalent in CUDA.  I've done some research online, and none of what I've tried worked.  The code:</p>
  
  <pre><code>    #pragma omp parallel for reduction(+:sum)
      for (i = 0; i &lt; N; i++)
      {
          float f = ...  //store return from function to f
          out[i] = f;    //store f to out[i]
          sum += f;      //add f to sum and store in sum
      }
  </code></pre>
  
  <p>I know what <code>for reduction()</code> does in OpenMP....it makes the last line of the for loop possible.  But how can I use CUDA to express the same thing?</p>
  
  <p>Thanks!</p>