P
Patrick Laurent
I found nothing on the GCC mailing list.
I posted a mail...waiting...
I posted a mail...waiting...
Patrick Laurent said:I found nothing on the GCC mailing list.
I posted a mail...waiting...
should be careful comparing the results of different compilers.
However, the question of to inline or not to inline should be left to the
compiler as it is closely connected to the other optimizations.
I could not test with GCC 4.0 yet, because the version is very new, and ourBTW have you tried your code with GCC 4.0 which is based on a totally
different design and also optimization approach?
Patrick said:I agree, but I still can compare the execution speed on the same computer,
with a chronometer.
The winner is the quickest.
I don't really care how the compiler does its job, but it must give a quick
executable.
And in this case GCC is between 3 times and 20 times slower.
I'd love not be concerned with inlining and let this difficulty to the
compiler, but I have many reasons to think that the slowness is due to bad
inlining from GCC.
I could not test with GCC 4.0 yet, because the version is very new, and our
administrator thinks (I don't know why, he must have his reasons) that it is
not stable enough.
Pat
Patrick said:I agree, but I still can compare the execution speed on the same computer,
with a chronometer.
The winner is the quickest.
I had a similar issue not too long ago. It was a numerical math problemPatrick said:I only wrote the parameters names.
Yes,I did supply a value (in fact I tried many values, most of the time big
values).
But GCC still doesn't inline many important functions, in comparison ICL on
windows does.
You are right, GCC tells which parameter is exceeded, so I always supplied a
bigger value to every corresponding parameter (up to astronomic values). But
it did not work: a few more functions were inlined, but the execution speed
is still very much slower than on Windows.
Is there no way to force inlining?
Pat
inline like a hammer. Most of the non-class functions that you declare
inline won't be inlined anyway because of their structure. Inlining
those would presumably have more negative than positive effects
regarding cache misses. Furthermore, you have quite a lot of redundant
code, which could be optimized (and in most cases will be) by the
compiler. However, it strikes me a little odd, as your obviously very
speed concerned.
I had a similar issue not too long ago. It was a numerical math problem
that could be parametrized with function templates. With gcc 3.4 I
cranked the parameters up ( I don't recall the actual numbers and the
parameters, but I think I tried something well in the range of 100000)
until everything was inlined. It gave me a factor ten in execution
speed. Also change the right parameter. I am not kidding, there are lots
of parameters that have 'inline' in their name.
I have never programmed for a windows platform, but on linux gcc
produces very fast code in my experience. Comparabable in speed to the
code produced with icc or the portland compiler
Patrick Laurent said:I declared many inline functions, but there are small functions.
I admit that the combinaison of many functions can become quite big.
But as far as I know the 'O2' or 'O3' options consider any function
(inline or not) as potentially inlinable.
GCC might be good for C programs, but not for generic C++ (in comparison
to ICL).
If you think that my program is redundant (or bad), contributions are
welcome, but not critics.
You could have a look to MTL,Pooma,Blitz++,Newmat: these libraries use
equivalent princips.
My philosophy was never to adapt my code to the compilers, I want to have
my code as clean as possible.
you really wanna drive it to the edge then you will have to resort to some
compiler specific things at some time. The aforementioned libs make
extensive use of meta-template programming, which is why they are fast. If
I remember correctly there should be a FFT implementation based on this
technique in Tod's Blitz++.
Anyway, first of all relax & take a depp breath. Second, if you put your
code on the web and make it public you will have to face criticism (it
happens and happened to the best), but you should realize that criticism
is not necessarily a bad thing! Speaking of this I never said that your
code is bad, but I said that after a quick glance I saw that there are
redundant parts and I'll stick to this statement.
In FFT for example you declare variables of value_type very often just to
assign a value of an array to it. Afterwards you call a new function with
the sum or the difference of these newly declared variables. Why not just
use the array itself? Of course, the compiler can and most certainly will
optimize this away after data-flow analysis, but you're making the life of
the compiler harder than necessary.
I honestly do not feel at ease about your speed sensitive applications...We frequently use it here at CERN, also for speed sensitive applications &
simulations
Patrick said:My question was "how force inlining", not "Should I inline".
I honestly do not feel at ease about your speed sensitive applications...
My question was "how force inlining", not "Should I inline".
Until yet, you did not tell a single thing that would help me a little bit.
Patrick Laurent said:I did at gcc-help.
I was adviced by someone in charge, to post my problem as a bug.
It is not really a bug, nevertheless I have posted my problem for 2 days.
I am still waiting an answer...
My question was "how force inlining", not "Should I inline".
Until yet, you did not tell a single thing that would help me a little bit.
Patrick said:I did at gcc-help.
I was adviced by someone in charge, to post my problem as a bug.
It is not really a bug, nevertheless I have posted my problem for 2 days.
I am still waiting an answer...
satisfy you, then perhaps you should pick another compiler.
Patrick said:I do, I use ICL on Windows.
But I want other people to use my library on other systems.
They can, but a similar speed to ICL is in some cases not available.
Yes, Intel C++ Compiler for Linux, is called ICC.also a Linux version of it.
I can exclude the macro suggestion.There are also two other ways to inline. Using macros, or convert your
run-time computations to compile-time (template meta-programming). Both
are an entire world of their own (for advanced uses). Or use assembly, but
that one is not portable.
Patrick Laurent said:[...]
I can exclude the macro suggestion.There are also two other ways to inline. Using macros, or convert your
run-time computations to compile-time (template meta-programming). Both
are an entire world of their own (for advanced uses). Or use assembly, but
that one is not portable.
I can exclude assembly too!
I think I know what you mean with 'meta programming'. I can exclude it too.
I use meta programming for type handling. I cannot imagine any way to
program a FFT, or any other signal processing functions with meta
programming.
It seems to be theoretically possible,
but anyway I think the
compilers are not quite ready yet.
Patrick said:I can exclude the macro suggestion.
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.