Hi,
srg wrote:I've heard that Hypertheadding only works like this if one thread is doing integer math and the other is doing fp at any one time.
Not really. The problem with modern CPUs is that there's many reasons for "pipeline stalls", including waiting for data to come from memory, situations where one instruction needs to wait for the results of a previous instruction, branch mis-prediction and situations where the pipeline/s needed for an instruction are in use.
The idea of hyper-threading is to execute multiple unrelated instruction streams at once, so that if one instruction stream is stalled for any reason the other can continue.
For example, if the code reads from memory (and the data isn't in the cache) it can take a relatively large amount of time for the data to become available. Without hyper-threading this can leave the CPU with nothing to do.
That's why the actual performance improvement of hyper-threading can't be easily predicted - it depends on what each stream of instructions is actually doing. If both streams are using different pipelines (e.g. if one stream is doing integer math and the other is doing fp), or if both streams spend a lot of time waiting for data from memory (e.g. working on large arrays with random access patterns) then you'd get a very good improvement.
If both streams are highly optimized to avoid all pipeline stalls, then HT won't help at all. In practice it's very rare for this to happen though.
Performance increase associated with HT is estimated to be between 5% and 60%. This is total performance increase, rather than the performance of a single instruction stream (which is reduced rather than improved, as the same CPU's resources are shared).
This has led to people using poorly written (single threaded) applications commenting that hyper-threading makes the application run slower. It'd be the same if you compared a computer with a single 2 GHz CPU to a computer with a pair of 1.4 GHz CPUs.
Cheers,
Brendan