fiew days ago i had the following idea:
caching the last computed attackSet and blockerSet.
==================================
Code: Select all
extern __inline BTB_T attackQ(SQR_T sq,BTB_T occ)
{
//initialize,so computation
//is done on the 1st run.
static BTB_T attOld[ID64] =
{
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1,
-1,-1,-1,-1,-1,-1,-1,-1
};
static BTB_T bloOld[ID64];
//-check if last computed attackset can be used again: if not, then compute...
//-store additionally the blockerSet to be able to use the next condition.
if(!((attOld[sq]&occ) == bloOld[sq]))
{
//compute
attOld[sq] = attackLine(&lmsk[sq][DIAGDIR],occ) |
attackLine(&lmsk[sq][ANTIDIR],occ) |
attackLine(&lmsk[sq][FILEDIR],occ) |
attackLine(&lmsk[sq][RANKDIR],occ) ;
bloOld[sq] = attOld[sq] & occ;
}
return(attOld[sq]);
}
version.
Also the speedgain may be concealed somehow in a real engine.
Maybe this approach can be used for various attackGetters.
There are different scenarios, where i think the speedgain comes from:
==============================================
- unmoved pieces
- revisiting square(with the same blockers for the lines)
- multiple calls within a stage(not for my perftframe,only incheck,movegen issues)
...and so on.
formular:
=======
i think it is a simple(cheap) formular:
(lastAttacks[sq] & currentOccupancy) == lastBlockers[sq]
where no computation is needed again.
Some ideas on that, or anyone did something similar ?
Maybe tell me about the drawbacks, i dont think of at the moment...
Michael