Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: C and C++ --- NPS

Author: Sune Fischer

Date: 13:11:55 12/24/02

Go up one level in this thread


On December 24, 2002 at 13:37:36, Matt Taylor wrote:

>On December 24, 2002 at 05:16:37, Sune Fischer wrote:
>
>>On December 23, 2002 at 21:29:08, Arshad F. Syed wrote:
>>
>>>Is there anyone here who has actually converted their C code to C++ while
>>>keeping the NPS the same or even managed to improve upon it? Sune did mention
>>>that he did so only at the cost of 15% degradation in speed. Why do people even
>>>bother wasting their time with C++ for a chess program when it inevitably leads
>>>to taking a hit in NPS? Regardless, of all the advice to simply inline the
>>>functions, I have yet to see a living example of chess program code which
>>>performed faster in C++.
>>>
>>>Regards,
>>>Arshad
>>
>>That problem is solved now, I just needed to inline a few functions and speed
>>went back up.
>>
>>It's tiny things really, like I had a GenCastleMoves which was called from
>>GenMoves. In GenCastleMoves I checked the flag first, most of the time this flag
>>isn't set so castle is illegal and I can return, it's just a function call
>>overhead for nothing.
>>
>>Actually I would like full inlining here, to have GenMoves and GetNextMove
>>inlined in my Search. But if I understood things correctly, I would then need to
>>have all the code in one huge file. I don't want that.
>>
>>-S.
>
>One of the weaknesses of C/C++ compilers in general is that the compiler can
>only inline what it sees. It is interesting that, in VC 7, the linker can do
>inlining. I was very pleased when I read that because it means I can practice
>good design without having to expose unnecessary portions of my code for inline
>functions.
>
>-Matt

I have tried VC 7, I was never able to make it go as fast as VC 6.

It might be an interesting experiment to try and inline as many functions as
possible. You have SEE to inline in the Sort and Sort can be inlined in Search,
so can GenMoves, GetNextMove, Repetition detection, Makemove and Eval and
probably many others as well. The Search() is called 500,000 times a second so
that has to be a lot of function call overhead.

-S.



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.