Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

OpenMP omp_get_max_threads() return value

Does omp_get_max_threads() return the value of $OMP_NUM_THREADS when OMP_NUM_THREADS environment variable is defined?

It look like so on my system (Linux/gcc). Even if OMP_NUM_THREADS is set to a ridiculously high value…

Calling it in the beginning of main, i.e., not inside any (nested) parallel region (if it makes a difference).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

You are right that omp_get_max_threads() returns the value of OMP_NUM_THREADS. And you can set this as high as you want: a thread is a software construct and has nothing to do with the number of cores you have. For that, use omp_get_num_procs(). Normally it wouldn’t make much sense to have more threads than cores, but it could: if the work in the threads is very different, or threads can pause because of locks and such, you could get a higher processor utilization by having more threads.

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading