Jump to content
  • Advertisement
Sign in to follow this  
Amr0

Multithreading Nowadays

This topic is 959 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi. I don't have intensive HW knowledge, but I've noticed that a lot of the rather recent intel CPUs I've looked at don't have HyperThreading support, and the specs say the number of threads is equal to the number of cores. Does that mean dividing the processing work in my application (like doing physics calculations that don't involve IO/networking) into multiple threads will not provide any performance benefits, and that multi-processing is where the gains can be had? Thanks.

Share this post


Link to post
Share on other sites
Advertisement

Hyperthreading can also be a double edged sword at times. It is like a second processor core, but not exactly the same thing. I really haven't done much work with hyperthreaded processors, and all that I honestly remember about the edge cases is that they exist. If you are going to start programming things with an aim at providing strong support for Intel's tech then it is probably a good idea to spend some time digging around with google for the various pitfalls of hyperthreading.

Share this post


Link to post
Share on other sites

I avoid threading as much as possible, but the one thing I remember about hyperthreading was that it's mostly fake, since you got only about 30% CPU power. In other words, you had the choice between 1 thread @ 100%, or 2 threads @ 65% each.

Share this post


Link to post
Share on other sites

Don't forget about potentially thrashing the cache thus reducing performance on your "main" thread.

Edited by Infinisearch

Share this post


Link to post
Share on other sites

I think at least for games, another significant problem with hyperthreading is that many workloads don't scale perfectly with core count. See https://en.wikipedia.org/wiki/Amdahl's_law for one cause of poor scaling.

 

That is, even if you compare say two core performance to four core performance without any hyperthreading, then the four cores probably won't be exactly double the speed of two cores. It might get say 1.8 times faster instead.

 

This means that the performance benefit from hyperthreading has to be higher than the overheads from using more threads, if it's going to actually improve performance.

Share this post


Link to post
Share on other sites

I think at least for games, another significant problem with hyperthreading is that many workloads don't scale perfectly with core count. See https://en.wikipedia.org/wiki/Amdahl's_law for one cause of poor scaling.

 

That is, even if you compare say two core performance to four core performance without any hyperthreading, then the four cores probably won't be exactly double the speed of two cores. It might get say 1.8 times faster instead.

 

This means that the performance benefit from hyperthreading has to be higher than the overheads from using more threads, if it's going to actually improve performance.

Even without hyperthreading, you often have a measurable benefit from using more threads than cores because there's always a busy thread to swap in. Especially when your application has different workloads, instead of always doing the same computation for different data. In a way, Hyperthreading is just a way to make this more efficient through hardware. However, with hyperthreading or without, the optimal number of worker threads is something you can often measure directly; knowing about hyperthreading just explains the results.

Share this post


Link to post
Share on other sites


Even without hyperthreading, you often have a measurable benefit from using more threads than cores because there's always a busy thread to swap in.
This is situation-dependent of course, but my experiences on my current project disagree. If I've got more threads than cores, then the overhead of the extra context-switches seems to create an overall performance loss. I found that when running my threads with 100% workloads (no idle time), performance of my game, and system-wide OS responsiveness suffered greatly if I created one thread per HW-thread.

On Intel Hyperthreaded CPU's, I've ended up running with one thread per core (not two!), and on other CPU's, I run one thread per core minus one (e.g. on an 8-core, I'll run 7 threads), which leaves a bit of extra CPU time spare for the OS and other applications to use, even if I'm maxing out my threads with 100% workloads.

 

Note that that's my "main & worker" threads anyway. I also have a bunch of extra "mostly sleeping" threads - e.g. middleware like FMOD, or your NVidia graphics drivers will create a bunch of it's own threads internally -- which can also run on that spare AMD core, or the Intel "hyperthreads" :)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!