Question About CPP-C#, Performance, and Square Represenation

Discussion of chess software programming and technical issues.

Moderator: Ras

lucasart
Posts: 3241
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Question About CPP-C#, Performance, and Square Represena

Post by lucasart »

spirch wrote:oops, ok it was a 1 liner that I didn't spot :wink:

I tried it on my computer, the test_perft() said something like 220 millions leaf per seconds

nice performance! :)
That's very fast, especially as it's running one thread only. What hardware do you have ? Mine only does 90-95 M leaf/sec.
Note that as my raw perft code evolves into a proper chess engine, the perft() speed will decrease. For example, I've had to introduce psq[] andpiece_psq[] to calculate dynamically PSQ table totals and subtotal for pieces. It's used in the material eval and the game phase interpolation.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
spirch
Posts: 95
Joined: Fri Nov 09, 2012 12:36 am

Re: Question About CPP-C#, Performance, and Square Represena

Post by spirch »

intel i2500k overclocked to 4.4ghz with 8 gig ddr3 1600

compiled under kubuntu with gcc 4.7 i think
lucasart
Posts: 3241
Joined: Mon May 31, 2010 1:29 pm
Full name: lucasart

Re: Question About CPP-C#, Performance, and Square Represena

Post by lucasart »

spirch wrote:intel i2500k overclocked to 4.4ghz with 8 gig ddr3 1600

compiled under kubuntu with gcc 4.7 i think
How much iis there to gain from overclocking ? That is, if you overclock with safe parameters, and don't require some water cooling system or whatever. Do you know where to find reliable tutorials on how to do it ?

I wanted to do it, so I went into the BIOS, and I got scared and didn't dare to touch anything. I had to manually set the CPU voltage and fan speed, and I had no idea what to use, couldn't find any clear instructions in the net, so I left it as it was. I don't want my computer to catch fire, especially when I let it run during the day (with the 2 CPU 100% utilized playing chess) and nobody's at home.
Theory and practice sometimes clash. And when that happens, theory loses. Every single time.
spirch
Posts: 95
Joined: Fri Nov 09, 2012 12:36 am

Re: Question About CPP-C#, Performance, and Square Represena

Post by spirch »

there is many kind of way of overclocking, it depend on the CPU that you have. What is your cpu?

Mine is a sandy bridge so it just a matter of finding the proper cpu voltage while not going over 80c while running CPU test stress for stability for hours(and hours, and hours), I wanted 4.4ghz (i could get more but i don't care) because that is 33% more than the default speed of my cpu which is 3.3ghz and my goal was that.

I use very safe setting for my overclocking, only 1.31 vcore (voltage on the core) you should stay under 1.4 if i remember correctly for sandy bridge, 1.35 for 24/7.

and the cooling that you have, mine look like this(red arrow are the air flow), default heatsink and default case without extra fan is not recommended for overclocking. What is your cooling?

I use this

Image
Cheney
Posts: 104
Joined: Thu Sep 27, 2012 2:24 am

Re: Question About CPP-C#, Performance, and Square Represena

Post by Cheney »

I have tried using the VS2010 profiler a few times. I went ahead and looked at dotTrace but on the surface it appeared to show me the same.

Using VS2010 profiler, something I noticed was where I used a MOD to figure something out (like what file a piece is on). On the left, it would show something like 5.3% on that line. I moved away from using MOD and developed an array that would return the file based on the square index. I guess that helped.

However, other "hot spots" really do not reveal anything to me except those are the most frequently called methods. I do not see where I am calling them unnecessarily (which I did before), so I expect those methods to be hot spots (like generating pawn moves and serializing bits from the pieces' bit boards using DeBruijn).
spirch
Posts: 95
Joined: Fri Nov 09, 2012 12:36 am

Re: Question About CPP-C#, Performance, and Square Represena

Post by spirch »

Do you select "line by line" and check the checkbox high accuracy in dottrace?

Image

this what i get with perft 6 on mine, at the bottom of each screen shot, the view code, left side, is the number of call that line got and the gray kind of progress bar is the % spend on that line for that function

Image
Image
Cheney
Posts: 104
Joined: Thu Sep 27, 2012 2:24 am

Re: Question About CPP-C#, Performance, and Square Represena

Post by Cheney »

Do you select "line by line" and check the checkbox high accuracy in dottrace?
Yes, I tried various settings, including those, to compare what all the differences were and hopefully spot something I can do to increase performance.

When I looked at those numbers on the left, they come to what they should and equal the perft results. The "hot path", according to dottrace, is MakeMove, but then, MakeMove is called for every move and from that perspective, it cannot be called less. If a perft 5 is 4.8m leaves then make move is called at least that many times.

So my dilemma is now to review the code within it to find enhancements. I have changed quite a bit to move from 90 seconds to 2.6 and am now hitting a wall with trying to make the various pieces more efficient.

Did you write in another post that the CLR can be viewed with dottrace or some other tool? I do know that, at times, clr.dll appears (in VS 2010's profiler) just within the "hot path".
spirch
Posts: 95
Joined: Fri Nov 09, 2012 12:36 am

Re: Question About CPP-C#, Performance, and Square Represena

Post by spirch »

in my 2 screenshot, look at the view code area, right side, Show IL code
Cheney
Posts: 104
Joined: Thu Sep 27, 2012 2:24 am

Re: Question About CPP-C#, Performance, and Square Represena

Post by Cheney »

Thanks Fred, I looked at but now need to research just what I am looking at and of course, the 10 day trial now expired. Through this exercise, I learned what the IL Disassembler in the SDK is and will check it out a little more.

Somewhere in looking at DotTrace and ilspy, I launched the exe in the x64\release folder and it performed much better (perft 5 in .5 and perft 6 in 8). I did not know that executing the code while in VS2010 actually affected performance - probably from being attached to the debugger. I feel so duh :)

Anyway, thanks for the help. I am going to continue working on enhancing the search and evaluation and along the way look more at the MSIL code, learn about it, and see if there are ways to increase performance.

Thanks again for all the help :)
spirch
Posts: 95
Joined: Fri Nov 09, 2012 12:36 am

Re: Question About CPP-C#, Performance, and Square Represena

Post by spirch »

anytime and yes, there is a big difference between run from visual studio and run as "standalone"

Image