Motherboard Forums


Reply
Thread Tools Display Modes

Question on Hyperthreading ( developer's question)

 
 





















Tetedeiench
Guest
Posts: n/a

 
      08-14-2003, 11:09 AM


Hi all !

I was writing a program which is testing the CPU stability. I was
developing it way before hyperthreading was introduced.

And now that hyperthreading is there and my testing program is almost
done, I encounter a problem.

I cannot spawn two threads at the same time running my test. My test
is single-threaded.

As my test runs fine in P4B without hyperthreading ( and every CPU
before this one), I was wondering :

Does hyperthreading interfere with the execution of one thread ?

That is, will my thread be as effective in a P4 with HT than in a P4
without HT ?

Will the hyperthreading cause threads to overlap and cause my thread
to be slowed down a bit, which will reduce its effectiveness ?

Thanks for your answers,

tetedeiench
 
Reply With Quote
 
Alex Johnson
Guest
Posts: n/a

 
      08-14-2003, 01:07 PM
Tetedeiench wrote:
> I cannot spawn two threads at the same time running my test. My test
> is single-threaded.


Could you say this another way. It is not clear to me what you mean.

> That is, will my thread be as effective in a P4 with HT than in a P4
> without HT ?


Maybe, maybe not. There are some resources on the P4 which are doubled,
one copy for each thread. There are a few resources which are divided:
when in ST mode you get the whole resource, when in MT mode you get no
more than half the resource for each thread to ensure each thread can
get in. Usually this is not a preformance problem, but you can probably
construct a rigged test that would bang its head against on of these
resources if you knew which ones were doubled and which were divided.

> Will the hyperthreading cause threads to overlap and cause my thread
> to be slowed down a bit, which will reduce its effectiveness ?


No. There is a main thread and a backup thread. The main thread will
take all the resources it can. If there are any resources on chip left
over that the backup thread can use, it will use them. If not, the main
thread runs and the backup thread sits there like on a single processor
machine. Due to the way code executes in bursts of high parallelism
followed by long valleys of single-issue or stalls, the second thread
has ample opportunity to execute. What ends up happening on a
multithreaded processor is the threads naturally start to align so that
the peaks of one occur during the troughs of the others, and so the
processor is getting a higher % utilization over time.

Alex
--
My words are my own. They represent no other; they belong to no other.
Don't read anything into them or you may be required to compensate me
for violation of copyright. (I do not speak for my employer.)

 
Reply With Quote
 
Yousuf Khan
Guest
Posts: n/a

 
      08-14-2003, 03:06 PM
(Tetedeiench) wrote in message news:< om>...
> Will the hyperthreading cause threads to overlap and cause my thread
> to be slowed down a bit, which will reduce its effectiveness ?


Simple answer: yes. See more details below.

> I was writing a program which is testing the CPU stability. I was
> developing it way before hyperthreading was introduced.
>
> And now that hyperthreading is there and my testing program is almost
> done, I encounter a problem.
>
> I cannot spawn two threads at the same time running my test. My test
> is single-threaded.
>
> As my test runs fine in P4B without hyperthreading ( and every CPU
> before this one), I was wondering :
>
> Does hyperthreading interfere with the execution of one thread ?


The HT feature basically takes advantage of idle time in the P4's
instruction pipeline to execute more than one thread at a time.
However, if the first thread has no idle time in its pipeline, then
the second thread (which automatically has lower priority) will not
get a chance to run. This would be especially true if you're just
copying the same function with no idle time and spawning it in two
threads. The first instance of the function would hog all the CPU
time, and the second will get none. If the first function had some
idle time (such as waiting for some kind of i/o) then the second
function would get a chance to execute. If your function is basically
CPU-bound with little or no i/o, then HT might be a problem for you.

Yousuf Khan
 
Reply With Quote
 
Tetedeiench
Guest
Posts: n/a

 
      08-15-2003, 03:09 PM
(Yousuf Khan) wrote in message news:<. com>...
> (Tetedeiench) wrote in message news:< om>...
> > Will the hyperthreading cause threads to overlap and cause my thread
> > to be slowed down a bit, which will reduce its effectiveness ?

>
> Simple answer: yes. See more details below.
>
> > I was writing a program which is testing the CPU stability. I was
> > developing it way before hyperthreading was introduced.
> >
> > And now that hyperthreading is there and my testing program is almost
> > done, I encounter a problem.
> >
> > I cannot spawn two threads at the same time running my test. My test
> > is single-threaded.
> >
> > As my test runs fine in P4B without hyperthreading ( and every CPU
> > before this one), I was wondering :
> >
> > Does hyperthreading interfere with the execution of one thread ?

>
> The HT feature basically takes advantage of idle time in the P4's
> instruction pipeline to execute more than one thread at a time.
> However, if the first thread has no idle time in its pipeline, then
> the second thread (which automatically has lower priority) will not
> get a chance to run. This would be especially true if you're just
> copying the same function with no idle time and spawning it in two
> threads. The first instance of the function would hog all the CPU
> time, and the second will get none. If the first function had some
> idle time (such as waiting for some kind of i/o) then the second
> function would get a chance to execute. If your function is basically
> CPU-bound with little or no i/o, then HT might be a problem for you.
>
> Yousuf Khan


Alright. Then there's no use for me to spawn a second thread running
something else : i don't have any I/O in my program. Thus HT will not
be used a lot and won't interfere a lot

For the first sentence, I was just saying that because of the current
implementation of my test, I cannot run more than one thread at a time
running the same test, because there's some global variable they will
fight for

Anyway, thanks a lot for your input, i feel a lot better

iench
 
Reply With Quote
 
Alex Johnson
Guest
Posts: n/a

 
      08-15-2003, 05:44 PM
Tetedeiench wrote:
> Alright. Then there's no use for me to spawn a second thread running
> something else : i don't have any I/O in my program. Thus HT will not
> be used a lot and won't interfere a lot


I/O does not mean disk access in this context. I/O means moving data to
or from the processor. If you use variables, you have I/O. If you use
large arrays or linked lists or trees, then you will have significant
I/O. If you do multi-processor operation such as locks, you will have a
little more I/O. I/O is everywhere! Remember that IA32 only has 8
registers, which are not exactly general purpose. So you will be doing
lots of mov reg, mem and mov mem, reg and push/pop, which are all I/O.

Alex
--
My words are my own. They represent no other; they belong to no other.
Don't read anything into them or you may be required to compensate me
for violation of copyright. (I do not speak for my employer.)

 
Reply With Quote
 
Oliver S.
Guest
Posts: n/a

 
      08-16-2003, 03:15 PM
> No. There is a main thread and a backup thread. The main thread will
> take all the resources it can. If there are any resources on chip left
> over that the backup thread can use, it will use them.


From where did you get this ? This simply isn't true and can easily
been falsified by running two parallel benchmarks on one HT-CPU. Look f.e.
at the SETI@home-benchmarks. Even if you statically assign the two proces-
ses to one logical CPU each, they both get the same throughput (of course
this per-process-throughput is lower than when running undisturbed.
 
Reply With Quote
 
Oliver S.
Guest
Posts: n/a

 
      08-16-2003, 03:19 PM
> ... if the first thread has no idle time in its pipeline, then the
> second thread (which automatically has lower priority) will not get
> a chance to run. ...


That's not true; the shared execution-resources are shared symmetri-
cally among the two threads. Therefore, one the "primary" thread can
be slowed down by the existance of a "secondary" thread. But the com-
bined throughput is usually higher.
 
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Re: OS question PDR Dell 1 10-30-2008 08:41 PM
Re: OS question Ben Myers Dell 2 10-30-2008 07:07 PM
Re: OS question William R. Walsh Dell 0 10-30-2008 04:05 PM
P4P800-E Deluxe CPU upgrade question. DaveW Asus 4 03-28-2007 11:06 AM
K7S5A: Yellow question marks in XP SP2 rhino Elitegroup 1 02-21-2007 06:40 PM


All times are GMT. The time now is 10:53 PM.

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43