Cpu cores vs threads

My MacBookPro running BootCamp has an Intel i7-640M processor that has 2 cores. Like all other i7 chips, each core has hyper-threading, so you can have up to 4 threads. Using Visual Studio 2010 c / C ++ to define them:

coresAvailable = omp_get_num_procs ( ); threadsAvailable = omp_get_max_threads ( ) ; 

"threadsAvailable" returns with a value of 4, as expected. But "coresAvailable" is also reported as 4.

What am I missing?

+6
source share
1 answer

omp_get_num_procs returns the number of processors in OS reports, and since the hyper-threading core reports itself as 2 processors, the dual-core hyper-threading chip will be reported as 4 processors.

omp_get_max_threads returns most threads that will be used in a parallel area of ​​the code, so it makes sense that most threads that will be used will have the number of available CPUs.

+11
source

Source: https://habr.com/ru/post/901060/


All Articles