Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: WCCC: Almost no hardwareadvantage for Crafty

Author: Robert Hyatt

Date: 08:06:27 06/30/04

Go up one level in this thread


On June 30, 2004 at 03:19:12, Tony Werten wrote:

>On June 29, 2004 at 18:03:10, Robert Hyatt wrote:
>
>>On June 29, 2004 at 16:04:23, Vincent Diepeveen wrote:
>>
>>>On June 29, 2004 at 12:52:43, Robert Hyatt wrote:
>>>
>>>>On June 29, 2004 at 12:31:00, Vincent Diepeveen wrote:
>>>>
>>>>>On June 29, 2004 at 09:00:51, Ingo Bauer wrote:
>>>>>
>>>>>>On June 29, 2004 at 08:26:15, Zach Wegner wrote:
>>>>>>
>>>>>>>One important point is that crafty uses bitboards, so it will have an additional
>>>>>>>speedup on a 64 bit processor.
>>>>>>
>>>>>>http://www.talkchess.com/forums/1/message.html?372849
>>>>>>
>>>>>>According to yesterdays news its ~47%. Assuming that the hardware is equal and
>>>>>>that double speed gives 60 ELO Crafty wins 30 ELO. We will see soon if this will
>>>>>>be enough.
>>>>>>
>>>>>>Bye Ingo
>>>>>
>>>>>The 32 bits version is using 8 registers.
>>>>>The 64 bits version uses 16 registers.
>>>>>
>>>>>And another few tiny differences.
>>>>>
>>>>>Crafty loses always 1 register to index which thread it is using, so the
>>>>>advantage of going from 8 to 16 is a big one.
>>>>>
>>>>>Then i do not know whether the 64 bits version uses inline assembly versus the
>>>>>32 bits version not using it and the compiler versions and type of compilers
>>>>>used is unclear.
>>>>
>>>>
>>>>If you are going to write about what you don't know, we are going to be here all
>>>>day.
>>>>
>>>>the pointer cost me 3-4% when I added it a few years back.  That is not going to
>>>>be a "big one" when moving to 16 registers.
>>>>
>>>>Both versions use inline assembly for FirstOne() and LastOne() and that's it.
>>>>There is no other assembly in Crafty other than my spinlock code for the SMP
>>>>stuff...
>>>>
>>>>On windows there is no inline asm at all as windows has a built-in intrinsic to
>>>>get to BSF/BSR...
>>>
>>>Do you run in windows at the world champs 2004?
>>
>>If I could, yes.  the compiled executables Eugene produces are faster than
>>anything I can do on linux..  And XP runs crafty just as well, and Eugene's numa
>>memory stuff works just fine with no twiddling as I have to do on linux from
>>version to version..
>>
>>However, here is the huge amount of inline asm I have in Crafty:
>>
>>int static __inline__ FirstOne(long word)
>>{
>>  long      dummy, dummy2;
>>
>>asm("          bsrq    %0, %1"                       "\n\t"
>>    "          jnz     1f"                           "\n\t"
>>    "          movq    $-1, %1"                      "\n\t"
>>    "1:        movq    $63, %0"                      "\n\t"
>>    "          subq    %1, %0"                       "\n\t"
>>    :"=r&"(dummy), "=r&" (dummy2)
>>    :"0"((long) (word))
>>    :"cc");
>>  return (dummy);
>>}
>>
>>
>>int static __inline__ LastOne(long word)
>>{
>>  long      dummy, dummy2;
>>
>>asm("          bsfq    %0, %1"                       "\n\t"
>>    "          jnz     1f"                           "\n\t"
>>    "          movq    $-1, %1"                      "\n\t"
>>    "1:        movq    $63, %0"                      "\n\t"
>>    "          subq    %1, %0"                       "\n\t"
>>    :"=r&"(dummy), "=r&" (dummy2)
>>    :"0"((long) (word))
>>    :"cc");
>>  return (dummy);
>>}
>>
>>
>>Ten whole assembler instructions.  And had I renumbered my bits in the right
>>way, this would be a grand total of _two_ assembler instructions rather than 10.
>
>I've read that before. What is the right way ?
>
>H8 at bit0 and A1 at bit63 ? And why ?
>
>Tony

right way is to make rightmost bit == 0, leftmost bit == 63, as that is how the
X86 BSF/BSR instructions number them.  Mine are opposite due to the way Cray
numbers bits in the Cray T90 and such.  Rather than "find first one" they have
an instruction "count leading zeroes".  Which means left-most bit ends up 0,
rightmost bit ends up 63.

Doesn't matter which logical chess square is bit 0, just which end of the 64 bit
int you call 0.  call the LSB bit 0 for best performance with BSR/BSF...





>
>>
>>Crafty really does have a "huge amount of inline assembly" doesn't it???
>>
>>Please stop saying that.
>>
>>
>>
>>
>>>
>>>This i ask because Eugene's beta compiler won't run under linux i guess...
>>
>>
>>Of course it won't.  It is a windows product.
>>
>>
>>
>>
>>>
>>>By the way i thought Eugene was working at the IA64 a while ago, has that team
>>>been moved to x86-64 nowadays and has IA64 development been stopped now?
>>
>>
>>I can't speak for him.  His compiler works on _all_ platforms, obviously.  He is
>>working on all three so far as I know.



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.