| |
| Posted by Ilya Minkov in reply to Anuj Goyal | PermalinkReply |
|
Ilya Minkov
Posted in reply to Anuj Goyal
| Anuj Goyal schrieb:
> Since fortran compilers have been around for so long, are they more optimized
> than c?
I heard they are able to optimize more agressively, but definately not for the reason of being around longer. The current architectures we use are younger than compilers - DMC is more than 20 years old (previously: Zortech, some other names). GCC is also of comparable age. The performance characteristic of CPUs doesn't look now too much like it was back then.
However, there are ways to give hints to C compilers so that they can employ somewhat more agressive optimizations.
> It seems that the language is mostly for use in the scientific community
> and that many libraries are readily available. These libraries boil down to
> assembly anyways right? what is the difference between using C and using Fortran
> for libraries? Is it the nature of scientific programming that demands Fortran,
> or is just that the scientific communities' programmers are more familiar with
> Fortran?
With the number of libraries... I don't think it really matters since every mathematical foeld is probably covered in each of the languages many times over.
I'm not so sure there is so much "demand" for Fortran... You know, the whole performance difference due to agressive optimizations boils down to perhaps a few per cent - so uncomparably small compared to, say, performance gained by utilizing parallel processing. And the whole small-scale optimization is probably overhyped anyway.
I'm getting the impression that scientific community moves to C++ and high-level solutions, which are far from being optimal on the small scale, but are very easy from the usage point of view, and aid in getting an optimal design on the large scale.
What i say here about C probably applies to Fortran to a large extent, though i must say that i'm not familiar with it. In C, what you are dealing are separate functions, which are compiled separately and take fixed kind and number of arguments. They must be called, which means some sort of overhead. In C++, the working of typical math libraries is radically different, in part due to Templates. Imagine, for example a matrix library. If you were writing it in C, you would have sets of functions handle matrices of certain fixed sizes, and/or you could have a set of functions to handle matrices of arbitrary size - which is slower. But all funcrions to handle matrices of a fixed size would be very similar among sizes. With templates, you are not limited to that, you can have the library generate the code that fits your size. And inlining has shown to be useful where the work done by functions can often be optimized away. Of course the compiler doesn't always get it perfectly optimal, nor is there much that can be done to improve it, but generally it is acceptable.
-eye
|