Visual C++ 2008 - good compiler/ linker settings for speed?

Discussion of chess software programming and technical issues.

Moderators: Harvey Williamson, bob, hgm

Forum rules
This textbox is used to restore diagrams posted with the [d] tag before the upgrade.
User avatar
silentshark
Posts: 284
Joined: Sat Mar 27, 2010 6:15 pm
Contact:

Visual C++ 2008 - good compiler/ linker settings for speed?

Post by silentshark » Mon Apr 12, 2010 5:05 pm

The subject field says it all, really. What are good compiler flags to wring out good speed from the MS C++ 2008 compiler?

So far, I've found the following are good:

/O2 - optimise speed
/arch:SSE2 - compile for platforms supporting SSE2 instruction set

But there are probably some other ones I haven't come across?

(And feel free to tell me to go and use compiler X, if I really should be trying something else for high speed code these days)

Regards,
Tom

User avatar
Roman Hartmann
Posts: 295
Joined: Wed Mar 08, 2006 7:29 pm
Contact:

Re: Visual C++ 2008 - good compiler/ linker settings for spe

Post by Roman Hartmann » Mon Apr 12, 2010 7:01 pm

You might want to add /GL

Roman

User avatar
silentshark
Posts: 284
Joined: Sat Mar 27, 2010 6:15 pm
Contact:

Re: Visual C++ 2008 - good compiler/ linker settings for spe

Post by silentshark » Mon Apr 12, 2010 7:08 pm

Roman Hartmann wrote:You might want to add /GL

Roman
Ok, will do. Any other candidates? I've done some googling, but not found much - there's something about profile guided optimisation which I might have a gander at.

Dann Corbit
Posts: 11626
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Visual C++ 2008 - good compiler/ linker settings for spe

Post by Dann Corbit » Mon Apr 12, 2010 7:08 pm

silentshark wrote:The subject field says it all, really. What are good compiler flags to wring out good speed from the MS C++ 2008 compiler?

So far, I've found the following are good:

/O2 - optimise speed
/arch:SSE2 - compile for platforms supporting SSE2 instruction set

But there are probably some other ones I haven't come across?

(And feel free to tell me to go and use compiler X, if I really should be trying something else for high speed code these days)

Regards,
Tom
The Intel compiler produces a little bit better results, most of the time.
Profile guided optimization produced a good gain almost all the time (for both Intel and MSVC++ compilers).

vladstamate
Posts: 161
Joined: Thu Jan 08, 2009 8:06 pm
Location: San Francisco, USA
Contact:

Re: Visual C++ 2008 - good compiler/ linker settings for spe

Post by vladstamate » Mon Apr 12, 2010 7:29 pm

Hi,
Dann Corbit wrote: The Intel compiler produces a little bit better results, most of the time.
Is that valid for AMD processors as well? Will it know to use some intrinsics like popcnt for example? I use then with the MSVC++ compiler.
Dann Corbit wrote:Profile guided optimization produced a good gain almost all the time (for both Intel and MSVC++ compilers).
I can testify to that. I got roughly 12% increase in speed (both when doing perft as well as normal search) by using PGO. In Visual Studio that is done as simply as clicking 3 buttons and waiting your program to run for some time so it gets some performance data. I was quite impressed.

Dann Corbit
Posts: 11626
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Visual C++ 2008 - good compiler/ linker settings for spe

Post by Dann Corbit » Mon Apr 12, 2010 8:04 pm

vladstamate wrote:Hi,
Dann Corbit wrote: The Intel compiler produces a little bit better results, most of the time.
Is that valid for AMD processors as well? Will it know to use some intrinsics like popcnt for example? I use then with the MSVC++ compiler.
Dann Corbit wrote:Profile guided optimization produced a good gain almost all the time (for both Intel and MSVC++ compilers).
I can testify to that. I got roughly 12% increase in speed (both when doing perft as well as normal search) by using PGO. In Visual Studio that is done as simply as clicking 3 buttons and waiting your program to run for some time so it gets some performance data. I was quite impressed.
There are problems using the Intel toolset for AMD processors.

The most annoying of which is that the profiler castrates itself.

Sven
Posts: 3883
Joined: Thu May 15, 2008 7:57 pm
Location: Berlin, Germany
Full name: Sven Schüle
Contact:

Re: Visual C++ 2008 - good compiler/ linker settings for spe

Post by Sven » Mon Apr 12, 2010 9:50 pm

silentshark wrote:
Roman Hartmann wrote:You might want to add /GL

Roman
Ok, will do. Any other candidates? I've done some googling, but not found much - there's something about profile guided optimisation which I might have a gander at.
/EH- /GR-

Sven

User avatar
rvida
Posts: 481
Joined: Thu Apr 16, 2009 10:00 am
Location: Slovakia, EU

Re: Visual C++ 2008 - good compiler/ linker settings for spe

Post by rvida » Mon Apr 12, 2010 11:34 pm

vladstamate wrote: I can testify to that. I got roughly 12% increase in speed (both when doing perft as well as normal search) by using PGO. In Visual Studio that is done as simply as clicking 3 buttons and waiting your program to run for some time so it gets some performance data. I was quite impressed.
You are a lucky one. Or you just happen to write "branchy" code. In my experience with Critter there is only cca 5% speedup from PGO :(

Dann Corbit
Posts: 11626
Joined: Wed Mar 08, 2006 7:57 pm
Location: Redmond, WA USA
Contact:

Re: Visual C++ 2008 - good compiler/ linker settings for spe

Post by Dann Corbit » Mon Apr 12, 2010 11:44 pm

rvida wrote:
vladstamate wrote: I can testify to that. I got roughly 12% increase in speed (both when doing perft as well as normal search) by using PGO. In Visual Studio that is done as simply as clicking 3 buttons and waiting your program to run for some time so it gets some performance data. I was quite impressed.
You are a lucky one. Or you just happen to write "branchy" code. In my experience with Critter there is only cca 5% speedup from PGO :(
I have seen up to 30% for some engines.
I usually do the following sort of test during the profile sessions:
1. A couple hundred EPD test positions at 5 seconds each
2. At least ten games of engine verses engine.
3. Perft (if the engine has it) at depths 4/5/6
On the games, I have the GUI restart the engines after each game.

alpha123
Posts: 660
Joined: Sat Dec 05, 2009 4:13 am
Location: Colorado, USA

Re: Visual C++ 2008 - good compiler/ linker settings for spe

Post by alpha123 » Tue Apr 13, 2010 2:42 am

rvida wrote:
vladstamate wrote: I can testify to that. I got roughly 12% increase in speed (both when doing perft as well as normal search) by using PGO. In Visual Studio that is done as simply as clicking 3 buttons and waiting your program to run for some time so it gets some performance data. I was quite impressed.
You are a lucky one. Or you just happen to write "branchy" code. In my experience with Critter there is only cca 5% speedup from PGO :(
I suppose he could be an unlucky one and his non-PGO code is just slow.... :lol:

Peter

Post Reply