No, this is not only due to the compiler.
What tests, such as this one, where a program differs from benchmarks, is basically the amount of effort (and quality of effort) that a programmer wrote in writing in any given program. I suspect Fortran is in significant inconvenience in this particular metric - unlike C and C ++, the pool of programmers who would like to try their hand at improving the test program is quite small, and unlike most others, they probably I don’t feel that they have something to prove. Thus, there is no motivation for someone to spend several days looking for the generated assembly code and profiling the program to speed up its work.
This is pretty clear from the results. In general, with sufficient programming efforts and a decent compiler, neither C, C ++, nor Fortran will be much slower than the assembly code - of course, no more than 5-10%, in the worst case, except in pathological cases. The fact that the actual results obtained here are more than an option indicates that “sufficient programming efforts” have not been expended.
There are exceptions when you allow the assembly to use vector instructions, but do not allow C / C ++ / Fortran to use the corresponding built-in compiler functions - automatic vectorization is not even a close approximation of perfection and probably never will. I do not know how much they can be applied here.
Similarly, an exception occurs in things like string processing, where you are heavily dependent on the runtime library (which can be of varying quality; Fortran is rarely the case when a fast string library will make money for the compiler provider!), And basically the definition of "string" and how it is represented in memory.
Brooks Moses Aug 06 '09 at 3:29 2009-08-06 03:29
source share