Designing an analysis friendly Stockfish?

Code, algorithms, languages, construction...
Jeremy Bernstein
Site Admin
Posts: 1226
Joined: Wed Jun 09, 2010 7:49 am
Real Name: Jeremy Bernstein
Location: Berlin, Germany
Contact:

Re: Designing an analysis friendly Stockfish?

Post by Jeremy Bernstein » Thu Feb 03, 2011 9:07 pm

Hm, a lot of talking to myself. Anyway, I've posted new builds, 32- and 64-bit, PGO, based on the PA_G and GTB code. Enjoy, please let me know how they run.

http://www.expr-i0.net/Stockfish_201_PA_GTB_G.7z

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: Designing an analysis friendly Stockfish?

Post by Prima » Thu Feb 03, 2011 9:32 pm

Jeremy Bernstein wrote:Hm, a lot of talking to myself. Anyway, I've posted new builds, 32- and 64-bit, PGO, based on the PA_G and GTB code. Enjoy, please let me know how they run.

http://www.expr-i0.net/Stockfish_201_PA_GTB_G.7z
My apologies for the non-to-late response. Since yesterday after my last post, I was been away from my PC. Also away earlier today. I just logged-in today/now.

Your first 2 project files uploads still won't compile here, either in VS2010 GUI or via command prompt method. I still get errors.

How did you compile these 2 PGOs using your VS2008 (or 2010?) GUI? Also, did you mix or move all various sources from sub folders into the main stockfish source folder and then
"Add items" and compile? Or did you keep using the "Add item" tab for all sub folders with sources till everything has been "Added" and then compile?

Thanks for your help.

Jeremy Bernstein
Site Admin
Posts: 1226
Joined: Wed Jun 09, 2010 7:49 am
Real Name: Jeremy Bernstein
Location: Berlin, Germany
Contact:

Re: Designing an analysis friendly Stockfish?

Post by Jeremy Bernstein » Thu Feb 03, 2011 9:47 pm

Prima wrote:
Jeremy Bernstein wrote:Hm, a lot of talking to myself. Anyway, I've posted new builds, 32- and 64-bit, PGO, based on the PA_G and GTB code. Enjoy, please let me know how they run.

http://www.expr-i0.net/Stockfish_201_PA_GTB_G.7z
My apologies for the non-to-late response. Since yesterday after my last post, I was been away from my PC. Also away earlier today. I just logged-in today/now.

Your first 2 project files uploads still won't compile here, either in VS2010 GUI or via command prompt method. I still get errors.

How did you compile these 2 PGOs using your VS2008 (or 2010?) GUI? Also, did you mix or move all various sources from sub folders into the main stockfish source folder and then
"Add items" and compile? Or did you keep using the "Add item" tab for all sub folders with sources till everything has been "Added" and then compile?

Thanks for your help.
Prima, I am confused. Don't take me the wrong way, but are you even looking at the stuff I'm sending? All you have to do is open the src folder in the archive and you'd see that I haven't moved any files around. Really all you have to do is open the Stockfish_PA_GTB.sln file in VS2010 and hit Build. In theory, that is.

So which errors do you get now, and under what circumstances (Target/Platform)? I downloaded the trial of VS2010 Ultimate, so those projects are 100% bonafide native to your setup. I was able to build both 32- and 64-bit using the projects I posted. In the meantime, I installed a 64-bit OS and have verified that the 64-bit builds work. I also downloaded the Intel compiler, which I've been using more than the built-in one on my end, but the projects I posted are for the built-in MS compiler, and you shouldn't get bogged down there yet.

The one thing you might have to change is the Runtime Library -- but this won't affect building. It would affect portability of the executables that you build.

Prima
Posts: 328
Joined: Tue Dec 14, 2010 6:12 am

Re: Designing an analysis friendly Stockfish?

Post by Prima » Thu Feb 03, 2011 10:55 pm

Jeremy Bernstein wrote:
Prima wrote:
Jeremy Bernstein wrote:Hm, a lot of talking to myself. Anyway, I've posted new builds, 32- and 64-bit, PGO, based on the PA_G and GTB code. Enjoy, please let me know how they run.

http://www.expr-i0.net/Stockfish_201_PA_GTB_G.7z
My apologies for the non-to-late response. Since yesterday after my last post, I was been away from my PC. Also away earlier today. I just logged-in today/now.

Your first 2 project files uploads still won't compile here, either in VS2010 GUI or via command prompt method. I still get errors.

How did you compile these 2 PGOs using your VS2008 (or 2010?) GUI? Also, did you mix or move all various sources from sub folders into the main stockfish source folder and then
"Add items" and compile? Or did you keep using the "Add item" tab for all sub folders with sources till everything has been "Added" and then compile?

Thanks for your help.
Prima, I am confused. Don't take me the wrong way, but are you even looking at the stuff I'm sending? All you have to do is open the src folder in the archive and you'd see that I haven't moved any files around. Really all you have to do is open the Stockfish_PA_GTB.sln file in VS2010 and hit Build. In theory, that is.

So which errors do you get now, and under what circumstances (Target/Platform)? I downloaded the trial of VS2010 Ultimate, so those projects are 100% bonafide native to your setup. I was able to build both 32- and 64-bit using the projects I posted. In the meantime, I installed a 64-bit OS and have verified that the 64-bit builds work. I also downloaded the Intel compiler, which I've been using more than the built-in one on my end, but the projects I posted are for the built-in MS compiler, and you shouldn't get bogged down there yet.

The one thing you might have to change is the Runtime Library -- but this won't affect building. It would affect portability of the executables that you build.
After reading your posts, specifically on the part where I had to click on the Stockfish_PA_GTB.sln, the VS2010 GUI automatically opened and I was able to make a successful and regular (but no optimization of any kind) compiled with it. Thanks Jeremy.

This still leaves me vulnerable to future Stockfish engines with GTB ported to it with multiple sub-source-folders, or, any engine that has similar multiple sub-folders within its source folder. Perhaps there's a method to how I can accomplish similar end-results you did with the project files etc.

One more thing, the VS2010 Edition does not have settings/menu for "linking" to produce a non-dll-dependent executive file we talked about earlier. Are these settings hidden? I can't find it.

I tried compiling it using the command prompt method to compile it. I pointed it to the stockfish_pa_gtb.sln (as I would point it to .cpp & .c source files) but the command prompt gave errors and couldn't compile it.

Thanks Jeremy. I appreciate these help.

fruity
Posts: 29
Joined: Wed Feb 02, 2011 12:52 am

Re: Designing an analysis friendly Stockfish?

Post by fruity » Fri Feb 04, 2011 12:29 am

SF PA_G scores about 15 Elo below SF default at very fast games in my tests. If everything would have been correctly coded in SF PA_G that should not be the case. I think the ok_to_use_tt_PV() function is not quite right. The test for TT hits should rather look like

Code: Select all

bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value alpha, Value beta, int ply) {

    Value v = value_from_tt(tte->value(), ply);

    return (   tte->depth() >= depth
            || v >= Max(value_mate_in(PLY_MAX), beta)
            || v <= Min(value_mated_in(PLY_MAX), alpha))

           && (
        		    ((tte->type() & VALUE_TYPE_LOWER) && v >= beta)
        		 || ((tte->type() & VALUE_TYPE_UPPER) && v <= alpha)
        		 || (tte->type() == VALUE_TYPE_EXACT && v < beta && v > alpha)
        	  );
  }
in both cases, PV and non-PV. Please correct me if I'm wrong. If I change the code appropriately, I get a slightly positive score after 6000 ultra fast games, like expected. Result was: +1921 -1814 =2265 from changed SF PA_G's pov.
Last edited by fruity on Fri Feb 04, 2011 12:33 am, edited 1 time in total.

Peter C
Posts: 154
Joined: Thu Jun 10, 2010 3:12 am
Real Name: Peter C

Re: Designing an analysis friendly Stockfish?

Post by Peter C » Fri Feb 04, 2011 12:33 am

New Stockfish 2.0.1 PA GTB:
http://www.mediafire.com/?ith6bg64djk2hex

Changes:
  • Fixed some potential bugs, especially if compiled with a non-GCC compiler (thanks Jeremy)
  • Changed how total_piece_count() works so now it just checks an instance field
  • Added fruity's change suggested here, configurable with UCI options (see below)
  • Added Dann Corbit's smooth scaling, configurable with UCI options (see below)
  • ProbeOnlyAtRoot is now on by default, because it makes it stronger
I recommend turning ProbeOnlyAtRoot off for analysis, because it can do strange things to the tablebase probing.

New UCI options:
Update history and killer moves in PV- This turns on/off fruity's change suggested here, which was to update history and killer moves also in the PV. It is stronger with it on, and so it's on by default.
Max depth to update history and killers in PV - As fruity noticed, his change works best at lower depths. This controls the depth, in ply, that it is used.
Use smooth scaling - This turns on/off Dann Corbit's smooth scaling. It is off by default because it makes it weaker. It might suggest interesting moves for analysis.
Linear Factor in Centipawns, Constant Factor in Centipawns, Log Factor in Centipawns - Ask Dann Corbit what these do. :P They have no effect if smooth scaling is off.

With default settings, this thing is slightly stronger than the standard Stockfish in hyper-bullet (40 moves in 1 second).

Peter

Jeremy Bernstein
Site Admin
Posts: 1226
Joined: Wed Jun 09, 2010 7:49 am
Real Name: Jeremy Bernstein
Location: Berlin, Germany
Contact:

Re: Designing an analysis friendly Stockfish?

Post by Jeremy Bernstein » Fri Feb 04, 2011 12:36 am

Prima wrote:After reading your posts, specifically on the part where I had to click on the Stockfish_PA_GTB.sln, the VS2010 GUI automatically opened and I was able to make a successful and regular (but no optimization of any kind) compiled with it. Thanks Jeremy.
OK, that's a start. In my projects, optimization is turned off for the Debug build, but on for the Release. The PGO stuff is additional to the Release builds, and if you google "PGO Visual Studio" you will find some instructions about how to use it. Basically you build an instrumented version of your app, use it (I've been exercising the app with benchmark runs using different numbers of threads, hash sizes and pvs and 30s+0.5s engine matches (32 v 64 bit to exercise them both at once), and then build an optimized build on the basis of files which get saved automagically when you run the instrumented build. But see if you can't get the normal, non-PGO optimized builds going first.
This still leaves me vulnerable to future Stockfish engines with GTB ported to it with multiple sub-source-folders, or, any engine that has similar multiple sub-folders within its source folder. Perhaps there's a method to how I can accomplish similar end-results you did with the project files etc.
It's pretty simple: you add the .c/.cpp files that you want to compile to the project. You add the folders containing any .h files that the .c files reference (which aren't in the compiler header search path already) to the list of #include directories. That's actually it. This isn't a vulnerability -- it's just the way compilers work. When I converted my project from VS2008 to VS2010, VS flattened the file structure I had in the original project (which mirrored the file system's folders) for some reason, but internally they are referenced by path relative to the project file.
One more thing, the VS2010 Edition does not have settings/menu for "linking" to produce a non-dll-dependent executive file we talked about earlier. Are these settings hidden? I can't find it.
You need to examine the options in the property pages (in the Solution Explorer, right-click on the project file and choose Properties...). That's where all of the stuff you normally specify on the command line is set, such as preprocessor variables, linked libs, optimization settings, etc.
I tried compiling it using the command prompt method to compile it. I pointed it to the stockfish_pa_gtb.sln (as I would point it to .cpp & .c source files) but the command prompt gave errors and couldn't compile it.
The .sln/.vcproj thing is an alternative to using the command line. You do one or other other, usually.

Jeremy

Jeremy Bernstein
Site Admin
Posts: 1226
Joined: Wed Jun 09, 2010 7:49 am
Real Name: Jeremy Bernstein
Location: Berlin, Germany
Contact:

Re: Designing an analysis friendly Stockfish?

Post by Jeremy Bernstein » Fri Feb 04, 2011 12:38 am

Peter C wrote:New Stockfish 2.0.1 PA GTB:
http://www.mediafire.com/?ith6bg64djk2hex
Very cool. Thank you. I'll post some builds to compete with yours tomorrow morning.

jb

gaard
Posts: 127
Joined: Thu Jun 10, 2010 1:39 am
Real Name: Martin Wyngaarden
Location: Holland, Michigan

Re: Designing an analysis friendly Stockfish?

Post by gaard » Fri Feb 04, 2011 12:46 am

fruity wrote:SF PA_G scores about 15 Elo below SF default at very fast games in my tests. If everything would have been correctly coded in SF PA_G that should not be the case. I think the ok_to_use_tt_PV() function is not quite right. The test for TT hits should rather look like

Code: Select all

bool ok_to_use_TT(const TTEntry* tte, Depth depth, Value alpha, Value beta, int ply) {

    Value v = value_from_tt(tte->value(), ply);

    return (   tte->depth() >= depth
            || v >= Max(value_mate_in(PLY_MAX), beta)
            || v <= Min(value_mated_in(PLY_MAX), alpha))

           && (
        		    ((tte->type() & VALUE_TYPE_LOWER) && v >= beta)
        		 || ((tte->type() & VALUE_TYPE_UPPER) && v <= alpha)
        		 || (tte->type() == VALUE_TYPE_EXACT && v < beta && v > alpha)
        	  );
  }
in both cases, PV and non-PV. Please correct me if I'm wrong. If I change the code appropriately, I get a slightly positive score after 6000 ultra fast games, like expected. Result was: +1921 -1814 =2265 from changed SF PA_G's pov.
I had not touched ok_to_use_TT but I will go ahead and fix this. Was the +1921 -1814 =2265 score from the 20" games?

Jeremy Bernstein
Site Admin
Posts: 1226
Joined: Wed Jun 09, 2010 7:49 am
Real Name: Jeremy Bernstein
Location: Berlin, Germany
Contact:

Re: Designing an analysis friendly Stockfish?

Post by Jeremy Bernstein » Fri Feb 04, 2011 12:57 am

fruity wrote:in both cases, PV and non-PV.
You're saying replace the contents of both ok_to_use_TT() and ok_to_use_TT_PV() with what you posted, or just for ok_to_use_TT()?

Actually, what you wrote only works in ok_to_use_TT_PV(), anyway. There is no alpha parameter in ok_to_use_TT()/

jb

Post Reply