Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: huge speedup by using pointers instead of arrays

Author: Juergen Wolf

Date: 05:03:46 09/28/04

Go up one level in this thread


On September 28, 2004 at 05:33:46, Roman Hartmann wrote:

>About half a year ago I started to write a move generator from scratch (to be
>honest that was allready my second attempt) and soon I realized that this would
>not be an easy task as progress was very slow. But anyway a few days ago I
>finnished this task also due the help of this forum (I found the EP and castling
>bug with the help of the divide command of Sharper).
>
>Anyway, as I’m not using biboards in my program I was sure my move generator
>would be rather slow compared to state of the art bitboard programs. The move
>generator ended up beeing about 5 times slower than the one from crafty. I
>didn’t expect it to do any better.
>
>Yesterday evening I thought I could speed up things a bit by using pointers. I
>didn’t expect too much from this attempt, though.
>But only changing my attack function to pass pointers instead of passing the
>structure gave me a allready a huge speedup. Today I changend also my testmove
>function to use a pointer to a struct instead of passing the structure and got
>another 100% Speedup!
>
>I didn’t expect this huge speedup but I guess it’s because I had functions
>calling other functions with passing values from function to function.
>
>Layout before:
>int makemovelist(...) {
>        ...
>	testmove(struct point p, int von, int nach);
>}
>int testmove(struct point, int von, int nach) {
>	...
>	imschach(struct point p);
>}
>int imschach(struct point p) {
>	...
>	attack(struct point p, p.k_w);
>}
>
>int attack(struct point p, int i) {
>    	...
>}
>Not a very fast approach, obviously.
>But only by changing this to passing a pointer to the struct p now instead of
>call by value the move generation process is about seven times faster than it
>was before. I tried several compilers to check that.
>
>

Not sure whether i fully understood your posting.
Passing pointers/addresses instead of structures is usually faster,
as in the later case a copy of your structure will be created whereas in the
first case one a 32-bit value will be passed to the called procedure

kind regards juergen



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.