home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #27 / NN_1992_27.iso / spool / comp / lang / c / 16938 < prev    next >
Encoding:
Internet Message Format  |  1992-11-20  |  2.3 KB

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