Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

AdColvin

macrumors newbie
Original poster
Nov 16, 2010
2
0
Preston, England
My understanding was that a multi-core processor allowed for computing tasks be performed simultaneously. Rather than one after another, which is what a single-core processor would do. This is often applied within the applications themselves, to increase execution speed. Such applications being multi-threaded applications.

But I've recently learnt that even single core processors can execute code in more than one thread. So in this sense, what extra functionality does having multiple cores give you? Or am I wrong in thinking that single core processors can do this too?

There's a hole in my understanding somewhere, I just don't know where it is.

Any info appreciated.

Many thanks,
Adam
 
Heat up rooms very nicely, when being pushed. :)

I think it's the degree of multi-tasking. Also, even if a program is multithreaded, perhaps it may only be able to use one core. But two programs could each use one core in dual core chips. Perhaps?
 
But I've recently learned that even single core processors can execute code in more than one thread

in rapid succession as such.
Multithreaded_process.svg


so a multicore system just allows it to compute several things at once, rather then as above.
 
Last edited:
A modern processor is usually divided up into lots of different processing units. They have general integer units, floating point units, MMX/SSE vector units (similar to the old AltiVec in G4) and others, all combine onto one chip and one processor.

A processor normally works on one instruction at a time, with others queued in a pipeline. If the instruction is an integer instruction, it uses the integer unit, but ties up the entire processor.

A multithreaded processor (commonly known as the Intel term hyperthreading) allows more then one instruction into the processor to use the unused units. So an integer instruction could be run at the same time as an SSE instruction.

Multi core means that the single silicon die has multiple processors on it. For example, a dual core processor will have two full integer units on it, and allow two integer instructions to be computed at the same time. A single core with hyperthreading could only allow two instructions of differing types to run at the same time.

Hyperthreading can then be applied to a multi core processor, allowing even more instructions to run in parallel. The Core i7 does this, along with the processors in the 2009/2010 Mac Pro.
 
A multithreaded processor (commonly known as the Intel term hyperthreading) allows more then one instruction into the processor to use the unused units. So an integer instruction could be run at the same time as an SSE instruction.

so your telling me that given the right circumstances a HT CPU could perform twice that of its single threaded cousin?
 
The way i think about this..

For a single core processor, this is how we would execute 3 instructions.
1. Pass 1st instruction
2. Wait for 1st instruction to finish processing
3. Pass 2nd instruction
etc..

What multi-core lets a processor do is cut up its total resources into multiple parts (cores), so that it can execute multiple instructions in parallel. This way, instructions that are finished earlier leaves a core "free" to execute the next waiting instruction (unlike single threaded mode). It's a more efficient use of resources, and it ties into power management so that cores we don't use can be powered down.

It's like taking a processor and cutting it up into 2, 4, 8 parts so that we can now manage these parts separately. More granular control, means more power savings, and more efficient instruction execution.

MacRumors members please chime in if I have this wrong!
 
so your telling me that given the right circumstances a HT CPU could perform twice that of its single threaded cousin?
Thread load/execution/unload efficiency could translate into 2x performance, given the right load and conditions (ie: temperature)..
 
But I've recently learnt that even single core processors can execute code in more than one thread. So in this sense, what extra functionality does having multiple cores give you? Or am I wrong in thinking that single core processors can do this too?

Single core, non-hyperthreaded: You're doing your taxes. The phone rings. You pick up all your papers and the calculator with your figures and put them in the next room over. Then you come back and pick up the phone. When you hang up, you have to go back and get your stuff before you can continue. This is called a "context switch".

In an operating system, this involves putting the contents of the processor's registers in a "stack". That stack is stored in system RAM, so there's a slight delay while the contents are retrieved from memory. Even if you have a fast memory bus, it's slower than your CPU so it's going to be twiddling it's thumbs in the meantime.

Single core, hyperthreaded: Same thing, but you move your paperwork to a table next to you instead of a different room. When you're done with your call, you just grab everything from the table.

Intel's hyperthreaded processors keep a second set of registers for quick access during context switches. Some context switches still need to go out to RAM and back, but not all.

Edit: This is my understanding of HT. It sounds like some other folks in this thread know what's going on in more detail. I'll defer to their expertise.

Dual core: The phone rings and your spouse answers the phone. You keep doing your taxes.

A multicore system has two or more processing cores, more or less complete CPUs, that may or may not be hyperthreaded. They work independently, but share one bus connected to memory.
 
A multi-core processor is almost literally more processors. Here is a die shot of an Intel Core i5 Quad Core:

i5die.jpg


You get four execution cores instead of one. Four instruction decoders, four banks of L1 and L2 cache, and in this case a thread for each core (as this is a quad core i5).

How does a single thread processor compute multiple tasks at once? It is abstracted in software. The operating system manages what goes on the main thread, when, and with what priority. This is why in an older OS (classic anybody?) when you pulled down a menu, everything just stopped happening... the OS was not capable of managing multiple tasks properly. Everything just had to wait.

Sometimes having multiple threads doesn't get you anything. Many applications do not support multiple threads, therefore the OS can only do so good a job splitting up the workload. Two threads can still be useful with single threaded applications because all of the background tasks can be put on the second thread while the app consumes the entire first thread.

However, sometimes having many threads gets you a lot. My profession involves a lot of 3D rendering, which is highly parallelized. This means that each thread can be given its own full workload, thus allowing the render to be completed many times faster.

If we are talking threads though, a complexity comes up. Something that has actually been around for a long time: Hyperthreading. Basically, what happens if the chip is very fast, and you cannot get enough data to it on one thread to saturate it? You end up wasting processing power. Hyperthreading takes each real physical core, and abstracts it so that the operating system sees two threads. The operating system can then load tasks on to two threads, and so the extra potential of the core is unlocked. In the case of Core/Nehalem, the wide front end of that architecture is better served by multiple threads. They are not a replacement for a real core, and the speed boost is ~25% on a good day. But that is performance that would be lost otherwise.

Why does the i5 quad core only have four threads (no hyperthreading), and the i7 quad core have eight threads (hyperthreading)? Marketing, pure and simple.
 
Single core, hyperthreaded: Same thing, but you move your paperwork to a table next to you instead of a different room. When you're done with your call, you just grab everything from the table.

Intel's hyperthreaded processors keep a second set of registers for quick access during context switches. Some context switches still need to go out to RAM and back, but not all.

Edit: This is my understanding of HT. It sounds like some other folks in this thread know what's going on in more detail. I'll defer to their expertise.

thats my and wikipedias understanding too - why i was questioning drakinos statement
Wikipedia said:
Hyper-threading works by duplicating certain sections of the processor—those that store the architectural state—but not duplicating the main execution resources. This allows a hyper-threading processor to appear as two "logical" processors to the host operating system, allowing the operating system to schedule two threads or processes simultaneously. When execution resources would not be used by the current task in a processor without hyper-threading, and especially when the processor is stalled, a hyper-threading equipped processor can use those execution resources to execute another scheduled task. (The processor may stall due to a cache miss, branch misprediction, or data dependency.)
http://en.wikipedia.org/wiki/Hyper-threading
 
Here is how to think about it...

Every thread is a car, every core is a lane...

If you have a road, you can fit 80 cars onto one lane. Everything will just move really slowly.

If you want to speed up the traffic, you can keep adding lanes, and spread out the cars.

However, if you only have one car, there isn't any point in adding more lanes, as it won't speed up the single car.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.