Author: Bo Persson
Date: 02:37:41 05/04/03
Go up one level in this thread
On May 03, 2003 at 18:15:35, Uri Blass wrote: >On May 03, 2003 at 08:55:33, Magoo wrote: > >>On May 03, 2003 at 08:26:05, Uri Blass 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 do not know what get_piece does but >>>I do not think that calling one function 300 times/node is reasonable. >>> >>>If get_piece find the next piece then there is no reason for a special function >>>and you can use your piece list. >>> >>>Even without piece list I see no reason to call get_piece so many times. >>>There are not 300 pieces in the board. >>> >>>Uri >> >>No, this is what it does: get_piece(board brd, int sqr) -> piece, >>it takes a pointer to a board and returns the piece on square sqr. >>When moving say a Bishop, you have it on square src, i call >>get_piece(brd,src-15) to test if it can move to src-15 ( if get_piece returns >>EMPTY, it can move there.. else i test for captures etc..). >>Im guessing, that doing all of this work is heavy, i mean calling a function 29 >>Million times.. thats alot of parameter passing.. im going to test a few ugly >>things (hard coding some stuff) to see if it improves... I can actually "remove" >>both on_board and get_piece, i think that calling the function on_board is more >>expensive than the function itselft, (the only thing it does is "return >>!(square&0x88"). > > >I have a lot of global varaibles in my program. > >local varaibles that are used by many functions is a bad idea because parameter >passing takes time. > >A lot of my functions get no parameters and simply use global varaibles. >I also told my program to inline every suitable function. Global variables are not necessarily faster, as it might interfere with the compiler optimizations. Inlining though is usually a *great* benefit for program speed, especially if you have a lot of small functions. Bo Persson bop2@telia.com >Uri
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.