Author: Daniel Clausen
Date: 13:48:22 09/02/99
Go up one level in this thread
Hi
On September 01, 1999 at 23:50:05, Tom Kerrigan wrote:
>This looks like 5% technology improvement and 95% marketing hype.
>I wouldn't rush out and buy a Mac just yet... (unless, of course, you plan to
>run Linux on it :)
>-Tom
>
I talked with a friend of mine about this Altivec unit and it
seems it could be really useful in chess programs.
Suppose the following problem: (at least I think I can use
that in the still-to-write eval function, especially when
using bitboards)
char value[16]; // Array filled with some values :) [*]
int mask; // Must be at least 16 bit :)
int i;
int sum;
for(i=result=0; i<16; i++)
if(mask & (1<<i)) result += value[i];
[*] Just a note: ANSI-C doesn't specify whether a 'char' is
unsigned or signed. This is implementation-defined. I say
this because I had exactly this bug in my program, when I
ran it under a different OS. :)
Or in other words: Sum all values in the value[] array for
indices where the corresponding big is set in the mask.
Altivec has instructions which enable you to calculate this
"partial sum" quite efficient. It has an instruction which can
sum up all 16 bytes (or 8 shorts, 4 ints, 4 floats) in a
vector. So you have to set all values to zero which you don't
want to sum up. You can do that when you "expand" the 16bit
mask in a 16 byte vector. (0bit -> 0x00, 1bit -> 0xff)
Then you AND this vector with the value vector. Tada.
Here's a summary what you would do:
vector load 1 cycle
expand 4 cycles
and 1 cycle
sum 1 cycle
total 7 cycles
Of course, you can optimize the algorithm in the beginning as
well, but I doubt you can do the whole thing under 7 cycles.
(or even close to it)
Summary: I think, Altivec can be quite useful in chess
programming. I'm sure there are other possibilities to
use Altivec except for the above example. Now I would never
dare to say some crazy factors but I also wouldn't call
it a "total washout", as some other guy did.
Kind regards,
-sargon
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.