inline question

S

Steve Pope

toton said:
Steve Pope wrote:
Macros are evil. I will never use them except some very simple cases,
even when I am very careful.

Agreed. (But you did say you wanted some functions/operators inlined,
and this is one approach...)
I hadn't said that. What I had said is that inlined functions need to
be in header (not translation unit) , may be at the place of
declaration, or may be seperately after declaration. If the whole
header file has forward declaration of cetrain class, due to circular
dependency, One can not write inline function which use the definition.

Thanks, that makes sense.

Steve
 
B

Bo Persson

Steve said:
I have always liked "register" because it is not in general possible
from textual analysis to determine which of the auto variables
in a function are used most frequently.

But the compiler can do that on its internal representation.
This was not so bad in C, since you would typically declare them all
at the beginning of the function's block, and the compiler would
place
them in registers until it ran out. In C++, with vairables declared
willy-nilly throughout the function, the register keyword is more
useful.

I would say that it is less useful, because the compiler can easíly
change the register allocation halfway through the function. The
programmer cannot.


Bo Persson
 
B

Bo Persson

toton said:
peter said:
toton wrote:
[snip]
Or may be someday
compiler will compile the program, ask user to run a few standard
run, collect the stats and reoptimize the program based on that. A
SemiJIT or CachedJIT, whatever you call it :)
This is done today already.
Which compiler do it for C++? I only know IBM Java VM cache the
Jitted
code from first run of the Java program, for subsiquent runs. Not
aware of any other compiler (C++ or any other language), which ask
user or programmer for a few "typical run" of the program and
optimize the code. This is something like optimizing the code
statically, before actual run, based on standard run for specific
processor architecture. Interested to hear about such AOT compilers
or some reference to them. :)

Both Intel's and MS' C++ compilers will do that. The programmer first
peforms a few "typical runs" to collect profile data, and then
recompiles.


Bo Persson
 
P

peter koch

toton skrev:
peter said:
toton wrote:
[snip]
Or may be someday
compiler will compile the program, ask user to run a few standard run,
collect the stats and reoptimize the program based on that. A SemiJIT
or CachedJIT, whatever you call it :)
This is done today already.
Which compiler do it for C++?
The new Microsoft compiler does so - and there probably are other (I'd
be surprised if Intel did not use the same trick).
/Peter
[snip]
 
D

Dave Steffen

toton said:
peter said:
toton wrote:
[snip]
Or may be someday compiler will compile the program, ask user to
run a few standard run, collect the stats and reoptimize the
program based on that. A SemiJIT or CachedJIT, whatever you call
it :)
This is done today already.

Which compiler do it for C++? I only know IBM Java VM cache the
Jitted code from first run of the Java program, for subsiquent runs.
[...]

IIRC GCC has had this for a while. I've never used it, and don't
know the details, but it's something to do with the 'gcov' code
coverage tool and the -fprofile-arcs -ftest-coverage options. I
think this has been available for several years.
 
I

info

Bo Persson said:
Both Intel's and MS' C++ compilers will do that. The programmer first
peforms a few "typical runs" to collect profile data, and then
recompiles.
I made a test for a while and the gain was not very good:
compiling lame using PGO give me 1-2% more speed...
For application which are not manually tuned, I get some times 10%
but I think that the effort needed (running samples, recompiling, ...)
to use this feature is too high.


------------------------------------------
CoverageMeter Software Factory
> Code Coverage Tool for C/C++ <

Homepage: http://www.coveragemeter.com
------------------------------------------
 

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

Similar Threads

gcc inline memcpy 7
inline functions 2
Proposed Standard Change: inline this 8
inline vs. function pointers 36
how to inline member function is a separate file 6
inline 5
Inline functions 33
inline, templates, 1

Members online

Forum statistics

Threads
473,776
Messages
2,569,603
Members
45,192
Latest member
KalaReid2

Latest Threads

Top