lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Mon, Dec 3, 2012 at 8:35 PM, Miles Bader <miles@gnu.org> wrote:
> Coda Highland <chighland@gmail.com> writes:
>>> I have read many times that FORTRAN is better Than C for number
>>> crunching buy I do not know WHY?
>>
>> Long story short, it's actually not. Once upon a time, it was, when C
>> was a systems programming language and FORTRAN was explicitly created
>> for mathematics. Now, not so much -- with the GNU tools, both
>> languages compile down to essentially the same thing and are
>> essentially equivalent in performance.
>
> Hmm, I seem to recall that fortran programs benefit from different
> language rules regarding aliasing, such that a fortran compiler can
> ignore potential aliasing in situations where a C compiler can not.
>
> Aliasing issues can be a significant problem for optimizers, so this
> additional freedom can result in better optimization.  This is
> especially the case with a lot of matrix-heavy math codes.
>
> Now, given the degree to which fortran and C compilers often share
> infrastructure these days, I don't know the degree to which optimizers
> actually make good use of this additional freedom, but it is a
> potential benefit, and it's certainly possible to take advantage of
> it, even in a multiple language compiler.
>
> -Miles
>
> --
> .Numeric stability is probably not all that important when you're guessing.

C can get the same no-aliasing benefits if you use the "restrict"
keyword, which was implemented for exactly that reason.

/s/ Adam