home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!munnari.oz.au!bruce.cs.monash.edu.au!monu6!escargot!goanna!ok
- From: ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe)
- Newsgroups: comp.lang.c
- Subject: Re: Allowed Fortran and C optimizations
- Message-ID: <16019@goanna.cs.rmit.oz.au>
- Date: 21 Nov 92 06:22:12 GMT
- References: <1992Nov16.153307.4632@alchemy.chem.utoronto.ca>
- Organization: Comp Sci, RMIT, Melbourne, Australia
- Lines: 39
-
- In article <1992Nov16.153307.4632@alchemy.chem.utoronto.ca>, mroussel@alchemy.chem.utoronto.ca (Marc Roussel) writes:
- > A few days ago, I suggested that I might post some example code
- > showing that better performance can sometimes be obtained from Fortran
- > than C unless one is willing to hand-tune the C code.
-
- So much depends on the machine and the compilers. On the machine that
- I'm posting from, I have had cases where f2c+gcc produced faster code
- than f77.
-
- > Compiling this in ANSI mode with the -O flag we get 9.93 MFLOPS, i.e.
- > about half the Fortran performance. Interestingly, we get 9.93 MFLOPS
- > without switching to array syntax, i.e. with just the la and lcnt hacks.
-
- This should not have been a surprise. Changing from
- foo(a) double a*;
- to foo(a) double a[];
- changes NOTHING. In both Classic C and ANSI C the two are identical
- in every respect.
-
- > Now the +Om1 flag does what I want it to, but I wouldn't want to
- > compile a library or program written in C by someone else with it: Since C does
- > not force you to keep your function parameters distinct, I couldn't
- > count on the program executing correctly.
-
- This is a well understood point, and Jim Giles has explained it in detail
- many times. The argument founders on one vital point:
- Fortran does not force you to keep your function parameters
- distinct _either_.
- The basic point here is that
- The Fortran compiler goes ahead and ASSUMES that the arguments
- are distinct,
- the C compiler doesn't make that assumption unless you TELL it to.
- It is true, and it is important, that the Fortran standard forbids aliased
- arguments, and the C standard doesn't. But if you want to "count on [a]
- program executing correctly", you want a development system which will
- enforce whatever assumptions the compiler is relying on. I have seen a
- great deal of Fortran code which blithely ignored the standard's restriction.
- Tools like the PORT checker or ToolPack are all but essential.
-
-