Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

OMP - more threads than the number of processors?

Tags:

c++

c

openmp

By default OpenMP directive:

opm_get_num_threads gives number of threads equivalent to processors/cores.

I have an 8 core machine, so it gives me 8 threads. Is that the maximum? Can I get more threads than 8, if I deliberately specify more than 8?

Thanks

like image 300
Benny Avatar asked Jul 27 '12 16:07

Benny


People also ask

Is it possible to have more threads than cores?

Threads typically wait until the os allows them to run. OSs typically have a scheduler that schedules various threads to run as resources are available. Also, it must be taken into account that in a modern operating system, there are many, many threads running, way more than cores.

Is it better to have more threads than cores?

Cores increase the amount of work accomplished at a time, whereas threads improve throughput, computational speed-up. Cores is an actual hardware component whereas thread is a virtual component that manages the tasks. Cores use content switching while threads use multiple CPUs for operating numerous processes.

What does it mean if a processor has more threads?

Threads refer to the highest level of code executed by a processor, so with many threads, your CPU can handle several tasks at the same time. All CPUs have active threads, and every process performed on your computer has at least a single thread.

How many threads can I use in OpenMP?

First of all,you can't run more than 8 threads. Second,resort to nested parallelism if nothing else works as openmp has to improve a lot in this aspect.


1 Answers

You can set as many threads as you want with:

int threads = 16;
omp_set_num_threads(threads);

http://msdn.microsoft.com/en-US/library/e16bady3%28v=vs.80%29

But be sure you are aware of the drawbacks of using more threads than there are logical cores in the system.

like image 113
Mysticial Avatar answered Oct 09 '22 01:10

Mysticial