Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: oops here's a better version...

Author: Koundinya Veluri

Date: 22:11:40 01/15/02

Go up one level in this thread


On January 15, 2002 at 08:41:55, Severi Salminen wrote:

>>On my computer, bsf is faster if the 1-bit is less significant and bsr is faster
>>if the 1-bit is more significant, so the FirstBit() and LastBit() versions with
>>the jumps are running faster on average.

Actually I was wrong here. I'm not sure about bsf/bsr on my processer (which is
a P4 1.7 by the way). I think it takes the same amount of time regardless of
where the bit is.

>>How does this test on other processors?
>>I'm curious...
>
>You should check from processor specs, if bsr/bsf takes constant amount of
>cycles or not. If not, then jumping is very wise thing to do. Otherwise the
>opposite might be true. Then second thing is that adding and removing
>instructions might cause misalignements and code will run faster/slower even if
>it _should_ be slower/faster. So you should really check how many cycles bsr/bsf
>takes on your processor (which is?)

Ok I understand now. I believe bsf/bsr are taking the same amount of time
(according to testing; or at least the difference is unnoticable) so jumping is
then not a wise thing to do here. As Miguel has explained, my test is also not
good because it makes the branches very predictable. When I use random numbers,
the versions with no branches are the fastest by far.

Regards,
Koundinya

>
>Severi



This page took 0 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.