
On Sat, 12 Jan 2002, eric wrote:
Iterations took 6.12530398369 seconds. Fortran iterations took 3.15447306633 seconds.
Hey! That is larger than I would have expected. Fortran often has a slight advantage ( a few percent), but not a factor of 2. Several things could be in play here.
(1) Prabhu and I have no clue how to set compiler switches in gcc for best results. (very possible) (2) Your using a better optimizing Fortran compiler (wonder what the Intel or KAI compiler would do on the C++ code). Which one are you using? If it is g77, then this is exhibit A for supporting (1). (3) If comparisons are made against Prabhu's C++ code instead of my extension module which (mis) uses blitz++ arrays for indexing, would only show a 33% improvement. Correct? This is starting to be more what I'd expect.
I used the same code (laplace.py) that was in your message to this list.
Anyway, I'd be surprised if the difference is this great in the final analysis -- I'll bet less than 10% difference either way.
I used g77 in these tests. But indeed, also with heavy optimizations switches turned on. Here are other results with different optimization flags enabled: 1) g77 -02 (standard) Iterations took 6.34938693047 seconds. Error: 38047.7567709 Fortran iterations took 3.69506299496 seconds. Error: 21778.5117188 2) g77 (no optimization) Iterations took 6.44155204296 seconds. Error: 38047.7567709 Fortran iterations took 3.82356095314 seconds. Error: 21778.5117188 3) g77 -O3 -funroll-loops -march=i686 -malign-double (machine depend.) Iterations took 6.34858202934 seconds. Error: 38047.7567709 Fortran iterations took 3.29500699043 seconds. Error: 21778.5117188 4) ifc -O3 -tpp6 -xi (this is Intel Fortran 90 compiler for Linux) Iterations took 6.38630092144 seconds. Error: 38047.7567709 Fortran iterations took 2.84432804585 seconds. Error: 21779.0996094 Note that even without any optimization and with g77, the factor is still quite high: 1.6. And with Intel compiler this is 2.2. So, I would not be so pessimistic about Fortran capabilities. I guess that these numbers also depend on the particular test, and the current one just fits for Fortran. Anyway, I don't think that people would use Fortran if the gain in speed would be only few percent. It must be higher than that. Regards, Pearu