Hi,
I just made my program ~3% faster, perhaps more (nothing to do with chess) by forcing the compiler to use __fastcall instead of the default __cdecl.
I wonder whether using __fastcall would have the same effect with PGO enabled.
Could someone verify this? I believe it may be a nice speedup for the windows build of a chess engine, if it would hold with PGO.
It may but it may not. I especially wonder what compiler experts have to say about it
Martin
VisualStudio - __fastcall instead of __cdecl?
Moderators: hgm, Rebel, chrisw
-
- Posts: 2559
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
-
- Posts: 1385
- Joined: Fri Jul 14, 2006 7:56 am
- Location: London, England
- Full name: Jim Ablett
Re: VisualStudio - __fastcall instead of __cdecl?
Hi Martin,
I read about this optimization tip many years ago from Dann Corbit and use it whenever possible with Msvc
although I found it produces instability with some chess engine code, so you must be careful. If I used with Intel, binary would always crash or become unstable.
http://www.playwitharena.com/?Tips_%2B_ ... r_Binaries
Jim.
I read about this optimization tip many years ago from Dann Corbit and use it whenever possible with Msvc
although I found it produces instability with some chess engine code, so you must be careful. If I used with Intel, binary would always crash or become unstable.
http://www.playwitharena.com/?Tips_%2B_ ... r_Binaries
Jim.
-
- Posts: 481
- Joined: Thu Apr 16, 2009 12:00 pm
- Location: Slovakia, EU
Re: VisualStudio - __fastcall instead of __cdecl?
Hi,mar wrote:Hi,
I just made my program ~3% faster, perhaps more (nothing to do with chess) by forcing the compiler to use __fastcall instead of the default __cdecl.
I wonder whether using __fastcall would have the same effect with PGO enabled.
Could someone verify this? I believe it may be a nice speedup for the windows build of a chess engine, if it would hold with PGO.
It may but it may not. I especially wonder what compiler experts have to say about it
Martin
Just in case you didn't already know - this option is ignored for 64bit builds. The x64 ABI defines only one calling convention, __fastcall.
http://msdn.microsoft.com/en-us/library/ms235286.aspx
Richard
-
- Posts: 2559
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: VisualStudio - __fastcall instead of __cdecl?
That's interesting Jim, I only noticed some compile time problems with libpng and tremor where some callback function ptrs were explicitly declared as __cdecl and thus incompatible with __fastcall, didn't know about stability issues though. I guess I'll be happy with cdecl then. Thanks for clarifying this to me.Jim Ablett wrote:Hi Martin,
I read about this optimization tip many years ago from Dann Corbit and use it whenever possible with Msvc
although I found it produces instability with some chess engine code, so you must be careful. If I used with Intel, binary would always crash or become unstable.
http://www.playwitharena.com/?Tips_%2B_ ... r_Binaries
Jim.
Martin
-
- Posts: 2559
- Joined: Fri Nov 26, 2010 2:00 pm
- Location: Czech Republic
- Full name: Martin Sedlak
Re: VisualStudio - __fastcall instead of __cdecl?
Thanks Richard I didn't know that. It seems logical though because as far as I understand 64-bit mode has more registers available than x86 mode. Thanks for the insight.rvida wrote: Hi,
Just in case you didn't already know - this option is ignored for 64bit builds. The x64 ABI defines only one calling convention, __fastcall.
http://msdn.microsoft.com/en-us/library/ms235286.aspx
Richard
Martin