Reputation: 3086
Are the modern multi-core processors really doing parallel processing?
Like, take for example, Intel's core i7 processors. some of them has #of Cores: 4
and #of Threads: 8
(taken from Intel's specifications pages). If I to write a program (say in Java or C) that has multiple threads of execution, will they really be processed concurrently? My instructor said that "it is not always the case with multi-core processors", but didn't give too much details.
And why do Intel have to specify both #of Cores and #of Threads? Isn't thread just a term that describe a program-related abstraction, unlike "cores" which are actual hardware? ("Every thread runs on different core").
Upvotes: 1
Views: 904
Reputation: 567
Warren Dew's answer turns out to be misleading, at least for some multi-processor machines. For instance, when I implemented the usual work-stealing scheduler on a machine with 32 cores each supporting up to 8 logical processors (via hyper-threading), the peak throughput was somewhere between 64 and 128 worker threads. This can only be explained if hyper-threading can truly yield a higher throughput than having just one thread per core, because the difference in speedup is really substantial, going from ×20 to ×29 when increasing from 32 to 64 worker threads.
Upvotes: 0
Reputation: 8938
Yes, modern multicore processors are really doing parallel processing, on appropriate tasks and provided the software is properly written to permit it. I have personally tested multithreaded software with a configurable number of threads, and watched the throughput increase proportional to the number of threads until that number was equal to the number of cores: on a four core processor, one thread completed one task in a certain amount of time, and four threads completed four tasks in the same amount of time, a quadrupling of throughput. With additional threads beyond the number of cores, there was no further increase, and in fact a slight decrease: eight tasks on eight threads took more than twice the amount of time to complete than did four tasks on four threads. It was faster just to use four threads and have them each process two tasks in a row.
However, and this may be what your professor is referring to, just having multiple threads does not guarantee that you will be taking advantage of multiple cores. For example, the threads may be limited by contention on a shared resource - say, a piece of memory they all needed to access. They could also be contending for a shared I/O resource, like disk access or network access. In some of these cases, running more than one thread at a time may not improve things, and may actually decrease total throughput.
Finally, the "number of threads" and "number of cores" numbers are different because of Intel's "hyperthreading" architecture, which supposedly allows each core to run two threads at a time. In my experience, hyperthreading is not very useful in the real world: for example, in the test I described above, the cores were hyperthreaded Intel cores, but the peak throughput still occurred when I ran a number of threads equal to the number of physical cores, and dropped when I ran a number of threads equal to Intel's claimed thread capacity. I find it best to pay attention to the number of cores and ignore Intel's "number of threads" claim.
Upvotes: 3