Skip to main content
GameDev.net gamedev.net
🔒 Locked

hypertreading

Started by Raab314159 Mar 26, 2004 at 7:45 AM 11 replies 1.9k views
Original Post
Raab314159
Raab314159
Hi, Do you know about hypertreading? Any tutorials? [edited by - Raab314159 on March 26, 2004 8:46:11 AM]
tok_junior
tok_junior
There isn''t anything you need to know about hyperthreading, except it''s good for multithreaded apps.
So keep using threads where it''s usefull, threading''s what hyperthreading handles.
Raab314159
Raab314159
quote:
Original post by tok_junior
There isn''t anything you need to know about hyperthreading, except it''s good for multithreaded apps.
So keep using threads where it''s usefull, threading''s what hyperthreading handles.



So, to increase the performance of a program you simply split it in as many threads as possible?

Promit
Promit
There are way more issues with threading and hyper threading than simply splitting an app into multiple threads.

You don''t code for hyper threading. You code for threads in a way that makes sense. If it doesn''t make sense for your prog to be multithreaded, it won''t help you to make it multithreaded and run on a hyper threaded processor.
SlimDX | Ventspace Blog | Twitter | Diverse teams make better games. I am currently hiring capable C++ engine developers in Baltimore, MD.
Agony
Agony
quote:
Original post by Raab314159 ...split it in as many threads as possible?

And even if your progrm could be easily multithreaded, you don''t want to split it up as much as possible. Hyperthreading, if I remember right, can only do a few things at the same time; maybe even only two, so any more threads than that, and you''d not be increasing your performance anyway. A program running 32 threads on one single hyperthreaded processor, when it could be doing the same thing in 2 threads, is going to be absolutely insane.


int Agony() { return *((int*)0); }    Mwahaha... >8)
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas nly, and not for things themselves." - John Locke o
amag
amag
quote:
With only a few executing threads, mostly not CPU-bound, this cost isn't a problem on a GHz machine. But if your application creates 20 threads on a single CPU machine and each of them is generating prime numbers, you will start to notice the overhead of context switching.


Hmm, I have >250 threads and 30 processes running on my machine right now, I guess the kernel is doing some context-switching as I write this message. I'm not sure whether any of them are generating prime-numbers but that's not the point. The point is that Windows (any version >=95) is a preemptive multitasking OS, even if your application runs in a single thread, you'll still have context-switches. Of course creating more threads doesn't help, but it won't do much more overhead either.

That said, if you (the OP) want to speed up your program, randomly splitting it up into threads is NOT the way to go. If you read up on concurrent programming and multithreading (etc), you'll learn when to use threads and when not to use threads. Until then, stick to one thread!

[edited by - amag on March 26, 2004 6:31:55 PM]
Shannon Barber
Shannon Barber
If your app is written correctly, it will only be placed in the scheduling queue when and if it has work to do (i.e. Event Driven, No Polling!).

The timer interrupt still fires all the time, and Windows checks from 50 to 100 times per second to see if it should switch threads, but it won''t switch threads if it doesn''t need to.
The trade-off between price and quality does not exist in Japan. Rather, the idea that high quality brings on cost reduction is widely accepted.-- Tajima & Matsubara
Agony
Agony
quote:
Original post by amag
Hmm, I have >250 threads and 30 processes running on my machine right now...

And probably none of them are doing any intensive computations, or at most one or two of them are. However, I am guessing that the intention of the original question was to speed up a general computationally complex algorithm. If you had 30 threads, all of which that wanted as much CPU time as possible, then the context-switching would become significant, and would degrade your performance. If you have 30 threads that all only need around 2% of the CPU''s power, then you''re not going to have a problem at all. Context switching has another 40% of the CPU to work with. And most threads use much less than 2% of the CPU these days. But attempting to speed up processor-hungry algorithms by splitting it into more threads than you have separate (possibly simulated) processors will fail in almost all, if not all, cases.
"We should have a great fewer disputes in the world if words were taken for what they are, the signs of our ideas nly, and not for things themselves." - John Locke o
CGameProgrammer
CGameProgrammer
At the moment I have 309 threads, but I certainly do not have 309 threads actually running. Instead, there are simply 309 threads that were created and not yet destroyed. But applications, and their threads, spend most of their time idle, meaning they told the OS not to run their code until they receive a message (at least that''s how Windows works). So a word processor will do nothing until the user presses a key or uses the mouse, and if you Alt+Tab out of a game, its code will stop running until you switch back to it, if it''s decently programmed.

That''s why, in Windows XP, you can see nearly all of the processes are using 0% of the CPU.

~CGameProgrammer( );

Screenshots of your games or desktop captures -- Upload up to four 1600x1200 screenshots of your projects, registration optional. View all existing ones in the archives..
~CGameProgrammer( ); Developer Image Exchange -- New Features: Upload screenshots of your games (size is unlimited) and upload the game itself (up to 10MB). Free. No registration needed.
aboeing
aboeing
hyperthreading info (more than you can poke a stick at

http://www.intel.com/cd/ids/developer/asmo-na/eng/microprocessors/ia32/pentium4/hyperthreading/index.htm

some of the papers suggest its use almost as a form of micro optimization, I still havent played with the technology enough to make any kind of comment.
amag
amag
I''m only a bit saddened that you all just missed my point, but then again it wasn''t very obvious...

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.