On Jul 13, 2004, at 8:42 PM, Keith Bierman wrote:
> Bill Long wrote:
>
> many sage words...
> ...
> Your best optimization chances with a C program are if you
> write it to look just like a Fortran program (sometimes called Ctran).
>
> This is also true on a variety of non-vector systems. Sometimes there
> are compiler flags to tell C to have more Fortran like semantics
> (assume things about pointers which are dubious ... unless the author
> of the code wrote in Ctran ;>)
>
>
> 2) Vectorization and parallelization depend on the compiler's ability
> to
> analyze data dependencies in the code. This is made significantly
> more
> difficult in programs that use pointers, which is the common
> programming
> model in C. Fortran's support for arrays and aliasing rules for dummy
> arguments allow for much better automatic vectorization and
> parallelization.
>
>
> Indeed, this is ... and will remain true for the foreseeable future
> (it's deeply ingrained into the "DNA" of each of the two language
> standards). With the exception of processor/user collusion to write
> Fortran with C spellings ... which has dubious portability ... to say
> the least. Also, if it's a large code ... some maintainer off in the
> far future, will almost certainly destroy the careful Ctran coding ;>
> because they will think they are coding in C.
>
> In many ways C++ is harder for an optimizer.
>
> So if you want it to go as fast as it can, without writing it in
> assembler ... you generally are better off in Fortran.
I agree with this. There is no doubt Fortran code can be made faster,
easier.
One thing which I haven't seen brought up, which is in favor of higher
level languages like C++ and Java, is algorithmic performance. The
algorithm you choose can often be much more important than the extra
cycles a compiler can save you. An advantage with C++/Java like
languages is simply that they are better at abstraction, and this can
make writing complex algorithms easier. The fortran version of the
algorithm would nearly always run faster, but writing the fortran
version may be considerably harder.
So it depends largely on what you want to do, and whether you can make
inroads algorithmically. Sometimes you can't, and Fortran is then the
logical choice.
Drew
========================================
Dr. Drew McCormack (Kmr. R153)
Afd. Theoretische Chemie
Faculteit Exacte Wetenschappen
Vrije Universiteit Amsterdam
De Boelelaan 1083
1081 HV Amsterdam
The Netherlands
Email [log in to unmask]
Web www.maniacalextent.com
Telephone +31 20 44 47623
Mobile +31 6 483 21307
Fax +31 20 44 47629
|