#define increases compile time significantly

S

Shirsoft

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] = VOL[K-1][J-1] + 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?=

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] = VOL[K-1][J-1] + 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?
 
S

Shirsoft

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
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] = VOL[K-1][J-1] + 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?
 
I

Ian Collins

Shirsoft wrote:

Please don't top-post. Corrected.
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] = VOL[K-1][J-1] + 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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,057
Latest member
KetoBeezACVGummies

Latest Threads

Top