Thank Bob,bob wrote:phhnguyen wrote:bob wrote: SImple. This is the "lockless hashing" idea for parallel search.
The issue is that different threads can store into the same hash table address at approximately the same time. There are two 64 bit values, the signature (A) and the score/etc (B). If two processors try to store at the same time, you want to get eihere A1,B1 or A2,B2 stored in the table, but due to timing you can get A1,B2 or A2, B1 which is a problem.
If, when you store A1, B1, you xor them to modify the stored signature, and when you probe that entry, you xor again to recover the original signature, you eliminate the possibility of getting a match on A1, but getting data B2 which would be wrong.
The lockless hashing paper is on my web page at www.cis.uab.edu, where you click on faculty then my name...
If you don't do this, you have to use a normal Lock()/Unlock() which is way excessive overhead due to all the hash storing and probing going on.
Hi Bob,
I am wondering if it is another solution for "lockless" if we set the hash key in the middle of the hash data (e. g: 32 bit data + 64 bit hash key + 32 bit data). Any wrong pair of A and B will simply destroy the hash key and we can avoid using the Xor.
What is your opinion / experience? Many thanks.
Pham
In thinking about it, it is not really a given that this would work on the PC. Nothing to prevent one thread from writing the first 4 bytes, then the next 8, then the next 4, but after the first 4, that thread gets suspended for an instant, leaving wrong data combined with right data. The processor is certainly free to complete all writes done by the active process at any point in time after a context-switch, which could be an issue.
Good idea, and it might work most of the time.
I have been continueing to develop the idea:
- When we see a correct hash key (in the middle of data), it always makes sure that the whole data is from only one position
- In the worse case, that data includes two half data (of the same position), but from two different search situations so they are different type, move, depth, value...
For the above case and for your current implementation, Crafty cannot use and has to throw the whole hash data away.
But if we set hash key in the middle and reoganize data, we can still use hash data. Solutions may be:
1) Use your 6 bit left (unused) as a verify value for the unique of the whole hash data
2) Re-oganize data so we can use data even they are not belong together:
- 6 unused, 3 bit age, 21 bit move (30 bit)
- 64 hash key
- 2 bit type, 15 bit draft, 17 bit value (34 bit) (If you could "compress" 15 bit draft into 13 bit, you could set the hash key in the "right" middle for easily accessing).
Just 2 cent
Pham