Computer Chess Club Archives


Search

Terms

Messages

Subject: Re: An inlining and macro peculiarity... (MSVC++ 6)

Author: Ricardo Gibert

Date: 02:53:05 08/22/03

Go up one level in this thread


On August 21, 2003 at 18:22:32, Omid David Tabibi wrote:

>I changed some data structures in my program and added two functions (the
>variables are renamed below):
>
>void func1(unsigned int &a, int b, int c) {
>    a += array[b][c];
>}
>
>BOOL func2(unsigned int a, int b, int c) {
>    return (a & mask[b][c]);
>}
>
>These two functions are very heavily used all over the program. In MSVC 6 I use
>the "inline any suitable" option for inlining, so I assumed that the compiler
>would definitely inline these functions. But again, "assumption is the mother of
>all f**k-ups", after turning the warning level to 4, I found out that these
>functions were not chosen for inlining... strange for itself.
>
>So I added a __forceinline to each of them and recompiled. But still the speedup
>was negligible. So instead I wrote the following two macros:
>
>#define func1(a,b,c)     (a += array[b][c])
>#define func2(a,b,c)     ((a) & mask[b][c])
>
>Wao! about 20% speedup! I was certain that the two functions were not inlined
>previously when I added __forceinline. So I checked it again in warning level of
>4, but didn't find any warning indicating that they were not inlined (if you
>mention __inline or __forceinline, and the compiler can't inline, a warning is
>typically displayed).

Following what I read here under Microsoft Specific concerning /Ob0:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccelng/htm/tions_9.asp

and here:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vccore98/html/_core_different_warnings_appear_using_different_optimizations.asp

I concluded that perhaps what you are experiencing is that you are turning
optimizations off by creating a debug build, which will also turn off some
warnings.

Using /Ob0 seems to be one way of getting what you are experiencing. If this is
not what you did precisely, maybe you did something similar. I hope this helps.
It is just a guess.



This page took 0.01 seconds to execute

Last modified: Thu, 15 Apr 21 08:11:13 -0700

Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.