[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

Re: [pygame] Capabilities of Pygame





On Sat, Jan 14, 2012 at 12:03 AM, R. Alan Monroe <amonroe@xxxxxxxxxxxxxxx> wrote:
> FORTRAN is still used in some circles because it's
> still very fast for number crunching.

A bit off topic, but I've seen this bit of folk wisdom repeated online
for a long time and have always been skeptical. How does a C command
that gets compiled to a CPU's MUL instruction differ in any way from a
Fortran command that also gets compiled to that same CPU's same MUL
instruction? Honest question.

Alan



Theoretically, the compiler has more information about the fortran code than the C code, so can make more optimizations.  So in C, the compiler can not be sure about pointer aliasing, and such things... so it has to be a little safer about the optimizations.  In practice, you can provide hints to the C compiler to get pretty much the same performance.  For a modern C compiler like gcc, you have things like 'pure', 'restrict', openmp hints, function level optimization optimizations, and various other vectorisation hints that let you do lots of optimizations that fortran can do.

See this for more info:
    http://stackoverflow.com/questions/146159/is-fortran-faster-than-c
Also see here that fortran is still speedy:
    http://shootout.alioth.debian.org/u64q/which-programming-languages-are-fastest.php


cheers,