Author: Gerd Isenberg
Date: 04:42:54 12/20/05
Go up one level in this thread
On December 20, 2005 at 03:20:43, Volker Böhm wrote: >Hi Gerd, > >suppose a 0x88 coding of the positions you can get an index simply by: > >position1 - position2 + 128 > >but you will need a table with 256 entries. Don´t you think this is faster? > >Greetings Volker Hi Volker, yes, a 0x88-diff lookup is fine to get a 0..63 range of absolute rank-and file differences for a second 64-element lookup and the unique distance "9" (adjacent file and rank) as (pre-)condition for the eight edge cases. Direct knight-distance from 0x88-diff might also work, but requires a bit more complicated code for those edges... The fastest approach for 0..63-square coordinates is a 64*64 lookup in precalculated tables, but using 64 cachelines instead of one may decrease performance elsewhere - more cache pressure and memory-cache transfer. There is allways this tradeoff between calculation and lookup. If the knightDistance routine is called rarely, it is likely, that the lookup-table is not in L1-cache. Combining edges and distance in one cacheline implements also a kind of prefetching. While an early cache miss don't hurt after getting the boolean edge-info, because there are other things to do with pure register calculation(latency hiding), the later access on the distance gets it most likely direct from L1-cache. Gerd
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.