Velocity Reviews

Velocity Reviews (http://www.velocityreviews.com/forums/index.php)
-   C++ (http://www.velocityreviews.com/forums/f39-c.html)
-   -   #define increases compile time significantly (http://www.velocityreviews.com/forums/t459851-define-increases-compile-time-significantly.html)

Shirsoft 01-16-2007 06:58 AM

#define increases compile time significantly
 
I have used a #define to reduce code size but it greatly increases the
compile time (from a few secs to 5 mins)
The #define is quite simple

#define UPDATE_VOL_SLICE(VOL,I,J,K, VAL)\
VOL[K][J][I] = VOL[K-1][J-1][I] + VAL\
+ VOL[K-1][J][I-1] - VOL[K-1][J-1][I-1]\
+ VOL[K][J-1][I-1] - VOL[K-1][J-1][I-1]

There are 2 more similar but bigger #define used by my program. They
are used a total of 20 times in the code.

Thanks
Shireesh


=?iso-8859-1?q?Erik_Wikstr=F6m?= 01-16-2007 07:07 AM

Re: #define increases compile time significantly
 
On Jan 16, 7:58 am, "Shirsoft" <shirs...@gmail.com> wrote:
> I have used a #define to reduce code size but it greatly increases the
> compile time (from a few secs to 5 mins)
> The #define is quite simple
>
> #define UPDATE_VOL_SLICE(VOL,I,J,K, VAL)\
> VOL[K][J][I] = VOL[K-1][J-1][I] + VAL\
> + VOL[K-1][J][I-1] - VOL[K-1][J-1][I-1]\
> + VOL[K][J-1][I-1] - VOL[K-1][J-1][I-1]
>
> There are 2 more similar but bigger #define used by my program. They
> are used a total of 20 times in the code.


Anything wrong with a normal inlined function?

--
Erik Wikström


Shirsoft 01-16-2007 08:03 AM

Re: #define increases compile time significantly
 
Some time back i had tested the speed of inline to actual code and the
speed was not same. The inline code was slower. Will try again and let
you know

Erik Wikström wrote:
> On Jan 16, 7:58 am, "Shirsoft" <shirs...@gmail.com> wrote:
> > I have used a #define to reduce code size but it greatly increases the
> > compile time (from a few secs to 5 mins)
> > The #define is quite simple
> >
> > #define UPDATE_VOL_SLICE(VOL,I,J,K, VAL)\
> > VOL[K][J][I] = VOL[K-1][J-1][I] + VAL\
> > + VOL[K-1][J][I-1] - VOL[K-1][J-1][I-1]\
> > + VOL[K][J-1][I-1] - VOL[K-1][J-1][I-1]
> >
> > There are 2 more similar but bigger #define used by my program. They
> > are used a total of 20 times in the code.

>
> Anything wrong with a normal inlined function?
>
> --
> Erik Wikström



Ian Collins 01-16-2007 08:22 AM

Re: #define increases compile time significantly
 
Shirsoft wrote:

Please don't top-post. Corrected.
>
> Erik Wikström wrote:
>
>>On Jan 16, 7:58 am, "Shirsoft" <shirs...@gmail.com> wrote:
>>
>>>I have used a #define to reduce code size but it greatly increases the
>>>compile time (from a few secs to 5 mins)
>>>The #define is quite simple
>>>
>>>#define UPDATE_VOL_SLICE(VOL,I,J,K, VAL)\
>>> VOL[K][J][I] = VOL[K-1][J-1][I] + VAL\
>>> + VOL[K-1][J][I-1] - VOL[K-1][J-1][I-1]\
>>> + VOL[K][J-1][I-1] - VOL[K-1][J-1][I-1]
>>>
>>>There are 2 more similar but bigger #define used by my program. They
>>>are used a total of 20 times in the code.

>>
>>Anything wrong with a normal inlined function?
>>

> Some time back i had tested the speed of inline to actual code and the
> speed was not same. The inline code was slower. Will try again and let
> you know


Then it wasn't being inlined.

Check your compiler's documentation for inline code size and optimisations.

--
Ian Collins.


All times are GMT. The time now is 08:16 AM.

Powered by vBulletin®. Copyright ©2000 - 2014, vBulletin Solutions, Inc.
SEO by vBSEO ©2010, Crawlability, Inc.