[LC++]floating processing of gcc

ianezz at sodalia.it ianezz at sodalia.it
Mon Mar 25 20:15:04 UTC 2002


Ray hong, pigiando tasti a caso sul citofono, ha scritto:

 > I found that the exectuable code generated by using GCC is
 > much slower than other commercial compilers.

Don't be surprised by that: optimizing compilers for specific
languages targeted at specific platforms are usually able to generate
executables running faster (or, at the worst, on par) than the ones
generated by gcc (which is a multi-language cross-compiler).

If speed of your executables on a given platform is your main concern,
gcc usually is at most the second best choice.

 > The exectuable code generated using absoft-fortran is at least
 > twice faster than the one generated by using f2c + gcc.

Well, for my little experience, optimizing FORTRAN is a different
matter than optimizing C code (incidentally generated by a
FORTRAN-to-C translator): the former should be easier to optimize (or,
at least, producing optimized code from FORTRAN should be a better
understood problem than producing optimized code from C).

But be sure to have a look at the optimizing options available for gcc
(i.e. even with -O3 it doesn't always unroll loops unless you tell it
explicitly).

 > Could anyone find a solution for that?

I'd say that you have basically four choices:

1) Stick to FORTRAN, and buy a proprietary compiler targeted to the
   platform of you choice. 

   This already gave you very good results, from what you said.

2) Port the FORTRAN code to C by hand, without using an automatic
   translator (which probably doesn't generate very good C), and buy a
   proprietary C compiler targeted to the platform of your choice.

   This should give equally good results as (1), but with more effort,
   and you end buying a proprietary compiler anyways.

3) Port the FORTRAN code to C and use gcc, optimizing the code by hand
   where needed using inline assembly. 

   This is the solution used for the Linux kernel: it works, but
   requires a lot of effort and knowledge.

3bis) Port the FORTRAN code to C, and use GNU GMP
      (http://swox.com/gmp/#DOC) to do math. GMP functions are already
      optimized by hand for several platforms, using inline
      assembly. YMMV.

4) Stay with f2c + gcc. It works, slowly, but it works. 

-- 
 |   \    \  | ___|_  |_  | ianezz AT sodalia.it
 |  _ \  | \ | _|    /   /  Visita il LinuxTrent a
_|_/  _\_|  _|____|___|___| http://www.linuxtrent.it




More information about the tuxCPProgramming mailing list