-1

I'm wondering what software must have to take full advantage of hyperthreading? Let's say I have intel cpu with 4physical cores. With hyperthreading the cpu appears to have 8 cores to the OS that is aware of HT technology.So that means the OS can address two independent threads to a single core. So it means the cpu can run 8threads of control 100% parallel divided 2 threads for each core? But however can a single core have more than 1 program counter?


So if the above sentence is true, that means to fully utilize a 4core cpu with HTT the software at least must have 8 programmed threads of control?

lychee
  • 1,771
  • 3
  • 21
  • 31
  • Please ask for clarification if something is not clear, but not just vote down for no reason... – lychee Feb 10 '15 at 14:09
  • I didn't downvote, but the question isn't clear - why are you surprised that an OS can have 8 different threads (which may even come from 8 different processes) at the same time? – Leeor Feb 10 '15 at 22:42
  • Well, what I mean't by software is not OS but applications(Photoshop,Chrome,firefox...), so in order to maximize performance and cpu work, these applications needs at least 8 threads? – lychee Feb 11 '15 at 10:41
  • In order to maximize *their* performance - yes, assuming they can be parallelized (not everything can). For overall system performance - just run 8 applications – Leeor Feb 11 '15 at 17:59

1 Answers1

2

A core can indeed run only one thread at a time. But while running that thread, it may run into idle time when it waits for something, eg. loading code or data from RAM (RAM is much slower than CPU) or wait for a computation of a specific circuit (FPU). Triggering scheduler is not an option because that needs a context swich which is (compared to RAM) very slow. With HT, instead of waiting, it switches to the second prepared thread.

How a core can have multiple program counters? Well, it just have two sets of all registers.

StenSoft
  • 9,369
  • 25
  • 30
  • I don't quite understand what you mean by "Triggering scheduler is not an option because that needs a context swich which is (compared to RAM) very slow." Do you mean context-switch is slower than loading data from RAM to cache and then registers? – lychee Feb 10 '15 at 16:05
  • Do you know how much time each operation consumes? context-swith: 1msec, acessing RAM; 100ns??? + some extra time to load it to cache – lychee Feb 10 '15 at 16:55
  • Accessing RAM costs up to inversion of its frequency, so it it has 1066 MHz, it takes less than 1 µs. Context switch takes several thousand cycles (~ 4,900 according to [this comment](https://stackoverflow.com/questions/5958941/cost-of-context-switch-between-threads-of-same-process-on-linux#comment6873346_5959188)) which would make 1 µs on a 5 GHz core and proportionally more on slower cores. – StenSoft Feb 10 '15 at 17:17