comp.lang.ada
 help / color / mirror / Atom feed
* comparing gnat/Ada95 and g77
@ 2002-03-14  9:47 Reinert Korsnes
  2002-03-14 10:37 ` John McCabe
                   ` (3 more replies)
  0 siblings, 4 replies; 21+ messages in thread
From: Reinert Korsnes @ 2002-03-14  9:47 UTC (permalink / raw)


Hi,

Could anybody try these two programs (Ada and Fortran)
and see if it is possible to make the Ada version (via compile 
options) to run as fast as the Fortran version under Linux, gnat
and g77 ?

reinert

--------------------------------------------------------------------
with Ada.Numerics.Generic_Elementary_Functions,Text_IO;
use Text_IO;
procedure test1 is
   type Real is Digits 9;
   package Flt_Io is new Text_IO.Float_Io   (Real);
   package Int_Io is new Text_IO.Integer_Io (Integer);
   package E_F is new Ada.Numerics.Generic_Elementary_Functions (Real);

   use E_F,Flt_Io,Int_Io;

   N : Integer := 10_000_000;
   M : Integer := N/50;
   x : Real := 10.0;
   begin
     for I in 1 .. N loop
         x := x + Real(I)/Real(N);
         x := x*0.5 + 1.0 + sin(x)*cos(x) + sin(x) + cos(x) +
                            sin(x)*sin(x) + cos(x)*cos(x);
         if I mod M = 0 then
            Put(I);  Put (x,4,7,0); New_Line (1);
         end if;
     end loop;
end;
------------------------------------------------------------------------

      program test1
c
      integer i
      real x
c     double precision x

      N = 10000000
      M = N/50
      x = 10.0

      do 10 i = 1,N,1
          x = x + real(i)/N
          x = x*0.5 + 1.0 + sin(x)*cos(x) + sin(x) + cos(x) +
     -                      sin(x)*sin(x) + cos(x)*cos(x)
          if(mod(i,M).eq.0) print *,i,x
 10   continue

      end
------------------------------------------------------------------------------



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14  9:47 comparing gnat/Ada95 and g77 Reinert Korsnes
@ 2002-03-14 10:37 ` John McCabe
  2002-03-14 11:00   ` Preben Randhol
  2002-03-15 10:44   ` Reinert Korsnes
  2002-03-14 10:58 ` Martin Dowie
                   ` (2 subsequent siblings)
  3 siblings, 2 replies; 21+ messages in thread
From: John McCabe @ 2002-03-14 10:37 UTC (permalink / raw)


On Thu, 14 Mar 2002 10:47:18 +0100, Reinert Korsnes
<reinert.korsnes@chello.no> wrote:

>Hi,
>
>Could anybody try these two programs (Ada and Fortran)
>and see if it is possible to make the Ada version (via compile 
>options) to run as fast as the Fortran version under Linux, gnat
>and g77 ?

What do you mean by "as fast as"? Do you have some figures already?
What are the differences?

I can't see any reason (other than constraint checking which can be
switched off) why the actual calculations should be any different, but
you might find that the IO takes longer in Ada than in Fortran because
it is obviously a bit more complicated (3 subroutine calls instead of
1) and, as you're doing this within a *huge* loop, any slight
degradation here will be significant.





^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14  9:47 comparing gnat/Ada95 and g77 Reinert Korsnes
  2002-03-14 10:37 ` John McCabe
@ 2002-03-14 10:58 ` Martin Dowie
  2002-03-14 11:04   ` chris.danx
  2002-03-14 11:06   ` Preben Randhol
  2002-03-14 11:14 ` Gerald Kasner
  2002-03-14 16:40 ` Jeffrey Carter
  3 siblings, 2 replies; 21+ messages in thread
From: Martin Dowie @ 2002-03-14 10:58 UTC (permalink / raw)


>          x := x*0.5 + 1.0 + sin(x)*cos(x) + sin(x) + cos(x) +
>                             sin(x)*sin(x) + cos(x)*cos(x);

Try changing this line to:

         Sin_X := Sin(X);
         Cos_X := Cos(X);
         X := X*0.5 + 1.0 + Sin_X*Cos_X + Sin_X + Cos_X +
            Sin_X*Sin_X + Cos_X*Cos_X;






^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 10:37 ` John McCabe
@ 2002-03-14 11:00   ` Preben Randhol
  2002-03-15 10:44   ` Reinert Korsnes
  1 sibling, 0 replies; 21+ messages in thread
From: Preben Randhol @ 2002-03-14 11:00 UTC (permalink / raw)


On Thu, 14 Mar 2002 10:37:59 GMT, John McCabe wrote:
> On Thu, 14 Mar 2002 10:47:18 +0100, Reinert Korsnes
><reinert.korsnes@chello.no> wrote:
> 
>>Hi,
>>
>>Could anybody try these two programs (Ada and Fortran)
>>and see if it is possible to make the Ada version (via compile 
>>options) to run as fast as the Fortran version under Linux, gnat
>>and g77 ?
> 
> What do you mean by "as fast as"? Do you have some figures already?
> What are the differences?

About 3 seconds, 20s (Ada) versus 17s (F77), with -O3 on both. Using
-gnatp didn't speed things up much. But note that one should wait for
GNAT 5.0 as the gcc backend is of different version (gnat uses gcc 2.8.1
while g77 uses 2.95.4).

-- 
Preben Randhol         �For me, Ada95 puts back the joy in programming.�



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 10:58 ` Martin Dowie
@ 2002-03-14 11:04   ` chris.danx
  2002-03-14 11:07     ` Bobby D. Bryant
  2002-03-14 11:41     ` David C. Hoos, Sr.
  2002-03-14 11:06   ` Preben Randhol
  1 sibling, 2 replies; 21+ messages in thread
From: chris.danx @ 2002-03-14 11:04 UTC (permalink / raw)



"Martin Dowie" <martin.dowie@nospam.baesystems.com> wrote in message
news:3c9081f5$1@pull.gecm.com...
> >          x := x*0.5 + 1.0 + sin(x)*cos(x) + sin(x) + cos(x) +
> >                             sin(x)*sin(x) + cos(x)*cos(x);
>
> Try changing this line to:
>
>          Sin_X := Sin(X);
>          Cos_X := Cos(X);
>          X := X*0.5 + 1.0 + Sin_X*Cos_X + Sin_X + Cos_X +
>             Sin_X*Sin_X + Cos_X*Cos_X;

what is the point of calculating sin(x)*sin(x) + cos(x)*cos(x)?  It is equal
to (sin(x))^2 + (cos(x)^2) which is always 1.0 so you can do

x := x * 0.5 + 1.0 + sin_x*cos_x + sin_x + cos_x + 1.0;

and that'll be even faster.






^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 10:58 ` Martin Dowie
  2002-03-14 11:04   ` chris.danx
@ 2002-03-14 11:06   ` Preben Randhol
  2002-03-14 16:43     ` Jeffrey Carter
  1 sibling, 1 reply; 21+ messages in thread
From: Preben Randhol @ 2002-03-14 11:06 UTC (permalink / raw)


On Thu, 14 Mar 2002 10:58:06 -0000, Martin Dowie wrote:
>>          x := x*0.5 + 1.0 + sin(x)*cos(x) + sin(x) + cos(x) +
>>                             sin(x)*sin(x) + cos(x)*cos(x);
> 
> Try changing this line to:
> 
>          Sin_X := Sin(X);
>          Cos_X := Cos(X);
>          X := X*0.5 + 1.0 + Sin_X*Cos_X + Sin_X + Cos_X +
>             Sin_X*Sin_X + Cos_X*Cos_X;

After removing the IO things from the program the exection time when 
from approx 19s to approx 5s.

The fortran went from approx 15s to approx 4s.

(note the gcc backends are different)

-- 
Preben Randhol         �For me, Ada95 puts back the joy in programming.�



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 11:04   ` chris.danx
@ 2002-03-14 11:07     ` Bobby D. Bryant
  2002-03-14 11:41     ` David C. Hoos, Sr.
  1 sibling, 0 replies; 21+ messages in thread
From: Bobby D. Bryant @ 2002-03-14 11:07 UTC (permalink / raw)


On Thu, 14 Mar 2002 05:04:51 -0600, chris.danx wrote:

> "Martin Dowie" <martin.dowie@nospam.baesystems.com> wrote in message
> news:3c9081f5$1@pull.gecm.com...
>> >          x := x*0.5 + 1.0 + sin(x)*cos(x) + sin(x) + cos(x) +
>> >                             sin(x)*sin(x) + cos(x)*cos(x);
>>
>> Try changing this line to:
>>
>>          Sin_X := Sin(X);
>>          Cos_X := Cos(X);
>>          X := X*0.5 + 1.0 + Sin_X*Cos_X + Sin_X + Cos_X +
>>             Sin_X*Sin_X + Cos_X*Cos_X;
> 
> what is the point of calculating sin(x)*sin(x) + cos(x)*cos(x)?  It is
> equal to (sin(x))^2 + (cos(x)^2) which is always 1.0 so you can do
> 
> x := x * 0.5 + 1.0 + sin_x*cos_x + sin_x + cos_x + 1.0;
> 
> and that'll be even faster.

Since the program doesn't take any inputs, the programmer concerned with
"fast" should just pre-calculate the answers and have the program spit
them out whole.

Or dispense with the program altogether, and just offer a text file with
the answers in it.

Bobby Bryant
Austin, Texas



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14  9:47 comparing gnat/Ada95 and g77 Reinert Korsnes
  2002-03-14 10:37 ` John McCabe
  2002-03-14 10:58 ` Martin Dowie
@ 2002-03-14 11:14 ` Gerald Kasner
  2002-03-14 12:59   ` Gary Scott
  2002-03-14 17:31   ` Toshitaka Kumano
  2002-03-14 16:40 ` Jeffrey Carter
  3 siblings, 2 replies; 21+ messages in thread
From: Gerald Kasner @ 2002-03-14 11:14 UTC (permalink / raw)


Reinert Korsnes schrieb:
> 
> Hi,
> 
> Could anybody try these two programs (Ada and Fortran)
> and see if it is possible to make the Ada version (via compile
> options) to run as fast as the Fortran version under Linux, gnat
> and g77 ?
> 
> reinert
> 
> --------------------------------------------------------------------
> with Ada.Numerics.Generic_Elementary_Functions,Text_IO;
> use Text_IO;
> procedure test1 is
>    type Real is Digits 9;
>    package Flt_Io is new Text_IO.Float_Io   (Real);
>    package Int_Io is new Text_IO.Integer_Io (Integer);
>    package E_F is new Ada.Numerics.Generic_Elementary_Functions (Real);
> 
>    use E_F,Flt_Io,Int_Io;
> 
>    N : Integer := 10_000_000;
>    M : Integer := N/50;
>    x : Real := 10.0;
>    begin
>      for I in 1 .. N loop
>          x := x + Real(I)/Real(N);
>          x := x*0.5 + 1.0 + sin(x)*cos(x) + sin(x) + cos(x) +
>                             sin(x)*sin(x) + cos(x)*cos(x);
>          if I mod M = 0 then
>             Put(I);  Put (x,4,7,0); New_Line (1);
>          end if;
>      end loop;
> end;
> ------------------------------------------------------------------------

Dear Reinert,
the difference is small on my machines

~ 28 sec for g77  (with -O3 option)
~ 32 sec for gnat (with -O3 -gnatp option)

The difference seems to be in the trigonometric functions, look 
in a-ngelfu.adb, Ada is more careful in these cases.

Rather than playing with options, it seems to be better to 
rewrite the program (as below). The program below needs 
about 11 sec, three times faster than the original one.

It's the algorithm, not the language that matters.

-Gerald
##############################################################################
with Ada.Numerics.Generic_Elementary_Functions,Text_IO;
use Text_IO;
procedure test2 is
   type Real is Digits 9;
   package Flt_Io is new Text_IO.Float_Io   (Real);
   package Int_Io is new Text_IO.Integer_Io (Integer);
   package E_F is new Ada.Numerics.Generic_Elementary_Functions (Real);

   use E_F,Flt_Io,Int_Io;

   N : Integer := 10_000_000;
   M : Integer := N/50;
   x : Real := 10.0;
   c, s : Real;
    
   begin
     for I in 1 .. N loop
         x := x + Real(I)/Real(N);
         c :=cos(x);
         s :=sin(x);
         x := x*0.5 + 1.0 + s*(c+1.0+s) +c*(1.0+c);         
         if I mod M = 0 then
            Put(I);  Put (x,4,7,0); New_Line (1);
         end if;
     end loop;
end;



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 11:04   ` chris.danx
  2002-03-14 11:07     ` Bobby D. Bryant
@ 2002-03-14 11:41     ` David C. Hoos, Sr.
  1 sibling, 0 replies; 21+ messages in thread
From: David C. Hoos, Sr. @ 2002-03-14 11:41 UTC (permalink / raw)


Or how about
 x := x * 0.5 + 2.0 + sin_x*cos_x + sin_x + cos_x;
which is faster still, unless the compiler optimizes to this
same thing.

----- Original Message -----
From: "chris.danx" <chris.danx@ntlworld.com>
Newsgroups: comp.lang.ada
To: <comp.lang.ada@ada.eu.org>
Sent: March 14, 2002 5:04 AM
Subject: Re: comparing gnat/Ada95 and g77


>
> "Martin Dowie" <martin.dowie@nospam.baesystems.com> wrote in message
> news:3c9081f5$1@pull.gecm.com...
> > >          x := x*0.5 + 1.0 + sin(x)*cos(x) + sin(x) + cos(x) +
> > >                             sin(x)*sin(x) + cos(x)*cos(x);
> >
> > Try changing this line to:
> >
> >          Sin_X := Sin(X);
> >          Cos_X := Cos(X);
> >          X := X*0.5 + 1.0 + Sin_X*Cos_X + Sin_X + Cos_X +
> >             Sin_X*Sin_X + Cos_X*Cos_X;
>
> what is the point of calculating sin(x)*sin(x) + cos(x)*cos(x)?  It is equal
> to (sin(x))^2 + (cos(x)^2) which is always 1.0 so you can do
>
> x := x * 0.5 + 1.0 + sin_x*cos_x + sin_x + cos_x + 1.0;
>
> and that'll be even faster.
>
>
>
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada
>





^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 11:14 ` Gerald Kasner
@ 2002-03-14 12:59   ` Gary Scott
  2002-03-14 13:17     ` Jean-Marc Bourguet
  2002-03-14 16:19     ` Dan Andreatta
  2002-03-14 17:31   ` Toshitaka Kumano
  1 sibling, 2 replies; 21+ messages in thread
From: Gary Scott @ 2002-03-14 12:59 UTC (permalink / raw)


Hi,
Gerald Kasner wrote:
> 
> Reinert Korsnes schrieb:
> >
> > Hi,
> <snip>
> 
> It's the algorithm, not the language that matters.

Actually, the design of the language is quite significant it terms of
how easy it makes it to design a suitable optimizer.  FORTRAN 77 should
be very easy to optimize so long as you're not using integer pointers
and/or aliasing.  Fortran 95 is only slightly less "optimizable". 
C-based languages are somewhat harder to optimize typically because they
ENCOURAGE use of pointers and various aliasing tricks.  However, some of
the difference between Fortran compilers and other languages has
something to do with the fact that there are companies with 30+ years
experience tweaking their compiler (the FORTRAN 77 ones are largely
mature, not to say that all intrinsics are optimal, I keep seeing
horrible performance with simple things like circular shift).


> 
> -Gerald

-- 

Gary Scott
mailto:scottg@flash.net

mailto:webmaster@fortranlib.com
http://www.fortranlib.com

Support the GNU Fortran G95 Project:  http://g95.sourceforge.net



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 12:59   ` Gary Scott
@ 2002-03-14 13:17     ` Jean-Marc Bourguet
  2002-03-15  0:52       ` Gary Scott
  2002-03-14 16:19     ` Dan Andreatta
  1 sibling, 1 reply; 21+ messages in thread
From: Jean-Marc Bourguet @ 2002-03-14 13:17 UTC (permalink / raw)


Gary Scott <scottg@flash.net> writes:

> Hi,
> Gerald Kasner wrote:
> > 
> > Reinert Korsnes schrieb:
> > >
> > > Hi,
> > <snip>
> > 
> > It's the algorithm, not the language that matters.
> 
> Actually, the design of the language is quite significant it terms of
> how easy it makes it to design a suitable optimizer.  FORTRAN 77 should
> be very easy to optimize so long as you're not using integer pointers
> and/or aliasing.  Fortran 95 is only slightly less "optimizable". 
> C-based languages are somewhat harder to optimize typically because they
> ENCOURAGE use of pointers and various aliasing tricks.  

That's not the case of Ada.  It is perhaps worse than Fortran, but is
far better than C and C++ on this aspect.

> However, some of the difference between Fortran compilers and other
> languages has something to do with the fact that there are companies
> with 30+ years experience tweaking their compiler (the FORTRAN 77
> ones are largely mature, not to say that all intrinsics are optimal,
> I keep seeing horrible performance with simple things like circular
> shift).

Another thing is that raw performance is an important factor in the
Fortran market. 

Yours,

-- 
Jean-Marc



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 12:59   ` Gary Scott
  2002-03-14 13:17     ` Jean-Marc Bourguet
@ 2002-03-14 16:19     ` Dan Andreatta
  2002-03-15  9:35       ` Gerald Kasner
  1 sibling, 1 reply; 21+ messages in thread
From: Dan Andreatta @ 2002-03-14 16:19 UTC (permalink / raw)


> something to do with the fact that there are companies with 30+ years
> experience tweaking their compiler (the FORTRAN 77 ones are largely
> mature, not to say that all intrinsics are optimal, I keep seeing
> horrible performance with simple things like circular shift).

Absolutely true. I tried the Compaq Visual Fortran on that piece of code 
(the original one), and the speedup is huge, 68 sec. for g77 (cygwin) 
versus 4.9 sec for CVF6. Probably CVF does all the possible semplifications 
that have been suggested in previous posts.

Dan



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14  9:47 comparing gnat/Ada95 and g77 Reinert Korsnes
                   ` (2 preceding siblings ...)
  2002-03-14 11:14 ` Gerald Kasner
@ 2002-03-14 16:40 ` Jeffrey Carter
  3 siblings, 0 replies; 21+ messages in thread
From: Jeffrey Carter @ 2002-03-14 16:40 UTC (permalink / raw)


Reinert Korsnes wrote:
> 
Ada:
>    type Real is Digits 9;

FORTRAN:
>       real x

How big is a FORTRAN real? On a typical 32-bit machine, a 1-word
(single-precision) floating-point number is "digits 6". "digits 9" would
use a 2-word (double-precision) implementation. This may bias the timing
in favor of FORTRAN.

The trig functions in Ada are pickier than those in other languages; for
a fair comparison, you have to use exactly the same functionality in
both languages.

Also, Text_IO tends to be "heavier" than the IO in other languages.

-- 
Jeffrey Carter



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 11:06   ` Preben Randhol
@ 2002-03-14 16:43     ` Jeffrey Carter
  0 siblings, 0 replies; 21+ messages in thread
From: Jeffrey Carter @ 2002-03-14 16:43 UTC (permalink / raw)


Preben Randhol wrote:
> 
> After removing the IO things from the program the exection time when
> from approx 19s to approx 5s.
> 
> The fortran went from approx 15s to approx 4s.

But if you eliminate the IO, then the following program is equivalent:

procedure Test1 is
   -- null;
begin -- Test1
   null;
end Test1;

and takes much less than 5s to execute.

-- 
Jeffrey Carter



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 11:14 ` Gerald Kasner
  2002-03-14 12:59   ` Gary Scott
@ 2002-03-14 17:31   ` Toshitaka Kumano
  1 sibling, 0 replies; 21+ messages in thread
From: Toshitaka Kumano @ 2002-03-14 17:31 UTC (permalink / raw)


Dear Reinert,

Gerald Kasner wrote:
> the difference is small on my machines
> 
> ~ 28 sec for g77  (with -O3 option)
> ~ 32 sec for gnat (with -O3 -gnatp option)
> 
> The difference seems to be in the trigonometric functions, look
> in a-ngelfu.adb, Ada is more careful in these cases.

If you seek for *performance only*, giving up the numerical accuracy
provided by Ada model, you can use the thin binding to math lib, 
Ada.Numerics.Aux.

Using this should make the difference smaller, I guess...

-- 
Toshitaka Kumano



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 13:17     ` Jean-Marc Bourguet
@ 2002-03-15  0:52       ` Gary Scott
  0 siblings, 0 replies; 21+ messages in thread
From: Gary Scott @ 2002-03-15  0:52 UTC (permalink / raw)


Hi,

Jean-Marc Bourguet wrote:
> 
> Gary Scott <scottg@flash.net> writes:
> 
> > Hi,
> > Gerald Kasner wrote:
> > >
> > > Reinert Korsnes schrieb:
> > > >
> > > > Hi,
> > > <snip>
> > >
> > > It's the algorithm, not the language that matters.
> >
> > Actually, the design of the language is quite significant it terms of
> > how easy it makes it to design a suitable optimizer.  FORTRAN 77 should
> > be very easy to optimize so long as you're not using integer pointers
> > and/or aliasing.  Fortran 95 is only slightly less "optimizable".
> > C-based languages are somewhat harder to optimize typically because they
> > ENCOURAGE use of pointers and various aliasing tricks.
> 
> That's not the case of Ada.  It is perhaps worse than Fortran, but is
> far better than C and C++ on this aspect.

That's what I would have expected.  

> 
> > However, some of the difference between Fortran compilers and other
> > languages has something to do with the fact that there are companies
> > with 30+ years experience tweaking their compiler (the FORTRAN 77
> > ones are largely mature, not to say that all intrinsics are optimal,
> > I keep seeing horrible performance with simple things like circular
> > shift).
> 
> Another thing is that raw performance is an important factor in the
> Fortran market.

True.  However, high-level "expressiveness" is dramtically improved by
Fortran 95 and I think that many OO buffs will very much like the
improvements in the upcoming standard.  Still, we just can't seem to get
a proper bit string/array type into the standard (or unsigned integers,
or ...).  If it can't be defined in a 100% portable way, it seems that
it won't be considered either.  Ada (and PL/1) will probably always be
ahead in terms of "features" (simply syntactic sugar in some
cases)...unless Ada stops being developed.  I doubt whether Fortran will
ever incorporate OS dependent features like
multi-tasking/threading/processes.  It is increasingly supporting
parallel processing constructs, though.

> 
> Yours,
> 
> --
> Jean-Marc


-- 

Gary Scott
mailto:scottg@flash.net

mailto:webmaster@fortranlib.com
http://www.fortranlib.com

Support the GNU Fortran G95 Project:  http://g95.sourceforge.net



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 16:19     ` Dan Andreatta
@ 2002-03-15  9:35       ` Gerald Kasner
  0 siblings, 0 replies; 21+ messages in thread
From: Gerald Kasner @ 2002-03-15  9:35 UTC (permalink / raw)



> Absolutely true. I tried the Compaq Visual Fortran on that piece of code
> (the original one), and the speedup is huge, 68 sec. for g77 (cygwin)
> versus 4.9 sec for CVF6. Probably CVF does all the possible semplifications
> that have been suggested in previous posts.
> 
> Dan

My Fortran exeriences date back 10 years or so, but these days there 
was a Fortran preprocessor for the RS6000, an incredible thing. Together 
with XLF there were giant speedups. For pure number crunching a fine
thing. 

But, to all our luck, life is more than number crunching, and the last
compiler 
I used before that machine died was Powerada from OCSystems ;-)

Gerald



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-14 10:37 ` John McCabe
  2002-03-14 11:00   ` Preben Randhol
@ 2002-03-15 10:44   ` Reinert Korsnes
  2002-03-15 12:14     ` John McCabe
  2002-03-16 14:00     ` Gautier
  1 sibling, 2 replies; 21+ messages in thread
From: Reinert Korsnes @ 2002-03-15 10:44 UTC (permalink / raw)


Thanks all for response.

For the Ada95 program I used:

 gnatmake test1.adb -cargs -O3 -ffast-math 

and for the Fortran version I used:

  f77 -c -O3 -ffast-math test1.f (and f77 -o test1 test1.o)

Ada:    11.8 s

Fortran: 2.7 s

Maybe "-ffast-math" is silently ignored (not "legal") for gnat 
since it is "dirty" ?  Without "-ffast-math" the Fortran 
version takes about 10.3 s .

reinert

PS: yes, I did NOT try to make a program doing anything
    meaningful except for figuring out compile options. 



John McCabe wrote:

> On Thu, 14 Mar 2002 10:47:18 +0100, Reinert Korsnes
> <reinert.korsnes@chello.no> wrote:
> 
>>Hi,
>>
>>Could anybody try these two programs (Ada and Fortran)
>>and see if it is possible to make the Ada version (via compile
>>options) to run as fast as the Fortran version under Linux, gnat
>>and g77 ?
> 
> What do you mean by "as fast as"? Do you have some figures already?
> What are the differences?
> 
> I can't see any reason (other than constraint checking which can be
> switched off) why the actual calculations should be any different, but
> you might find that the IO takes longer in Ada than in Fortran because
> it is obviously a bit more complicated (3 subroutine calls instead of
> 1) and, as you're doing this within a *huge* loop, any slight
> degradation here will be significant.




^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-15 10:44   ` Reinert Korsnes
@ 2002-03-15 12:14     ` John McCabe
  2002-03-15 17:53       ` Georg Bauhaus
  2002-03-16 14:00     ` Gautier
  1 sibling, 1 reply; 21+ messages in thread
From: John McCabe @ 2002-03-15 12:14 UTC (permalink / raw)


On Fri, 15 Mar 2002 11:44:10 +0100, Reinert Korsnes
<reinert.korsnes@chello.no> wrote:

>Thanks all for response.
>
>For the Ada95 program I used:
>
> gnatmake test1.adb -cargs -O3 -ffast-math 
>
>and for the Fortran version I used:
>
>  f77 -c -O3 -ffast-math test1.f (and f77 -o test1 test1.o)
>
>Ada:    11.8 s
>
>Fortran: 2.7 s

That seems like an incredible difference, especially as I would have
thought the IO is making up a significant part of this.



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-15 12:14     ` John McCabe
@ 2002-03-15 17:53       ` Georg Bauhaus
  0 siblings, 0 replies; 21+ messages in thread
From: Georg Bauhaus @ 2002-03-15 17:53 UTC (permalink / raw)


John McCabe <john.mccabe@emrad.ns.com> wrote:

:>Ada:    11.8 s
:>
:>Fortran: 2.7 s
: 
: That seems like an incredible difference, especially as I would have
: thought the IO is making up a significant part of this.

I've tried the fortran program with a HP f90 compiler.
The difference is quite significant depending on +O option
used. Is this some Ada persuasion game?

- georg



^ permalink raw reply	[flat|nested] 21+ messages in thread

* Re: comparing gnat/Ada95 and g77
  2002-03-15 10:44   ` Reinert Korsnes
  2002-03-15 12:14     ` John McCabe
@ 2002-03-16 14:00     ` Gautier
  1 sibling, 0 replies; 21+ messages in thread
From: Gautier @ 2002-03-16 14:00 UTC (permalink / raw)


Reinert Korsnes:

> For the Ada95 program I used:
> 
>  gnatmake test1.adb -cargs -O3 -ffast-math 

Hello!

* To compare Ada with Fortran, you should also suppress all checks,
i.e. for GNAT: -gnatp . At least with Compaq Ada where I did compare,
the Suppress_All pragma brought the perfomance near to the F77 one
(a few percents off)

* The automatic inlining is often counter-productive, so I would
use -O2 rather than -O3, but enable the cross-unit inlining,
i.e. -gnatn .

HTH
________________________________________________________
Gautier  --  http://www.mysunrise.ch/users/gdm/gsoft.htm

NB: For a direct answer, address on the Web site!



^ permalink raw reply	[flat|nested] 21+ messages in thread

end of thread, other threads:[~2002-03-16 14:00 UTC | newest]

Thread overview: 21+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2002-03-14  9:47 comparing gnat/Ada95 and g77 Reinert Korsnes
2002-03-14 10:37 ` John McCabe
2002-03-14 11:00   ` Preben Randhol
2002-03-15 10:44   ` Reinert Korsnes
2002-03-15 12:14     ` John McCabe
2002-03-15 17:53       ` Georg Bauhaus
2002-03-16 14:00     ` Gautier
2002-03-14 10:58 ` Martin Dowie
2002-03-14 11:04   ` chris.danx
2002-03-14 11:07     ` Bobby D. Bryant
2002-03-14 11:41     ` David C. Hoos, Sr.
2002-03-14 11:06   ` Preben Randhol
2002-03-14 16:43     ` Jeffrey Carter
2002-03-14 11:14 ` Gerald Kasner
2002-03-14 12:59   ` Gary Scott
2002-03-14 13:17     ` Jean-Marc Bourguet
2002-03-15  0:52       ` Gary Scott
2002-03-14 16:19     ` Dan Andreatta
2002-03-15  9:35       ` Gerald Kasner
2002-03-14 17:31   ` Toshitaka Kumano
2002-03-14 16:40 ` Jeffrey Carter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox