title: openmp parallelizing code with an internal for loop
body: <p>I'm trying to write a code that runs in parallel hardware using mpi and openmp. I have the following code piece:</p>
  
  <pre><code>#pragma omp parallel for private(k, temp_r)
  for(j=0; j&lt;size; j++){
       temp_r = b[j];
       for(k=0; k&lt;rows; k++){
            temp_r = temp_r - A[j*rows + k] * x[k];
       }  
       r[j] = temp_r;
   }
  </code></pre>
  
  <p>I know this code could be further improved because the internal for loop is a reduction. I can do the reduction for one for loop. But I'm not sure how to go about this since there are two for loops involved here. Any insight would be helpful.  </p>