Page 1 of 2

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

Posted: Mon Apr 12, 2010 7:05 pm
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

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

Posted: Mon Apr 12, 2010 9:01 pm
by Roman Hartmann
You might want to add /GL

Roman

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

Posted: Mon Apr 12, 2010 9:08 pm
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.

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

Posted: Mon Apr 12, 2010 9:08 pm
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).

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

Posted: Mon Apr 12, 2010 9:29 pm
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.

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

Posted: Mon Apr 12, 2010 10:04 pm
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.

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

Posted: Mon Apr 12, 2010 11:50 pm
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

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

Posted: Tue Apr 13, 2010 1:34 am
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 :(

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

Posted: Tue Apr 13, 2010 1:44 am
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.

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

Posted: Tue Apr 13, 2010 4:42 am
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