Advertisement

La Mothe - Optimated vector length-allgorithm

Started by October 26, 2000 06:53 AM
35 comments, last by Wunibald 24 years, 2 months ago
quote: Original post by msn12b

Hello? Are you joking or are you actually this stupid? You''re doing a FP compare immediately following the fabs()... even if you''re doing a simple fabs on a float, it is still faster to load and save from the FPU; the CPU can pair integer instructions w/ the FP instructions.

MSN


I disagree.
    // FPU abs:FLD [value] ; 1 cycleFABS ST; 1 cycleFSTP [value] ; 2 cycles// Gives a total of 4 cycles.// Int abs on a float:MOV EAX, [value] ; 1/2 cycle; paired with other instructionAND EAX, 0x7FFFFFFF ; 1/2 cycle; paired with other instructionMOV [value], EAX ; 1/2 cycle; paired with other instruction// Gives a total of 1.5 cycles    


if (4 > 1.5)
{ msn = wrong;
}

You can only pair a few integer instructions, never FPU!
What you mean is called interleaving I think, and it''s of no use in this situation!

Or am I as stupid as Poltras now? Come on msn12b - Poltras is oke!

quote: Original post by baskuenen
You can only pair a few integer instructions, never FPU!
What you mean is called interleaving I think, and it''s of no use in this situation!

Or am I as stupid as Poltras now? Come on msn12b - Poltras is oke!



Yes, actually. On a Pentium, you cannot pair any instruction that references the same register w/ a read-write or read-modify-write sequence.

And secondly, you missed the point. If you''re going to do a test like: if( fabs(a) < 1.34 ), there is no point in turning the fabs into an integer only sequence; you have to load fabs(a) onto the FPU at some point to do the test (unless you''re crazy enough to do this via pure integer instructions, which will work as quickly iff both numbers are positive, and which is generally a stupid optimization; yes, you can compare two floats as unsigned longs as long as they are both positive and get the same results. This is how IEEE set up the format). Then again, why bother? Because it''s kewl? Because it''s fun? Only if you have a very low opinion of the worth of your time.

Myopic to the extreme. Premature optimization w/o full knowledge of the problem domain leads to wasted time and effort. And stupid posts like these.

MSN
Advertisement
quote: Original post by msn12b

On a Pentium, you cannot pair any instruction that references the same register w/ a read-write or read-modify-write sequence.

And secondly, you missed the point.

... blablabla ...

Then again, why bother? Because it''s kewl? Because it''s fun? Only if you have a very low opinion of the worth of your time.

Myopic to the extreme. Premature optimization w/o full knowledge of the problem domain leads to wasted time and effort. And stupid posts like these.

MSN


Did I say you CAN pair instruction that references the same register w/ a read-write or read-modify-write sequence?
- NO!

I think you are missing the point here msn - read again!

Why bother? Why bother? You are on a forum about programming - It''s true! If you don''t want to talk about programming and want to waist your time with flaming people like Poltras and me - its better to go elsewhere!

I never had a problem with ANYBODY here! You must have some talent to make it this way.

You''re not making any friend here...why not leave...

msn12b, as soon as you''re old enough, I encourage you to drink heavily. Hopefully it''ll help you unwind
And that adaptor you posted does a pointer derefence too :p

Wow that is the meanest post I''ve ever seen from you Bask


and i guess it should be
[souce]
template
__inline T abs(T x)
{
return(if(x<0)?-x:x);
}

//ANSI C
__inline float fabs(float f)
{
__asm{
mov eax, f
and eax, 0x7FFFFFFF
}
}
[/source]
- 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
I just wanted to calculate a vector''s length *sniff*.

:0)
(Computer && !M$ == Fish && !Bike)
{raises hand}
Now I know what I'm made of, and I'm afraid of it...
Advertisement
quote: Original post by Magmai Kai Holmlor

Wow that is the meanest post I''ve ever seen from you Bask


You''re right Magmai Kai Holmlor . Maybe I was a little hard on the guy. I think I''m getting a bit tired of the name calling from some people.

Maybe the only thing against this is taking a clear stand. I''m not taking anything back though!
{raises hand}

This topic is closed to new replies.

Advertisement