title: Handling the number of possible threads with openmp collapse
body: <pre><code>int DIMENSION = 4, totalPair = 0;
  #pragma omp parallel for private(sx,dy,dx) 
   for(sy=0; sy&lt;DIMENSION; sy++)
    for(sx=0; sx&lt;DIMENSION; sx++)
     for(dy=0; dy&lt;DIMENSION; dy++)
       for(dx=0; dx&lt;DIMENSION;dx++){ 
      totalPair++;                                                                 
   }
  </code></pre>
  
  <p>This program returns totalPair as 256 with 16 openmp threads.
  However, if I consider the collapse clause as below code, then the returned value becomes 254 with 16 threads. On the other hand, if the number of threads are 4 same as DIMENSION number, then totalPair becomes 256 which is correct. </p>
  
  <pre><code>int DIMENSION = 4, totalPair =0;
  #pragma omp parallel for collapse(4) private(dx) 
   for(sy=0; sy&lt;DIMENSION; sy++)
    for(sx=0; sx&lt;DIMENSION; sx++)
     for(dy=0; dy&lt;DIMENSION; dy++)
      for(dx=0; dx&lt;DIMENSION;dx++){ 
      totalPair++;                                                                 
   }
  </code></pre>
  
  <p>And, even the case of below, returns totalPair as 255 with 16 threads. So, I wonder that using collapse the max allowed thread number will be equal to possible iteration count of the last loop.</p>
  
  <pre><code>int DIMENSION = 4, totalPair =0;
  #pragma omp parallel for collapse(2) private(dy,dx) 
   for(sy=0; sy&lt;DIMENSION; sy++)
    for(sx=0; sx&lt;DIMENSION; sx++)
     for(dy=0; dy&lt;DIMENSION; dy++)
      for(dx=0; dx&lt;DIMENSION;dx++){ 
      totalPair++;                                                                 
   }
  </code></pre>