Author: Frank E. Oldham
Date: 13:01:23 06/19/04
Go up one level in this thread
On June 19, 2004 at 10:04:28, William Bryant wrote:
>...
>The G5 has two distince _advantages_ that need to be exploited to get maximum
>performance on a G5.
>
>One, compile crafty for 64 bit integers to use bitboards efficiently.
>
>Two, the PPC has specific intstructions to do bit counting, which is what most
>of the optomized assembly code tries to do if I remember correctly.
>
>the cntlzw function counts the number of zero bits starting a the ?low order?
>end of the register.
>This is used for firstOne and lastOne and the other functions.
>
>I have Codewarrior versions of the routines posted below.
>
>I wonder how durable the liquid coolling system is.
>Apple does good engineering, but I would definately spend a few extra $$ on the
>extended apple warrienty. I have used it several times with my aging laptop and
>found them fast, efficient and friendly.
>(I have replaced the LCD screen on my lap top for $0 and it took 3 days door to
>door.
>
>
>The Code:
>Note: __cntlzw is is a CodeWarrior macro for the assembly language instruction
>
>inline UInt32 FirstOne(register BitBoard a) {
> register UInt32 i;
>
> if (i = a >> 32)
> return(__cntlzw(i));
> if (i = (UInt32) a)
> return(__cntlzw(i) + 32);
> return(64);
>}
>
>inline unsigned long LastOne(register BitBoard a) {
> register UInt32 i;
>
> if (i = (UInt32) a)
> return(__cntlzw(i ^ (i - 1)) + 32);
> if (i = a >> 32)
> return(__cntlzw(i ^ (i - 1)));
> return(64);
>}
>
>inline UInt32 NextOne(register BitBoard& a) {
> register UInt32 i;
> register UInt32 value;
>
> if (i = a >> 32) {
> value = __cntlzw(i);
> a^=SquareMask[value];
> return value;
> }
> if (i = (UInt32) a) {
> value = __cntlzw(i) + 32;
> a^=SquareMask[value];
> return value;
> }
> return(64);
>}
>
>inline UInt32 PopCnt(register BitBoard a) {
> register UInt32 c=0;
>
> while(a) {
> c++;
> a &= a - 1;
> }
> return(c);
>}
>
>William
If you are compiling for the G5 in 64-bit mode with gcc, you can use cntlzd
i.e., a line in crafty like
square = FirstOne(temp);
can be replaced by
asm("cntlzd %0, %1" : "=r" (square) : "r" (temp));
for modifying boolean.c, you can use:
#if (defined(USE_ASSEMBLY) && defined(PPC_G5))
asm int FirstOne(BITBOARD arg1)
{
/*
return (__cntlzd(arg1));
*/
li r2, 32;
sld r5, r3, r2;
or r4, r4, r5;
cntlzd r3, r4;
}
asm int LastOne(BITBOARD arg1)
{
/*
return (__cntlzd(arg1 ^ (arg1 - 1)));
*/
li r2, 32;
sld r5, r3, r2;
or r4, r4, r5;
subi r6, r4, 1;
xor r7, r4, r6;
cntlzd r3, r7;
}
#endif
Frank
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.