Performance comparison to C
Tim Prince
tprince@myrealbox.com
Wed Feb 27 14:36:00 GMT 2008
Dennis Wassel wrote:
> Hi everybody,
>
> Since this is my first post to this list (any list, come to that), I'll
> gladly start with a bit of praise:
> I really like the way you have been improving gfortran since the early
> releases. That said, I also get the impression that there still remains
> an awful lot to be done, but I trust in you guys to keep up the pace.
> Nice job!
> I've been using gfortran for some time now for my PhD project, which is
> concerned with a mathematical large-scale nonlinear optimisation solver.
>
> My issue is about some performance comparison stuff I've run a little
> while ago, which was basically a DGEMM routine (blas/lapack notation)
> written in Fortran95 and C, operating on 100x100 random-number matrices.
> I realise that I'm dipping my toe into the pool of the everlasting
> "$MY_LANG is better than $YOUR_LANG"-war in doing so.
>
> I've used three different compilers (GCC 4.2.3, Intel 10.1 and Sun), and
> for all of them results turned out -partly largely- in favour of
> Fortran, even if I ended up doing actual and gruesome hands-on pointer
> arithmetic in C.
> To be fair, the difference with GCC was rather small-ish (say 5-10%,
> quite certainly above measuring tolerance), but ranged between *factors*
> of 1.5-3x with Intel and Sun (depending on loop ordering and stuff). I
> will blame the small difference in gfortran to its still young age, and
> I am sure that, given enough time, you guys will be able to improve
> notably on that. Might even be tempted to join you in that, if I have
> the time and leisure.
>
> I have some really hazy understanding of what *might* be happening
> behind the curtain, with cache utilisation and potential pointer
> aliasing preventing aggressive optimisation in C, but I'd really
> appreciate, if someone who knows this stuff better than I do could shed
> some clearer light on this.
> Also, me and my colleagues have been working on convincing a customer
> that Fortran95 should, for various reasons, be our language of choice
> for developing our solver. If a gcc maintainer now openly stated that,
> Yes, Fortran in general is faster (and more suitable for computational
> stuff anyway) than C, because ..., this could greatly aid our efforts.
>
> Hope this is the right list. If not, please give me some pointers. (No
> easy C jokes on this one, please :-)
>
Not only is this flame war material; behind the flame wars are questions
about ground rules. C can be competitive with Fortran on x86-64, with
attention to issues like restrict qualifiers and (for Intel) pragmas.
Those involve extra development time; some of it has to be repeated for
each compiler.
Intel C requires -ansi_alias to invoke typed aliasing analysis; you would
not want to compare with gcc or with Fortran without setting that.
C tends not to admit reliable multi-level loop optimizations; ifort (but
not icc) has more of those than gfortran.
More information about the Fortran
mailing list