I want to create one global array of objects (One object per possible thread spawned by OpenMP
) and reuse it throughout the program. Each thread will read its number using omp_get_thread_num
and use it to index into the array.
How can I get the maximum number of OpenMP
threads that may be created during the whole execution of the program?
The documentation of omp_get_max_threads
says that this function is specified to return a value which is specific to the particular parallel region where it was invoked
omp_get_max_threads
– Maximum number of threads of parallel regionDescription: Return the maximum number of threads used for the current parallel region that does not use the clause num_threads.
Whereas the wording of MSDN documentation implies that the value returned by omp_get_max_threads
outside a parallel region is the same value that would be returned in any other point.
omp_get_max_threads
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.
Which one of them is correct?