Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: 3 optimization questions

Author: Bo Persson

Date: 06:52:16 06/19/03

Go up one level in this thread


On June 19, 2003 at 08:42:39, martin fierz wrote:

>i've been wondering about whether my checkers program could benefit from some
>IA-32 features, perhaps some specialist can answer me some questions - i'm using
>MSVC.net:
>
>1) prefetching
>my program spends 10% of it's time on a single line according to AMD
>codeanalyst, the line where it reads an entry from the hashtable. since i could
>theoretically compute the hashtable index long before accessing the hashtable, i
>could prefetch this hashtable data. is there a way to do this in C? i guess not,
>so is there a way to do this in assembly code in MSVC? if yes, does somebody
>have some code for this? is anybody doing this already?

There are some PREFETCHx instructions, that could be used. MSVC has no idea
about this, but it could be issued as an assembler instruction.

I use the hash value immediately after it is calculated, so I haven't tried
this.

>
>2) vectorized computation
>my board representation is 4 unsigned integers, my move representation too. my
>domove operates on these two structures by XORin each of the board integers with
>a move integer. is this vectorized by the compiler, or do i have to do (can i
>do?) this myself somehow?

The Intel compiler might try this, but for 4 values I guess it wouldn't make
much of a difference. It is already somewhat "vectorized" by the hardware, in
that the processor can execute more than one instruction at a time. The compiler
can choose different registers for the different operations to enable this.
Mostly it does.

>
>3) vectorized comparison
>i do a lot of pattern matching in my evaluation function with the position (4
>ints as above). that looks about like this:
>
>if( (board.bm & C1 == C1) && (board.wm & C2 == C2) && (board.bk & C3 == C3))
>  do something
>
>is there a way to use MMX registers to compare larger numbers (eg 128bit) with
>one instruction? if yes, how can i do this?

One problem is that MMX instructions do not set the status flags, but produce a
set of boolean values that must again be tested. If you can't keep the values in
MMX registers, there is also a cost for loading and storing the values.

In my experience, the bitmapping sequences in a chess program is too short to
benefit from MMX. It is of more use for video processing or audio compression.


>
>cheers
>  martin


Bo Persson
bop2@telia.com



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.