Author: Andreas Guettinger
Date: 02:05:03 07/01/04
Go up one level in this thread
On June 30, 2004 at 19:24:09, William Bryant wrote:
>On June 30, 2004 at 04:48:38, Andreas Guettinger wrote:
>
>>To compile crafty-19.14 on my PowerMac G4 I had to change the following line
>>back in the file boolean.c:
>>
>>#if defined(ALPHA) && !defined(PopCnt)
>>
>>into
>>
>>#if (!defined(INLINE_ASM) && !defined(ALPHA)) || (defined(ALPHA) &&
>>!defined(PopCnt))
>>
>>or else there is no popcnt, firstone, lastone.
>>Because obvioulsy Macs do not read INLINE_ASM and are not ALPHAs.
>>
>>OR
>>
>>Maybe somebody cares to write G4 and G5 versions of popcnt, firstone, lastone (I
>>think magic bitscan runs quite good on the powerpc), makes an #if defined
>>powerpc and sends the file to Hyatt.
>>:)
>>
>>regards
>>Andy
>
>Andreas,
>
>Last time I looked there were specific code for the PPC processor in Crafty.
>If not, there used to be.
>
>The PPC processor has a built in instruction to help with the FirstOne, LastOne
>function calls
>called cntlzw. The counts the number of leading zero bits, I think, form the
>low bit number end.
>It turns most of the bit manipulation routines (except popcnt) into almost a
>single instruction call.
>
>In metrowerks, it can be called with the compiler function __cntlzw(32bitvalue).
>
>In XCode you have to call it from assembly. The source was posted a week or so
>ago for the
>assembly language functions.
>
>William
I never saw powerpc specific code in Crafty.
But i remeber a post by Frank Oldham, who mentioned some ppc specific code for
Codewarrior. I use only gcc, and unfortunately I have no idea how to write
assembly code for gcc. :(
-------snip
>On February 17, 2004 at 22:37:32, Frank E. Oldham wrote:
>
>>uses assembly language FirstOne and LastOne;
>>for example,
>> square = FirstOne(temp)
>>becomes
>> asm("cntlzd %0, %1" : "=r" (square) : "r" (temp));
>>and
>> from = LastOne(piecebd);
>>becomes
>> asm("cntlzd %0, %1" : "=r" (from) : "r" (piecebd ^ (piecebd - 1)));
>
>Nice NPS. :)
>
>Do these FirstOne() LastOne() also work on a G4?
>
>regards
>Andy
Not quite -- cntlzd is a 64-bit instruction, "count leading zeros double" -- but
the G4
only has the 32-bit analogue cntlzw, so each half of the bitboard has to be done
separately.
In MW-compatible asm, it looks like:
asm int __inline__ FirstOne(BITBOARD arg1)
{
/*
register unsigned long i;
if (i = a >> 32)
return (__cntlzw(i));
if (i = (unsigned int) a)
return (__cntlzw(i) + 32);
return (64);
*/
mr. r5, r3;
beq @2;
cntlzw r3, r5;
blr;
@2
cntlzw r3, r4;
addi r3, r3, 32;
}
and similarly for LastOne.
-------------snip
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.