Author: Ulrich Tuerke
Date: 12:02:04 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);
C passes parameters "by value", i.e. the whole structure, arrays included, will
be copied "down" to the called routine.
This produces a completely unnecessary and very "expensive" performance overhead
here, because functions like "attack" are typically very performance critical.
Uli
>}
>
>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.
>
>A few perft values:
>roce: setboard 8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w -
>roce: perft 5
>Perft 5: 674624 (0.16s)
>roce: perft 6
>Perft 6: 11030083 (2.83s)
>roce: perft 7
>Perft 7: 178633661 (39.50s)
>roce: setboard r3k2r/p1ppqpb1/bn2pnp1/3PN3/1p2P3/2N2Q1p/PPPBBPPP/R3K2R w KQkq -
>Perft 5: 193690690 (29.09s)
>roce: setboard rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
>roce: perft 6
>Perft 6: 119060324 (21.56s)
>roce: setboard rnbqkbnr/pppppppp/8/8/8/8/PPPPPPPP/RNBQKBNR w KQkq - 0 1
>roce: perft 6
>Perft 6: 119060324 (21.56s)
>roce: setboard 8/2p5/3p4/KP5r/1R3p1k/8/4P1P1/8 w - -
>roce: perft 6
>Perft 6: 11030083 (2.83s)
>roce: perft 7
>Perft 7: 178633661 (39.42s)
>
>Not too bad for a non bitboard engine IMO. Now, finally, I can have a look at
>the more ineresting things in chess programming.
>
>Cheers
>Roman
>
>PS: roce stands for Roman’s own chess engine
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.