Hi,
I'm puzzled about the possibility of using floating point inside the evalutation function of my new engine. I'm now using SSE variable to store 2 32 bit integer in a single variable and I'm trying to implement an evalutation this way.
Up to now my evalutation only consider material and piece-square table and at the end does a tapered evalutation to return a single 32 bit integer.
The search uses the int to do a very standard alpha beta searcher.
what I'm now thinking is to use SSE floating point instructions inside the evalutation and to return at the end an integer (to not break the search, comparison and null windows search). I have noticed that there are more SSE floating point istruction than integer ones and that them are more powerful.
Has anyone tried them in a chess engine evalutation function? have you found faster/slower time execution with SSE floating point ? Any problems?
thank you all
floating point SSE eval
Moderators: hgm, Rebel, chrisw
-
- Posts: 686
- Joined: Thu Mar 03, 2011 4:57 pm
- Location: Germany
Re: floating point SSE eval
Hi Marco,
in the very early versions of my engine (4 years ago) I used floating point eval scores, I changed it later to integer but there was not much impact on the speed. Probably the engine was spending most of its time elsewhere. At that time I just started with the whole stuff and I did not use a profiler for such decisions.
There might be side effects that you do not think of, like the compiler is not able to optimize as efficiently with floats as it is with ints (e.g. integer addition is commutative, addition of floating points is not so the order of adding the values has influence on the result - limiting the options of the compiler)
So, I would say. Don't guess. Use a profiler and measure.
Thomas...
in the very early versions of my engine (4 years ago) I used floating point eval scores, I changed it later to integer but there was not much impact on the speed. Probably the engine was spending most of its time elsewhere. At that time I just started with the whole stuff and I did not use a profiler for such decisions.
There might be side effects that you do not think of, like the compiler is not able to optimize as efficiently with floats as it is with ints (e.g. integer addition is commutative, addition of floating points is not so the order of adding the values has influence on the result - limiting the options of the compiler)
So, I would say. Don't guess. Use a profiler and measure.
Thomas...
-
- Posts: 838
- Joined: Thu Jul 05, 2007 5:03 pm
- Location: British Columbia, Canada
Re: floating point SSE eval
If you want to use the integer ones, the SSE2 set of instructions is supported by all modern x86 chips (everything since Pentium 4 and AMD K8 has supported it), every x64 chip can do SSE2, so don't be afraid to use those.elcabesa wrote:Hi,
I'm puzzled about the possibility of using floating point inside the evalutation function of my new engine. I'm now using SSE variable to store 2 32 bit integer in a single variable and I'm trying to implement an evalutation this way.
Up to now my evalutation only consider material and piece-square table and at the end does a tapered evalutation to return a single 32 bit integer.
The search uses the int to do a very standard alpha beta searcher.
what I'm now thinking is to use SSE floating point instructions inside the evalutation and to return at the end an integer (to not break the search, comparison and null windows search). I have noticed that there are more SSE floating point istruction than integer ones and that them are more powerful.
Has anyone tried them in a chess engine evalutation function? have you found faster/slower time execution with SSE floating point ? Any problems?
thank you all
-
- Posts: 4185
- Joined: Tue Mar 14, 2006 11:34 am
- Location: Ethiopia
Re: floating point SSE eval
The question is why do you want to use floats in evaluation. It will only make you go slower especially if you use double precision. You can use milli-pawns instead of centi-pawns, or a 1pawn=256units as some engines already do. If you are a bitboarder, there maybe some uses of it in chess-wiki or ask Gerd. SSE/AVX are designed for HP scientific computing just like GPU units, so branching code in chess is not gonna benefit from that a lot.elcabesa wrote:Hi,
I'm puzzled about the possibility of using floating point inside the evalutation function of my new engine. I'm now using SSE variable to store 2 32 bit integer in a single variable and I'm trying to implement an evalutation this way.
Up to now my evalutation only consider material and piece-square table and at the end does a tapered evalutation to return a single 32 bit integer.
The search uses the int to do a very standard alpha beta searcher.
what I'm now thinking is to use SSE floating point instructions inside the evaluation and to return at the end an integer (to not break the search, comparison and null windows search). I have noticed that there are more SSE floating point istruction than integer ones and that them are more powerful.
Has anyone tried them in a chess engine evaluation function? have you found faster/slower time execution with SSE floating point ? Any problems?
thank you all
-
- Posts: 7216
- Joined: Mon May 27, 2013 10:31 am
Re: floating point SSE eval
Always watch out for rounding errors. For instance when testing the value of a rational number. If you test A == 0 but A is 0.000000000133333 it will be false.
Sorry if this looks like programming for beginners.
Sorry if this looks like programming for beginners.
-
- Posts: 855
- Joined: Sun May 23, 2010 1:32 pm
Re: floating point SSE eval
I think i'll use sse2 or later integer or float instructions.wgarvin wrote: If you want to use the integer ones, the SSE2 set of instructions is supported by all modern x86 chips (everything since Pentium 4 and AMD K8 has supported it), every x64 chip can do SSE2, so don't be afraid to use those.
I'm writing a floating point eval function so it shouldn't happen. thank you for the warningAlways watch out for rounding errors. For instance when testing the value of a rational number. If you test A == 0 but A is 0.000000000133333 it will be false.
Sorry if this looks like programming for beginners.
it looks like thah sse floating point instructions are "stonger" than integer ones.The question is why do you want to use floats in evaluation. It will only make you go slower especially if you use double precision. You can use milli-pawns instead of centi-pawns, or a 1pawn=256units as some engines already do. If you are a bitboarder, there maybe some uses of it in chess-wiki or ask Gerd. SSE/AVX are designed for HP scientific computing just like GPU units, so branching code in chess is not gonna benefit from that a lot.
with the library i'm using you can do sqrt nad pow of packed float for example. you can calculate a reciprocal ans so on.
-
- Posts: 3232
- Joined: Mon May 31, 2010 1:29 pm
- Full name: lucasart
Re: floating point SSE eval
Actually, this is a very good point! Writing a PVS algorithm for use with floating point evaluation is a disastrous. How do you write a zero window with floating point scores?Henk wrote:Always watch out for rounding errors. For instance when testing the value of a rational number. If you test A == 0 but A is 0.000000000133333 it will be false.
Sorry if this looks like programming for beginners.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
-
- Posts: 855
- Joined: Sun May 23, 2010 1:32 pm
Re: floating point SSE eval
sorry lucas for my next few words but .....lucasart wrote: Actually, this is a very good point! Writing a PVS algorithm for use with floating point evaluation is a disastrous. How do you write a zero window with floating point scores?
why everyone write without reading what I have weritten??
I stated that I want to write a floating point evalutation and at the end convert it to an int to not break the PVS search.
have you found slower/flawed/wrong using float inside evalutation?
has anyon an insight of it?
thank you all
-
- Posts: 686
- Joined: Thu Mar 03, 2011 4:57 pm
- Location: Germany
Re: floating point SSE eval
Hi Marco,
as I wrote. Floating points worked for me and when I changed to int I had no significant speedup.
At that time I did not have a term that required a division (e.g. scaling king safety depending on the enemy material left or so). If you do a lot of this stuff than ints might be faster.
Thomas...
as I wrote. Floating points worked for me and when I changed to int I had no significant speedup.
At that time I did not have a term that required a division (e.g. scaling king safety depending on the enemy material left or so). If you do a lot of this stuff than ints might be faster.
Thomas...
-
- Posts: 2250
- Joined: Wed Mar 08, 2006 8:47 pm
- Location: Hattingen, Germany
Re: floating point SSE eval
You may give it a try. See also the papers referred in cpw:
https://chessprogramming.wikispaces.com/Float
and
http://www.talkchess.com/forum/viewtopic.php?t=22817
http://en.wikipedia.org/wiki/FMA_instruction_set
For a null window in PVS one has to pass only one bound anyway, so one may try it even in search...
https://chessprogramming.wikispaces.com/Float
and
http://www.talkchess.com/forum/viewtopic.php?t=22817
http://en.wikipedia.org/wiki/FMA_instruction_set
For a null window in PVS one has to pass only one bound anyway, so one may try it even in search...