Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

cpu cores vs threads

My MacBookPro, running BootCamp, has an Intel i7-640M processor, which has 2 cores. Like all the other i7 chips, each core is hyperthreaded, so you can have up to 4 threads. Using Visual Studio 2010 c/c++ to determine these:

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

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

What am I missing?

like image 842
PaeneInsula Avatar asked Nov 08 '11 19:11

PaeneInsula


People also ask

Are more cores or threads better?

The advantage of having several cores is that each core can handle a different data thread simultaneously, allowing for a much quicker transfer of data at any given time. A high clock speed means faster processor.

What is more important in a CPU cores or threads?

Up to a certain amount, more cores is more important to most users, even those with a program or two that relies on a single thread for itself. The operating system runs more than one thread, no matter which personal programs you use.

What does 4 cores and 8 threads mean?

A i7-2670QM processor has 4 cores. But it can run 8 threads in parallel. This means that it only has 4 processing units (Cores) but has support in hardware to run 8 threads in parallel.

What is the difference between CPU core and thread?

Threads are the virtual components or codes, which divides the physical core of a CPU into virtual multiple cores. A single CPU core can have up-to 2 threads per core. For example, if a CPU is dual core (i.e., 2 cores) it will have 4 threads.


1 Answers

omp_get_num_procs returns the number of CPUs the OS reports, and since a hyperthreaded core reports itself as 2 CPUs, a dual-core hyperthreaded chip will report itself as 4 processors.

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

like image 153
Gabe Avatar answered Sep 29 '22 05:09

Gabe