Intel® Moderncode for Parallel Architectures
Support for developing parallel programming applications on Intel® Architecture.
1696 Discussions

to hyperthread or not with single threaded application

jorgen
Beginner
440 Views
I am running a single threaded explicit solid mechanics code. A console application with mainly number crunching. Recently we bought a PC with dual Xeon processors. (With hyperthreading enabled the OS believes there are 4 processors.) I need to do a case study with several long (a few days) runs of the same code. (The cases are very similar so they should (approximately) take equal amount of time)

I wonder what will be faster

1) running 2 cases with no-HT and when they finish run 2 more cases or

2) run 4 cases simultaneously with HT enabled.

Trying to read up on the hyperthreading but I have not been able to conclude which will be faster without testing which I have not done yet.

Any comments appreciated.
/jorgen
0 Kudos
4 Replies
jorgen
Beginner
440 Views
I tested a bit by myself.

test case of application described above.

HT disabled. computation time: 138 minutes for 1 case
HT enabled. computation time: 194 minutes for 1 case

slowdown=(194-138)/138 ~= 40%

So in my case I am better off running 4 cases with HT enabled.

hope this is helpful for someone.
/jorgen
0 Kudos
ClayB
New Contributor I
440 Views
Jorgen -
Glad to see you've been able to run some quick tests yourself. Using a specific code will give you better estimates than relying on someone else's experiences (though the latter can be informative).
I'm not sure I understand your conclusion. If you run a single test with and without HT, and the HT run is slower, I would have thought you would arrive at the opposite conclusion. That is, it would be better run with HT off. Was the "1 case" you mention in your test results a single run (of the four you have to do)? Or was the HT on test with two apps running at the same time?
HT works best if your applications are not using all functional units all the time. Think of "bubbles" in the pipelines. A second thread (or process) that is ready to run may be able to fill in those bubbles with its own instructions achieving a speedup in overall execution time for both applications. If your apps are very "dense" and have few bubbles, HT will not be able to give you much of an advantage. There are special cases where HT can be detrimental since the OS scheduler is fooled into thinking there are two separate processors when, in fact, there is a single processor sharing resources with itself.
-- clay
0 Kudos
lspes
Beginner
440 Views
I have maybe a very simple idea of how HT works but I guess that in your test, one solution to increase performance is to run two threads (two jobs similar to your 1 case) but with HT enabled and you should get better performance ...

to check ...
0 Kudos
ClayB
New Contributor I
440 Views

With HT it may be more of a case of higher throughput, than better (raw) performance. That is, if one task takes 5 seconds to run, but with HT on I can get two tasks to run in 8 seconds, my average per task is 4 seconds. I'm getting my per task results slower, but I'm getting two tasks done in less time that it would take to do both in serial.

Running two tasks (or four) in parallel like this may cause problems with memory space and contention for I/O or other shared resources. These problems can be detrimental and may cause my two tasks to run in 12 seconds, which would tell me that these would be better run in serial.

So, it's always best to run some tests, like Jorgen did, before deciding how to utilize HT.

--clay

0 Kudos
Reply