Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: SSE2 Instructions and hash key calculations

Author: Dezhi Zhao

Date: 06:38:09 09/03/03

Go up one level in this thread


On September 03, 2003 at 04:56:00, Bo Persson wrote:

>On September 02, 2003 at 16:52:24, Dezhi Zhao wrote:
>
>>Hi!
>>
>>I know that some programmers here have played with MMX/SSE/SSE2 quite a lot. I
>>am wondering if the new SSE registers and xor op can beat the regular registers
>>in calculating the hash key that are 64 bit operations. Have anybody tried this?
>
>Yes, SSE can beat (maybe by offloading) the regular registers in computing the
>hash key. The problem is that you cannot easily compare the result with anything
>else, without a set of load/store instructions. This tends to negate the
>computational speedup.

I was considering the load/store overhead too. However I dont think it is too
difficult to compare them. Say, we make a noncapture move and want to know the
new key. Could we compare them here? Please refer to the following code:

#include "stdafx.h"

__int64 old_key;
__int64 new_key;
__int64 type_rnd[12][64];	// indexed by [type][square]

struct Move
{
	unsigned char from;		// from square
	unsigned char to;		// to square
	unsigned char type;		// pc type
	unsigned char capt;		// captured type

	Move(int move) { *((int*) this) = move; };	// a simple converter
};

void update_key_non_capture(int move)
{
	Move m  = move;			// cast back to convenient form

	new_key = old_key ^ type_rnd[m.type][m.from] ^ type_rnd[m.type][m.to];
}

int main(int argc, char* argv[])
{
	update_key_non_capture((12) | (28 << 8) | (0 << 16));	// we test e4 now:)
	return 0;
}


>
>
>>
>>Regards,
>>dzhao
>
>
>Bo Persson



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.