BMI2 PEXT idea for attacks generation

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

mjlef
Posts: 1494
Joined: Thu Mar 30, 2006 2:08 pm

BMI2 PEXT idea for attacks generation

Post by mjlef »

As I travel about 2000 miles by car, I have some time for ideas. Here is one;

Reduce the size of attacks bitmaps to 16 bits using the PEXT command and a PDEP command. this will make an 800+ KB table about 1/4th the size.

So you first use pext to extract the bits to make an index into the attacks bitmap table. But instead of the table having 64 bit values, it has 16 bit values. You then use pdep to deposit the bits back into the 64 bit result using th e same map. So this should be much more cache friendly, and maybe faster if pdep is fast.

I will try it late tonight when I reach a hotel. If anyone beats me to it, let me know if it is faster.mark
Gerd Isenberg
Posts: 2250
Joined: Wed Mar 08, 2006 8:47 pm
Location: Hattingen, Germany

Re: BMI2 PEXT idea for attacks generation

Post by Gerd Isenberg »

Hi Mark

you mean PEXT/PDEP Bitboards?

Zach already had the idea back in 2011.
http://www.talkchess.com/forum/viewtopic.php?t=40333

Cheers,
Gerd
syzygy
Posts: 5566
Joined: Tue Feb 28, 2012 11:56 pm

Re: BMI2 PEXT idea for attacks generation

Post by syzygy »

And I verified recently that it is faster on my Kabylake laptop:
http://talkchess.com/forum/viewtopic.ph ... 441#727441

While we're at it, note that SF's current variable-shift magics implementation is considerably slower than a clever fixed-shift solution.