473,385 Members | 1,934 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

#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

Jan 16 '07 #1
3 1934
On Jan 16, 7:58 am, "Shirsoft" <shirs...@gmail.comwrote:
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

Jan 16 '07 #2
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.comwrote:
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
Jan 16 '07 #3
Shirsoft wrote:

Please don't top-post. Corrected.
>
Erik Wikström wrote:
>>On Jan 16, 7:58 am, "Shirsoft" <shirs...@gmail.comwrote:
>>>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.
Jan 16 '07 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

18
by: Bryan Parkoff | last post by:
"#define" can only be inside the global scope before main() function. "#if" can be tested after "#define" is executed. The problem is that "#define" can't be inside main() function. I do not wish...
34
by: BQ | last post by:
Hello Is there a way to declare 'FUNCT' via a define so that if its parameter x, a constant, is greater than 35, it returns 56, if not, 20. I would like that at compile time, not at run time. ...
8
by: Fan Zhang | last post by:
Hi group, This is a follow-up of the question I posted this afternoon. I tried to define two constants, PI and radian in that program in the following way, #define PI 3.1415926 #define...
31
by: bilbothebagginsbab5 AT freenet DOT de | last post by:
Hello, hello. So. I've read what I could find on google(groups) for this, also the faq of comp.lang.c. But still I do not understand why there is not standard method to "(...) query the...
7
by: Holger (David) Wagner | last post by:
Hi Group, I've searched the Web for precompilers that compile ASPX/ASCX pages just like it can be done with JSPs, but so far, I've only found approaches targetted at increasing the performance....
7
by: JustBoo | last post by:
Whilst reading through the C++ FAQ. I came across Section 29.8 and realized I never had fully thought about where a #define resided in a Standard C++ program. I thought they were a compile-time...
10
by: Yevgen Muntyan | last post by:
Consider the following macro: #define ALLOCIT(Type) ((Type*) malloc (sizeof (Type))) The intent is to wrap raw memory allocation of N bytes into a macro which returns allocated chunk of memory...
5
by: alan | last post by:
Hello world, I'm wondering if it's possible to implement some sort of class/object that can perform mapping from class types to strings? I will know the class type at compile time, like so:...
27
by: pereges | last post by:
I need to define the plancks constant 6.67 X 10 exp -34. Is it possible to do it using #define or would you suggest using a (static ?)const double.
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.