Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: NPS Tree Walk

Author: Magoo

Date: 02:18:45 05/05/03

Go up one level in this thread


On May 05, 2003 at 02:55:14, Tony Werten wrote:

>On May 03, 2003 at 17:48:57, Tony Werten wrote:
>
>>On May 03, 2003 at 08:07:31, Magoo wrote:
>>
>>>On May 03, 2003 at 02:47:29, Tony Werten wrote:
>>>
>>>>On May 02, 2003 at 22:05:25, Magoo wrote:
>>>>
>>>>>How bad is this:
>>>>>Depth:3, Nodes:99949, Time:40 sec, Nps:2498
>>>>
>>>>Horrible, sorry.
>>>>
>>>>From the speed you get (Nps) I guess you are doing too much/ doing things
>>>>double. My program is not fast, but still 100x times faster.
>>>>
>>>>Profiling your code should show up where the problems are. You could also post
>>>>the structure of your program here, we might be able to help.
>>>>
>>>>Good luck,
>>>>
>>>>Tony
>>>
>>>I did a profile (for a minmax walk depth=3), im using a 0x88 board, i try to
>>>program with alot of "modules", that means i have small functions for almost
>>>everything. The function get_piece is called approx 300times/node, which seems
>>>resonable, on_board is the !(square & 0x88) test.
>>
>>I think you overdid it. Modular programming doesn't mean "making a functioncall
>>out of everything".
>>
>>It's sounds a bit like "get_x" wich returns the value of x. All the overhead is
>>in the functioncall itself.
>>
>>>
>>>Flat profile:
>>>
>>>Each sample counts as 0.01 seconds.
>>>  %   cumulative   self              self     total
>>> time   seconds   seconds    calls   s/call   s/call  name
>>> 11.74      1.20     1.20 29440891     0.00     0.00  get_piece
>>> 10.18      2.24     1.04 31783554     0.00     0.00  on_board
>>
>>both, see comment above.
>>
>>>  7.83      3.04     0.80    97862     0.00     0.00  eval
>>>  7.24      3.78     0.74   777565     0.00     0.00  move_pawn
>>>  7.14      4.51     0.73   497315     0.00     0.00  move_pieces
>>>  6.85      5.21     0.70   427282     0.00     0.00  not_in_check
>
>You search 100.000 nodes but you look for not in check 400.000 times ?

not_in_check is only called in the Q-search, i had problems with my Q-search
that i now have fixed. (MVV/LVA ordering).

>
>>>  6.75      5.90     0.69   100361     0.00     0.00  move_generator
>>>  5.77      6.49     0.59  7291134     0.00     0.00  is_different
>>
>>see above
>>
>>>  3.91      6.89     0.40 10203170     0.00     0.00  is_empty
>>
>>see above
>>
>>>  3.42      7.24     0.35   100360     0.00     0.00  all_moves_legal
>>>  3.33      7.58     0.34  7898776     0.00     0.00  getbits
>>>  3.03      7.89     0.31  3471247     0.00     0.00  new_move
>>>  2.74      8.17     0.28  4652405     0.00     0.00  is_null_move
>>>  2.64      8.44     0.27   196244     0.00     0.00  move_knight
>>>  2.25      8.67     0.23  4349648     0.00     0.00  legal_move
>
>Again, you search 100.000 nodes but you check for legal_move 40 times as often

legal_move is one of those "one-line function", it will be replaced by a macro,
anyway it checks one move, so checking 40 moves gives 40 calls.

>
>>>  2.05      8.88     0.21  4449597     0.00     0.00  look
>>>  1.66      9.05     0.17   100361     0.00     0.00  move_king
>>>  1.47      9.20     0.15  2170466     0.00     0.00  is_white_piece
>>
>>see above
>>
>>>  1.37      9.34     0.14  4265234     0.00     0.00  add_move
>>>  1.27      9.47     0.13  3021733     0.00     0.00  getBoard
>>>  0.98      9.57     0.10   786271     0.00     0.00  score_cap
>>>  0.88      9.66     0.09  2796571     0.00     0.00  hist_score2
>
>You add to history about 28 times per move.
>
No, that function is called when move_gen gives scores to moves, the score is
added to all non capture moves.

>You are definately doing things double.

Thats really not my problem even if i really was doing things double, im having
too many functioncalls. Replacing on_board and get_piece to macros increased the
speed, i now have to do this to other functions as well, my major concern now is
move_pawn, but its to big to inline, so im trying to make it smaller.
Compilers are stupid.


>
>Tony
>
>>>  0.88      9.75     0.09  2796571     0.00     0.00  set_move_score
>>>  0.88      9.84     0.09   100360     0.00     0.00  undo_move
>>>  0.78      9.92     0.08  1035659     0.00     0.00  is_black_piece
>>
>>see above. For these functions, replace them with the actual work that is done
>>in the functions and your speed should go up quite a lot.
>>
>>Tony
>>
>>>  0.68      9.99     0.07   100360     0.00     0.00  do_move
>>>.
>>>.
>>>.
>>>.
>>>.
>>>.



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.