How does the OpenMP runtime determine the best number of threads when omp_set_dynamic is used?
e.g. Are some sort of timing mechanisms used or does the compiler give hints to the runtime of how large the task size is?
omp_get_num_threads() The omp_get_num_threads function returns the number of threads in the team currently executing the parallel region from which it is called.
omp_set_num_threads. Sets the number of threads in upcoming parallel regions, unless overridden by a num_threads clause.
Enables or disables dynamic adjustment of the number of threads available for execution of parallel regions.
omp_get_num_threads. Returns the number of threads in the parallel region. 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. omp_get_thread_num.
I don't think that the OpenMP does determine the 'best' number of threads for an application, in any likely sense of the word 'best'. As @aaa has commented, the runtime's behaviour when omp_set_dynamic
is true is implementation specific.
I don't think that current Fortran/C/C++ compilers could provide information such as timings or task sizes to the runtime.
I believe that this function is available so that schedulers (and similar) can manage programs on machines, for throughput or similar.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With