Author: Robert Hyatt
Date: 07:53:52 04/22/02
Go up one level in this thread
On April 21, 2002 at 21:22:53, Russell Reagan wrote: >Generally when I ask around (besides here) about chess programming questions I >don't get very good answers, because I don't think most other programmers >understand computer chess. Normally something like this wouldn't even matter, >but because of the nature of chess programs repetitive nature in a handful of >short functions it seems like a possibly more important issue. > >My specific question is about whether it's faster to use a struct for your >position, or to simply have some global variables. Global variables seem like >they would be faster because you don't have to dereference the pointer. I'm not >sure how costly dereferencing a pointer is or if it even costs anything, but if >it costs even an extra instruction, and you do a dozen dereferences in your make >move and unmake move functions, and quite a few in your evaluation function, and >multiply how many dereferences you do by how many nodes you do in a normal >search, that's a lot of wasted instructions. > >So is it faster to pass a pointer to a position structure around to all of your >makemove, unmakemove, evaluation, etc. functions or to have some global >variables that the program acts upon? Note that you can do a structure _without_ using a pointer. If you are talking about a single instance of it, or even an array of structures. So in this context, it seems to make no difference whether you use global variables or a structure with all the variables inside... > >If it is faster to use global data, is the speed difference trivial? For >example, if you save a lot of instructions from using global data, but it only >gets you another 1000 nodes in a 60 second search it's not a huge difference. > >What are some basic things that I do to write efficient code? Basic rules, such >as pass a pointer instead of a copy of the entire structure. Things like that. > >And how could I test something like this in the future? For example, if I want >to find out the cost of dereferencing a pointer. Where can I learn about these >kinds of basic computer computational kinds of things? Any book or website >recommendations? I'm a product of growing up with Microsoft so I was never >really exposed to the more basic lower level computer issues like some of you >guys who were writing chess programs in the 70's before I was born :) > >Thanks for any help and advice you can offer. > >Russell Intel used to have a good programmer's guide for writing C code for their processor. I don't know if it is still on their web site or not. But I would bet a google search would turn up some online tutorials on writing efficient code...
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.