Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: speed in multithreaded chess programs

Author: Tony Werten

Date: 23:19:11 01/23/02

Go up one level in this thread


On January 23, 2002 at 19:44:57, Sean Mintz wrote:

>A friend am I have been working together on an engine. Both of us are very
>interested in the idea of multithreaded chess programs. We are now developing
>ours with Cilk, seeing as how we thought it would be the most painless
>transition.
>
>The new version is almost identical to the last version, except now we pass
>positions around and copy boards (which is obviously eating up a lot of time).
>
>Here is our perft function:
>
>unsigned int perft(Position * board, int depth) {
>        Position perft_board;
>        Move_Stack moves[MAX_MOVES];

This uses to much stack. Make a global array and you use a pointer to it.

>        int num_moves,
>            i;
>        unsigned int nodes;
>
>        if (depth <= 0) {
>                return 0;
>        }
>
>        num_moves = 0;
>        nodes = 0;
>
>        gen(board, &moves[0], &num_moves);

Don't generate all moves at once. At least split it in capture and noncapture
moves.

>
>        for (i=0; i<num_moves; i++) {
>                perft_board = copy_board(board);

On a pc there isn't enough memory bandwith to copy. Copy once (at the beginning
of the search) and do a make and unmake move on your "root" position.

Tony

>
>                if (make_move(&perft_board, moves[i].m)) {
>                        if (depth == 1) {
>                                nodes++;
>                        }
>
>                        nodes += perft(&perft_board, depth - 1);
>                }
>        }
>
>        return nodes;
>}
>
>What do people do to keep their programs fast?



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.