Sunday, January 15, 2012

New compiler and an old bug

I just installed gcc 4.6.2 and gave it a try on my sources to see whether it performs better than old gcc 4.5.2 I'm currently using. The sources compiled without any problems (I did not include the Gaviota TBS support however) and to my disappointment it did not gave any speed improvement. It was also somewhat slower than the MS Visual C++ compiler, so probably slower than the Intel ICC as well.

However I noticed in one of the test positions a tiny node difference at higher plys between the MSVC compiled code and the code from gcc 4.6.2. This is always a bad sign because it indicates a bug.

So I did some research to spot the exact node where both editions start behaving differently and it turned out to be a problem in the KBKP evaluator. In one version the position was announced as DRAW and in the other not so from here on both versions produced different results.

So after I knew where to look for the problem, it was rather easy to find. I mixed a square value with a bitboard in a comparison operation and the result of that was random. So I fixed it and the search of gcc and the MSVC was identical again, but unfortunately identically wrong.

The old bug disguised a logical problem in the evaluator that became visible now, so I had to recode the KBKP module and I had to do a complete verification cycle against a table base again which took several hours. But now it is fixed and I improved the performance of the module significantly. I does a much better job in spotting the draws than it did before. It is now spotting 90% of all draws using a few known patterns

KBKP Recognizer Performance
Incorrect Evals :         0
Spotted   Draws : 6.355.575
Missed    Draws :   607.948
Spotted   Wins  : 1.248.570

No comments:

Post a Comment