How can I get the maximum number of OpenMP threads that may be created during the whole execution of the program?
<p>I want to create one global array of objects (One object per possible thread spawned by <code>OpenMP</code>) and reuse it throughout the program. Each thread will read its number using <code>omp_get_thread_num</code> and use it to index into the array.</p>

<p>How can I get the maximum number of <code>OpenMP</code> threads that may be created during the whole execution of the program?</p>

<p>The documentation of <a href="https://gcc.gnu.org/onlinedocs/libgomp/omp_005fget_005fmax_005fthreads.html#omp_005fget_005fmax_005fthreads" rel="nofollow"><code>omp_get_max_threads</code></a> says that this function is specified to return a value which is specific to the particular parallel region where it was invoked</p>

<blockquote>
  <p><code>omp_get_max_threads</code> – Maximum number of threads of parallel region</p>
  
  <p><strong>Description:</strong> Return the maximum number of threads used for the current parallel region that does not use the clause num_threads. </p>
</blockquote>

<p>Whereas the wording of <a href="https://msdn.microsoft.com/en-us/library/62akecca.aspx" rel="nofollow">MSDN documentation</a> implies that the value returned by <code>omp_get_max_threads</code> outside a parallel region is the same value that would be returned in any other point.</p>

<blockquote>
  <p><code>omp_get_max_threads</code></p>
  
  <p>Returns an integer that is equal to or greater than the number of threads that would be available if a parallel region without num_threads were defined at that point in the code.</p>
</blockquote>

<p>Which one of them is correct?</p>