Is Fortran faster than C?
  Home FAQ Contact Sign in
comp.lang.fortran only
 
Advanced search
POPULAR GROUPS

more...

comp.lang.fortran Profile…
 Up
Is Fortran faster than C?         


Author: Vista
Date: Jul 3, 2007 19:05

Hi all,

Please, allow me to ask this naive question...

I am mainly a programmer in Matlab. Often times for the sake of speed, I
convert my Matlab program into C/C++, often with the aid of numerical
libraries such as GSL, IMSL, MKL, etc.

Now I am facing a numerical computation task which need quadruple precison.
Please see below for a detailed description.

I guess Intel Visual Fortran or other Fortran has natural support for the
quadruple precision.

I probably will have to pick up my Fortran book and do some Fortran
programming. (I've touched a little bit of it some years ago).

Now, speed if critical for my application. If somebody tells me that
Fortran's support of Quadruple precision is about 10%% faster than any other
quadruple solution in any other libraries in C/C++, then I am going to turn
to Fortran.

If the consensus is that Fortran for numerical calculations is only 5%%
faster than C/C++, then I won't bother turn to Fortran.

Thanks!
Show full article (2.65Kb)
147 Comments
Re: Is Fortran faster than C?         


Author: Terence
Date: Jul 5, 2007 23:44

I can't think of a human problem that needs anywhere near 128 bits of
floating point.
Some integer problems I can believe do require absolute accuracy (e.g.
checking you really have found the factores of a very large integer or
for being prime. Also accountants count the very largest amounts in
the most worthless currencies down to the cents that only exist on
paper - even when the thousands denominated tokens are worthless tiny
impure metal objects.

There ARE problems where it is mportant to not lose so much
calculation precision as to not achieve the final objctive with any
accuracy. But as far as I know, all these problema can be resolved in
a way where an approximate solution, with variables being assigned
values which bear close relationship to the truth, allow moving the
starting point of the algorithm to this new startimg approximation and
making another calculation pass. (Normalization). The solutions
usually converge at a reasonable rate to the desired solution with any
desired degre of accureacy, if you proceed.
no comments
Re: Is Fortran faster than C?         


Author: glen herrmannsfeldt
Date: Jul 6, 2007 01:02

Terence wrote:
> I can't think of a human problem that needs anywhere near 128 bits of
> floating point.

(snip)
> There ARE problems where it is mportant to not lose so much
> calculation precision as to not achieve the final objctive with any
> accuracy. But as far as I know, all these problema can be resolved in
> a way where an approximate solution, with variables being assigned
> values which bear close relationship to the truth, allow moving the
> starting point of the algorithm to this new startimg approximation and
> making another calculation pass. (Normalization). The solutions
> usually converge at a reasonable rate to the desired solution with any
> desired degre of accureacy, if you proceed.

Yes, those kind of problems. It might be possible to do other
ways, but sometimes high precision is the best way when you can't
be sure of another way. Or sometimes just to verify that the
other way does give the appropriately close answer.

-- glen
no comments
Re: Is Fortran faster than C?         


Author: Torben Ægidius Mogensen
Date: Jul 6, 2007 01:04

"Vista" gmai.com> writes:
> If the consensus is that Fortran for numerical calculations is only 5%%
> faster than C/C++, then I won't bother turn to Fortran.

This really depends on what you want to do. Fortran compilers
typically optimize for loops over large arrays, often employing loop
interchange, prefetching and blocking, which few (if any?) C/C++
compilers do. C++ can do some of the same optimisations by carefully
writing template libraries that instantiate code to specific array
sizes. I have heard of (at least) FFT and matrix multiply functions
made this way.

So, with good libraries, C++ may match Fortran on large array
operations, but if you need large-array code that isn't matched by an
existing optimized library, you might get more speed out of an
optimizing Fortran compiler.

For code that isn't dominated by loops over large arrays, I doubt
there is much speed difference between a good C/C++ compiler and a
good Fortran compiler.

You could also consider more modern languages like Clean, OCaml or
SML.
Show full article (1.05Kb)
no comments
Re: Is Fortran faster than C?         


Date: Jul 6, 2007 05:29

> Now, speed if critical for my application. If somebody tells me that
> Fortran's support of Quadruple precision is about 10%% faster than any
> other quadruple solution in any other libraries in C/C++, then I am going
> to turn to Fortran.
>
> If the consensus is that Fortran for numerical calculations is only 5%%
> faster than C/C++, then I won't bother turn to Fortran.

I think that is a false criteria on the whole.

One aspect where Fortran per se, has the edge over C, is that Fortran does
not allow aliasing but C does.
So technically a Fotran compiler could make extra optimisations that a C
compiler cannot make.
But this academic, as every C compiler I have seen has switches that allow
the compiler to make some assumptions about aliasing, so in practice, they
are level.

But in terms of support for "Quadruple precision", really that depends on
the compiler implementation not language.
You could easily find a compiler of different languages - ADA, Delphi, C++
that might be faster here.
Show full article (1.37Kb)
no comments
Re: Is Fortran faster than C?         


Author: Lionel B
Date: Jul 6, 2007 05:39

On Fri, 06 Jul 2007 13:29:28 +0100, Stephen Howe wrote:
>> Now, speed if critical for my application. If somebody tells me that
>> Fortran's support of Quadruple precision is about 10%% faster than any
>> other quadruple solution in any other libraries in C/C...
Show full article (1.18Kb)
no comments
Re: Is Fortran faster than C?         


Author: James Van Buskirk
Date: Jul 6, 2007 10:32

"Isaac Gouy" yahoo.com> wrote in message
news:1183741034.825083.266470@d30g2000prg.googlegroups.com...
> Fortran in the benchmarks game is sadly unloved - no one's sending
> Features Requests asking for a different language implementation, no
> one's working on the programs ...

The shootout rules are designed for C programmers, not Fortran
programmers. Whereas a Fortran programmer would look at a
problem statement, carry out some analysis, then compose a
brilliant innovative solution, a C programmer would have to
search for a pre-existing solution, likely in Fortran, then
code it up in C. The pre-existing solutions prescribed in the
shootout page are at least in some cases a couple of orders of
magnitude slower than optimal algorithms.
Show full article (2.78Kb)
no comments
Re: Is Fortran faster than C?         


Author: Greg Lindahl
Date: Jul 6, 2007 10:45

In article <7zr6nmvty4.fsf@app-5.diku.dk>,
Torben
no comments
Re: Is Fortran faster than C?         


Author: Isaac Gouy
Date: Jul 6, 2007 11:00

On Jul 6, 10:32 am, "James Van Buskirk" comcast.net> wrote:
> "Isaac Gouy" yahoo.com> wrote in message
>
> news:1183741034.825083.266470@d30g2000prg.googlegroups.com...
>
>> Fortran in the benchmarks game is sadly unloved - no one's sending
>> Features Requests asking for a different language implementation, no
>> one's working on the programs ...
>>http://shootout.alioth.debian.org/gp4/faq.php#report
>
> The shootout rules are designed for C programmers, not Fortran
> programmers. Whereas a Fortran programmer would look at a
> problem statement, carry out some analysis, then compose a
> brilliant innovative solution, a C programmer would have to
> search for a pre-existing solution, likely in Fortran, then
> code it up in C.
-snip-
Show full article (1.22Kb)
no comments
Re: Is Fortran faster than C?         


Author: Rui Maciel
Date: Jul 6, 2007 11:06

James Van Buskirk wrote:
> The shootout rules are designed for C programmers, not Fortran
> programmers.  Whereas a Fortran programmer would look at a
> problem statement, carry out some analysis, then compose a
> brilliant innovative solution, a C programmer would have to
> search for a pre-existing solution, likely in Fortran, then
> code it up in C.



You sure say a lot of nonsense in that post. From the imaginary class
difference between Fortran programmers and C programmers and the imaginary
border which separates both groups, to the claim that C is " an assembly
language for a long-dead CPU", not to mention that ridiculous assertion
about the learning curve of both languages. For a troll you sure put up a
whole lot of efford into that post.

Rui Maciel
no comments

RELATED THREADS
SubjectArticles qty Group
Re: faster casing = faster tires?!@rec.bicycles.tech ·
1 2 3 4 5 6 7 8 9