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
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.
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.
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.
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.
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.
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