Why is my dual-core CPU recognized as a quad-core one?

52

6

My processor is an Intel Core i3-380m. As you can see, it's 2 cores and 4 threads.

Although, both Ubuntu 11.04 and Windows 7 seem to think it's a quad-core CPU:

enter image description here

enter image description here

Why is this? Is it because there are 2 threads per core, dividing the CPU in 4 processing units?

seriousdev

Posted 2011-08-30T16:20:46.660

Reputation: 1 320

Answers

43

As mentioned you have a dual-core system, with 2 threads per core.

This is marketed by Intel as hyperthreading and has been done in various ways over the years by various different manufacturers.

To explain it in its simplest form each CPU core consists of a "core" and various architecture around that core that keeps state and process information for each thread. A single threaded core has the architecture to keep 1 thread worth of state information held at a time, a hyperthreaded core keeps two distinct sets of state information, allowing two separate processes to run at once as long as they require different parts of the core (which is reasonably likely to happen as the core consists of multiple units of multiple different types of processing unit).

To simplify how the CPU is seen to the system each hyperthread is seen as a separate CPU, so a dual core, 2 thread per-core processor appears as a quad core processor.

It is also possible for the operating system to use Core-parking (a feature in newer Intel processors) allows the operating system to suspend one half of a hyperthreaded core so that when the extra processing ability of hyperthreading is not needed then the single thread performance is increased as the core is no longer sharing it's cache across 2 threads and can now fully devote the on-core cache to a single thread.

Mokubai

Posted 2011-08-30T16:20:46.660

Reputation: 64 434

@Mokubai core-parking link does not work. – Biswapriyo – 2018-04-01T19:58:52.710

Thanks for the explanation. So, can we say here that a thread is to a core what a core is to a processor? – seriousdev – 2011-08-30T16:37:17.810

2In a way, yes. The OS sees the processor, knows how many cores are on that processor and in turn how many threads each core supports, from that the CPU usage you are seeing is now "per-thread" rather than "per core". It's not quite that simple (as each thread does actually appear to a non-hyperthreading aware OS as a fully fledged CPU core) but that is the general idea of it. – Mokubai – 2011-08-30T16:46:18.470

49

The reason is hyperthreading, which your processor supports. Hyperthreading isnt the equivalent of an extra processor, but can really boost performance on multithreaded applications. For each processor core that is physically present, the operating system addresses two virtual processors, and shares the workload between them when possible.

Keltari

Posted 2011-08-30T16:20:46.660

Reputation: 57 019

7Is this known as physical vs logical cores? – xdumaine – 2011-08-30T16:39:04.767

@roviuser - Yes. – Shinrai – 2011-08-30T16:52:23.863

11Yes, a physical core is - well... physical. You can touch it. Hyperthreaded cores arent real, hence logical. You can break physical cores into logical cores through virtualiztion, also. – Keltari – 2011-08-30T17:39:11.037

3

@Keltari actually, there is a physical part to it... Hyperthreading is a hardware component in a CPU core (and can only be disabled on a hardware level). See this Intel whitepaper for details. Basically, it shares a core's resources between two physical execution units. Technically, both cores seen by the OS in a hyperthreaded core are "logical", there isn't both a physical and logical one.

– Breakthrough – 2011-08-30T19:53:43.647

1true, hyperthreading is a physical part of the processor, but not a physical core. – Keltari – 2011-08-30T19:55:54.493

1The best way to think of HT is a "core-and-a-half" it shares many more resources with its brother than the seperate cores do. However it is capable of executing a thread "on its own" and the OS treats it as a thread execution unit (which you associated with a core). – crasic – 2011-08-31T00:22:50.330

@crasic I'm sorry, but hyperthreading is not even close to a "core and a half" (and indeed, performance gains are barely above 16-28%), and while HT allows multiple thread execution at once, it is far from "on it's own" since each thread shares that core's cache (imagine trying to run two entirely different program's threads on the same hyperthreaded core - that's why I say it's far from on it's own). – cp2141 – 2011-08-31T17:20:13.083

12

Things are a lot more complex than they were in the days of one cpu instruction per one clock cycle.

There's now a pipeline for each instruction that consists of a number of steps. I've heard as many as 41, though that was a while ago and I have no idea what current cpu pipelines look like. I do know that if the pipeline is long enough, you can start a new instruction down the pipeline before the last instruction has finished, sometimes in the same clock cycle, so that your single core is effectively doing two things at once.

There's a trick here, though. You can't just use this to speed up the rate at which your processor chews through instructions from a specific program. There's a correctness issue involved: the next instruction might depend on the as-yet-undetermined result of the prior instruction. To take advantage of the long pipeline safely, the chip will present two separate processor cores to the operating system scheduler, and alternate instructions sent to each core so that two instructions to the same "core" are never in the pipeline at the same time. This way it we can be sure that any instructions executed simultaneously will not interfere with each other. This is called hyperthreading.

It's worth noting here that while hyperthreading can significantly increase the amount of work you get out of your cpu, it's nowhere near as good as having that many physical cores. Depending on your work-load, it might means as little at 15% improvement or as much as 40% improvement. In some circumstances, you may even want to disable the feature so that the remaining cores have full exclusive access to the L1/L2 cache for that core (this is sometimes done with dedicated database servers).

When your chip advertises itself as having 2 cores with 4 threads, that means it's a dual core processor that supports hyperthreading.

Joel Coehoorn

Posted 2011-08-30T16:20:46.660

Reputation: 26 787

2

Take a look at this intel page- it has lots of animations showing how hyperthreading speeds up your tasks.

The Utilization of Processor Resources is the best animation, look at it and them click the "advance" button.

woliveirajr

Posted 2011-08-30T16:20:46.660

Reputation: 3 820

1

Why is this? Is it because there are 2 threads per core, dividing the CPU in 4 processing units?

Putting this simply, the answer is yes. Each core of your cpu can support two independent threads, so 4 in total. But it doesn't mean it has the same performance as a quad-core single-threaded cpu. practically the performance of a dual-core double-threaded cpu is lower than that of a quad-core single-threaded cpu. Like the AMD Phenom X4.

aminfar

Posted 2011-08-30T16:20:46.660

Reputation: 139

Do you know why? – seriousdev – 2011-08-30T21:09:32.103

1The reason is that in a double-threaded core the hardware resources (like reorder buffer) is shared between two threads, while in a single-threaded cpu all resources are dedicated to one core. It's worth mentioning that having a mulch-threaded core increases your hardware utilization and throughput, but it's bad for latency. There are many trade-offs involved. So the word "performance" is really vague here. For ordinary people it means the latency of a single thread. – aminfar – 2011-08-30T22:17:39.450