Is Fortran faster than C? - Programming Languages

This is a discussion on Is Fortran faster than C? - Programming Languages ; 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 ...

+ Reply to Thread
Page 1 of 19 1 2 3 11 ... LastLast
Results 1 to 10 of 181

Is Fortran faster than C?

  1. Default Is Fortran faster than C?

    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!

    -------------------------------
    Seeking the fastest numerical library for quadruple precision in
    C/C++/Fortran
    Hi all,

    I have some computation and simulation which need quadruple precision. I
    mean, the double precision is not enough, while high precision such as 1000
    digits is not needed, and that's too slow. I guess quadruple precision
    exactly fits my problem and should be much faster than double precision.

    Could anybody tell me if MS Visual C++, or Intel C, Intel Fortran have
    already got quadruple precision in them and they are fully supported on
    Intel based cpus? I guess Intel Fortran has quadruple precision, but since I
    prefer C/C++ so my first choices are within C/C++ languages.

    Moreover, do GSL, Intel MKL, and IMSL etc. have got quadruple precision
    support? I only need +, -, *, /, exp, and log.

    I eventually have to do everything in C/C++ so I am primarily looking for
    numerical libraries, instead of Matlab or Maple or Mathematica's symbolic
    capability.

    But if you know how to "simulate" quadruple precision in Matlab or Maple, or
    Mathematica, in order to see if an algorithm will overslow when converting
    into C/C++/Fortran, please let me know. I want to do the algorithm design in
    Matlab, and test if it will overflow, before converting everything into
    C/C++/Fortran.

    If you know how to "simulate" quadruple precision in Matlab, Maple or
    Mathematica even with the symbolic toolbox, please let me know too... this
    is for algorithm design and testing...

    Moreover, are there popular quadruple precision packages? Please recommend
    the fastest one. I am really in huge need of speed.

    Thank you very much!
    ------------------------------------------------



  2. Default Re: Is Fortran faster than C?

    Vista writes:
    [color=blue]
    > I guess Intel Visual Fortran or other Fortran has natural support for the
    > quadruple precision.[/color]

    What do you mean by "natural" support? My concept involves having a
    128-bit floating point unit and a compiler that can use it. When the
    requested precision exceeds the capabilities of the hardware, it needs
    to be emulated in software, which can be extremely slow.


  3. Default Re: Is Fortran faster than C?

    Vista <abc@gmai.com> wrote:
    [color=blue]
    > 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.[/color]

    I'm going to tell you that if you are looking for such a simple-minded
    metric, then you aren't going to find it. Well, you can probably find
    people who will tell you anything, but I'm assuming you actually want it
    to be accurate.

    The variation from one compiler to another, one application to another,
    and a whole lot of other factors will dwarf any generic language
    difference.

    --
    Richard Maine | Good judgement comes from experience;
    email: last name at domain . net | experience comes from bad judgement.
    domain: summertriangle | -- Mark Twain

  4. Default Re: Is Fortran faster than C?


    <tholen@antispam.ham> wrote in message
    news:468b04e9$0$16592$4c368faf@roadrunner.com...[color=blue]
    > Vista writes:
    >[color=green]
    >> I guess Intel Visual Fortran or other Fortran has natural support for the
    >> quadruple precision.[/color]
    >
    > What do you mean by "natural" support? My concept involves having a
    > 128-bit floating point unit and a compiler that can use it. When the
    > requested precision exceeds the capabilities of the hardware, it needs
    > to be emulated in software, which can be extremely slow.
    >[/color]

    But is there a 128-bit floating point unit in Intel CPU and supported by the
    compiler?

    And how slow is the software emulation?

    I would imagine that the "double double" (quad) will be still much faster
    than multiple/high precision package...



  5. Default Re: Is Fortran faster than C?

    Vista writes:
    [color=blue][color=green][color=darkred]
    >>> I guess Intel Visual Fortran or other Fortran has natural support for the
    >>> quadruple precision.[/color][/color][/color]
    [color=blue][color=green]
    >> What do you mean by "natural" support? My concept involves having a
    >> 128-bit floating point unit and a compiler that can use it. When the
    >> requested precision exceeds the capabilities of the hardware, it needs
    >> to be emulated in software, which can be extremely slow.[/color][/color]
    [color=blue]
    > But is there a 128-bit floating point unit in Intel CPU and supported by the
    > compiler?[/color]

    Not to my knowledge. The 32-bit Intel processors have had an 80-bit
    floating point unit for quite a few years now. I'm not aware of any
    expansion in the FPU with the newer 64-bit processors.
    [color=blue]
    > And how slow is the software emulation?[/color]

    Many times slower than hardware. Can you remember back to the 80386 days
    without a 80387 FPU, or even the 8086 days without an 8087 FPU?
    [color=blue]
    > I would imagine that the "double double" (quad) will be still much faster
    > than multiple/high precision package...[/color]

    That's not obvious. Extended precision software packages simply do it
    in software, just like quad precision.


  6. Default Re: Is Fortran faster than C?

    Vista wrote:[color=blue]
    >
    > I guess Intel Visual Fortran or other Fortran has natural support for the
    > quadruple precision.[/color]

    Intel (and a few other brands) of Fortran support quad without
    additional add-ons, as a standard Fortran data type, even on platforms
    where it is not a hardware supported data type. On a few platforms, such
    as Itanium and Power, there is sufficient hardware support for quad
    precision that it can be carried out in less than 3 times the time
    required for double, for applications which don't spend much time on
    divide or transcendentals. On Itanium, this is done under reasonable
    compliance with IEEE standard for IEEE 128-bit floating point. On more
    popular platforms like x86-64, the loss of opportunity for vectorization
    makes the penalty for quad precision more like an order of magnitude.
    It is still possible to show reasonable compliance with IEEE standard.[color=blue]
    >
    > 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.
    >[/color]

    When you use software floating point, in principle, any differences
    among languages become less important, compared to the quality of the
    floating point emulation. While some C/C++ compilers include some
    hidden support for quad precision, I don't know of any where it's a
    vendor supported data type. So it will be difficult to make a
    meaningful comparison such as you request.[color=blue]
    >
    > I have some computation and simulation which need quadruple precision. I
    > mean, the double precision is not enough, while high precision such as 1000
    > digits is not needed, and that's too slow. I guess quadruple precision
    > exactly fits my problem and should be much faster than double precision.[/color]
    It's difficult to guess what you are getting at here. Certainly, if the
    quad precision of several Fortran compilers satisfies your needs, it
    should be more convenient and possibly more efficient than multiple
    precision libraries such as GMP, particularly if you are restricting
    your usage to Windows.[color=blue]
    >
    > Could anybody tell me if MS Visual C++, or Intel C, Intel Fortran have
    > already got quadruple precision in them and they are fully supported on
    > Intel based cpus? I guess Intel Fortran has quadruple precision, but since I
    > prefer C/C++ so my first choices are within C/C++ languages.
    >
    > Moreover, do GSL, Intel MKL, and IMSL etc. have got quadruple precision
    > support? I only need +, -, *, /, exp, and log.[/color]
    Up to now, I thought you were thinking along the lines of GMP. MKL does
    incorporate a GMP work-alike.[color=blue]
    >
    > Moreover, are there popular quadruple precision packages? Please recommend
    > the fastest one. I am really in huge need of speed.
    >[/color]
    As already stated, GMP and compatible packages seem to be the closest
    match to your ideas in terms of add-on libraries. Of course, they
    present a significant performance and coding difficulty penalty,
    compared to native hardware supported floating point.

    Your questions aren't precise enough to admit of meaningful answers.
    There is plenty of preliminary research you could do quickly to improve
    on this.

  7. Default Re: Is Fortran faster than C?


    "Tim Prince" <timothyprince@sbcglobal.net> wrote in message
    news:NwEii.20482$RX.11048@newssvr11.news.prodigy.net...[color=blue]
    > Vista wrote:[color=green]
    >>
    >> I guess Intel Visual Fortran or other Fortran has natural support for the
    >> quadruple precision.[/color]
    >
    > Intel (and a few other brands) of Fortran support quad without additional
    > add-ons, as a standard Fortran data type, even on platforms where it is
    > not a hardware supported data type. On a few platforms, such as Itanium
    > and Power, there is sufficient hardware support for quad precision that it
    > can be carried out in less than 3 times the time required for double, for
    > applications which don't spend much time on divide or transcendentals. On
    > Itanium, this is done under reasonable compliance with IEEE standard for
    > IEEE 128-bit floating point. On more popular platforms like x86-64, the
    > loss of opportunity for vectorization makes the penalty for quad precision
    > more like an order of magnitude. It is still possible to show reasonable
    > compliance with IEEE standard.[/color]

    Why loss of vectorization?

    How about X86-32 Intel CPU, which is in my laptop?
    [color=blue][color=green]
    >>
    >> 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.
    >>[/color]
    >
    > When you use software floating point, in principle, any differences among
    > languages become less important, compared to the quality of the floating
    > point emulation. While some C/C++ compilers include some hidden support
    > for quad precision, I don't know of any where it's a vendor supported data
    > type. So it will be difficult to make a meaningful comparison such as you
    > request.[/color]

    I would imagine a 3rd-party quad library in C/C++ be slower than a native
    Fortran code?
    [color=blue][color=green]
    >>
    >> I have some computation and simulation which need quadruple precision. I
    >> mean, the double precision is not enough, while high precision such as
    >> 1000
    >> digits is not needed, and that's too slow. I guess quadruple precision
    >> exactly fits my problem and should be much faster than double precision.[/color]
    > It's difficult to guess what you are getting at here. Certainly, if the
    > quad precision of several Fortran compilers satisfies your needs, it
    > should be more convenient and possibly more efficient than multiple
    > precision libraries such as GMP, particularly if you are restricting your
    > usage to Windows.[/color]

    GMP and MPFR can also be compiled under Windows XP.

    I have an implementation using MPFR.

    But it is just slow.

    I want to turn to quad precision.

    I would guess setting "number-of-precision-digits" to be 50 digits in MPFR
    will still be slower than using "quad" data type. Since MPFR's
    implementation is mainly for high precision support and it is a complete
    different structure....

    [color=blue][color=green]
    >>
    >> Could anybody tell me if MS Visual C++, or Intel C, Intel Fortran have
    >> already got quadruple precision in them and they are fully supported on
    >> Intel based cpus? I guess Intel Fortran has quadruple precision, but
    >> since I
    >> prefer C/C++ so my first choices are within C/C++ languages.
    >>
    >> Moreover, do GSL, Intel MKL, and IMSL etc. have got quadruple precision
    >> support? I only need +, -, *, /, exp, and log.[/color]
    > Up to now, I thought you were thinking along the lines of GMP. MKL does
    > incorporate a GMP work-alike.[color=green]
    >>
    >> Moreover, are there popular quadruple precision packages? Please
    >> recommend
    >> the fastest one. I am really in huge need of speed.
    >>[/color]
    > As already stated, GMP and compatible packages seem to be the closest
    > match to your ideas in terms of add-on libraries. Of course, they present
    > a significant performance and coding difficulty penalty, compared to
    > native hardware supported floating point.
    >
    > Your questions aren't precise enough to admit of meaningful answers. There
    > is plenty of preliminary research you could do quickly to improve on this.[/color]

    Could you specify what shall I add to make the questions more precise?

    Thanks!



  8. Default Re: Is Fortran faster than C?


    <tholen@antispam.ham> wrote in message
    news:468b12fc$0$30605$4c368faf@roadrunner.com...[color=blue]
    > Vista writes:
    >[color=green][color=darkred]
    >>>> I guess Intel Visual Fortran or other Fortran has natural support for
    >>>> the
    >>>> quadruple precision.[/color][/color]
    >[color=green][color=darkred]
    >>> What do you mean by "natural" support? My concept involves having a
    >>> 128-bit floating point unit and a compiler that can use it. When the
    >>> requested precision exceeds the capabilities of the hardware, it needs
    >>> to be emulated in software, which can be extremely slow.[/color][/color]
    >[color=green]
    >> But is there a 128-bit floating point unit in Intel CPU and supported by
    >> the
    >> compiler?[/color]
    >
    > Not to my knowledge. The 32-bit Intel processors have had an 80-bit
    > floating point unit for quite a few years now. I'm not aware of any
    > expansion in the FPU with the newer 64-bit processors.
    >[color=green]
    >> And how slow is the software emulation?[/color]
    >
    > Many times slower than hardware. Can you remember back to the 80386 days
    > without a 80387 FPU, or even the 8086 days without an 8087 FPU?
    >[color=green]
    >> I would imagine that the "double double" (quad) will be still much faster
    >> than multiple/high precision package...[/color]
    >
    > That's not obvious. Extended precision software packages simply do it
    > in software, just like quad precision.
    >[/color]

    Yes, but perhaps with different data structure. I remember multiple
    precision packages reprement numbers using array of digits, while "quad"
    should represent numbers smarter?

    Thanks!



  9. Default Re: Is Fortran faster than C?


    "Vista" <abc@gmai.com> wrote in message
    news:f6ev6r$4b8$1@news.Stanford.EDU...[color=blue]
    > Hi all,
    >
    > Please, allow me to ask this naive question...
    >[/color]

    It's not the language, it's the compiler.


    [color=blue]
    > 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!
    >
    > -------------------------------
    > Seeking the fastest numerical library for quadruple precision in
    > C/C++/Fortran
    > Hi all,
    >
    > I have some computation and simulation which need quadruple precision. I
    > mean, the double precision is not enough, while high precision such as
    > 1000
    > digits is not needed, and that's too slow. I guess quadruple precision
    > exactly fits my problem and should be much faster than double precision.
    >
    > Could anybody tell me if MS Visual C++, or Intel C, Intel Fortran have
    > already got quadruple precision in them and they are fully supported on
    > Intel based cpus? I guess Intel Fortran has quadruple precision, but since
    > I
    > prefer C/C++ so my first choices are within C/C++ languages.
    >
    > Moreover, do GSL, Intel MKL, and IMSL etc. have got quadruple precision
    > support? I only need +, -, *, /, exp, and log.
    >
    > I eventually have to do everything in C/C++ so I am primarily looking for
    > numerical libraries, instead of Matlab or Maple or Mathematica's symbolic
    > capability.
    >
    > But if you know how to "simulate" quadruple precision in Matlab or Maple,
    > or
    > Mathematica, in order to see if an algorithm will overslow when converting
    > into C/C++/Fortran, please let me know. I want to do the algorithm design
    > in
    > Matlab, and test if it will overflow, before converting everything into
    > C/C++/Fortran.
    >
    > If you know how to "simulate" quadruple precision in Matlab, Maple or
    > Mathematica even with the symbolic toolbox, please let me know too... this
    > is for algorithm design and testing...
    >
    > Moreover, are there popular quadruple precision packages? Please recommend
    > the fastest one. I am really in huge need of speed.
    >
    > Thank you very much!
    > ------------------------------------------------
    >
    >[/color]



  10. Default Re: Is Fortran faster than C?

    Richard Maine wrote:[color=blue]
    > Vista <abc@gmai.com> wrote:[/color]
    [color=blue][color=green]
    >>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.[/color][/color]
    (snip)
    [color=blue]
    > The variation from one compiler to another, one application to another,
    > and a whole lot of other factors will dwarf any generic language
    > difference.[/color]

    I was about to write something similar. Actually, though, it should
    probably be compiler and processor, and the specific program.

    I was just yesterday reading in "Computer Architecture: A Quantitative
    Approach" by Hennessy and Patterson, 3rd edition, a comparison between
    Itanium, Alpha 21264, and Pentium 4 on Spec2000 benchmarks.

    One example is the SPECfp2000 for the above processors, where Itanium
    is 1.08 times faster than Pentium 4. (Sounds good.) It turns out
    that Itanium is 4x faster one one SPEC program, and pretty close
    on the rest, most a little slower, some a lot slower. SPEC uses
    geometric mean (the only one that makes sense on ratios).

    With different programs varying by a factor of about eight
    between two processors (some are Fortran, some C) it doesn't
    make much sense to worry about a few percent between languages.

    To continue, Itanium is about 60% of Pentium 4 for SPECint2000.

    I would recommend the Hennessy and Patterson books to anyone
    interested in processor design, including interest in speed.

    -- glen


+ Reply to Thread
Page 1 of 19 1 2 3 11 ... LastLast

Similar Threads

  1. Replies: 12
    Last Post: 08-02-2007, 07:36 AM
  2. Replies: 1
    Last Post: 07-07-2007, 06:45 AM
  3. how to run Fortran codes in Compaq Visual Fortran?
    By Application Development in forum Fortran
    Replies: 0
    Last Post: 06-08-2007, 12:45 PM
  4. Installing Fortran 95 (The Fortran Company)
    By Application Development in forum Fortran
    Replies: 0
    Last Post: 04-08-2007, 10:36 PM
  5. Re: Is C faster than fortran?
    By Application Development in forum Fortran
    Replies: 0
    Last Post: 03-27-2007, 03:46 PM