Question

My Intel CPU has 6 cores and 12 threads. I know that each core can do computation in parallel to other 5 cores. Thus, if I run a program on every 6 core, I get a 6 times speed up. But I cannot understand how that relates to threads. If I run my program on 12 threads of my 6 cores, will I get a 12 times speed up?

Was it helpful?

Solution

A thread is a "logical core", it has a full set of registers, uses its own virtual address space, and can perform anything a core can do, so in that sense - you have 12 cores.

However, a thread shares most of it's execution resources with its counterpart thread on the same core. Since modern cores can handle multiple instructions at the same time, having two (or more) threads allows you to essentially "throw" instructions from the 2 software threads into a large "pool", and have them executed whenever they're ready. If you have a single thread taking up full 100% of your core utilization, then you won't gain much from that, but if one of the threads leaves some empty slots, because it has branch mispredictions, data dependencies, long memory delays, or any other cause for inefficiency - the other thread sharing the core can use these slots instead, giving you a nice boost (since the alternative was to wait until the first thread finished its time slot and doing an expensive context switch).

In general, you can think of that in the following way - running 2 software threads on 2 cores would give you the best performance, running them on a single core with simultaneous multithreading would be slightly slower, especially in case you're bounded on execution (but less so if you're bounded for e.g. on memory latency). However if you don't have this feature, running the same 2 workloads on a single core would require you to run them one after the other (in timeslots), which would probably be much slower.

Edit: note that there are different ways of implementing this concept, see for e.g. - Difference between intel and AMD multithreading

OTHER TIPS

A thread is a "simultaneous" computation on the same core. So one core can manage two threads and effectively acts as two cores. This is a very basic answer I'm afraid.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top