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

Discussion of chess software programming and technical issues.

Moderators: hgm, Rebel, chrisw

User avatar
silentshark
Posts: 327
Joined: Sat Mar 27, 2010 7:15 pm

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

Post by silentshark »

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 8:29 pm

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

Post by Roman Hartmann »

You might want to add /GL

Roman
User avatar
silentshark
Posts: 327
Joined: Sat Mar 27, 2010 7:15 pm

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

Post by silentshark »

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: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

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

Post by Dann Corbit »

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 9:06 pm
Location: San Francisco, USA

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

Post by vladstamate »

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: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

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

Post by Dann Corbit »

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: 4052
Joined: Thu May 15, 2008 9:57 pm
Location: Berlin, Germany
Full name: Sven Schüle

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

Post by Sven »

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 12:00 pm
Location: Slovakia, EU

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

Post by rvida »

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: 12538
Joined: Wed Mar 08, 2006 8:57 pm
Location: Redmond, WA USA

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

Post by Dann Corbit »

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 5:13 am
Location: Colorado, USA

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

Post by alpha123 »

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