comp.lang.ada
 help / color / mirror / Atom feed
* Re: fast computing with GNAT (?)
  2000-04-07  0:00   ` Andreas Schulz
@ 2000-04-07  0:00     ` Gisle S�lensminde
  0 siblings, 0 replies; 5+ messages in thread
From: Gisle S�lensminde @ 2000-04-07  0:00 UTC (permalink / raw)


In article <38EDAEC0.412E6CC7@nord-com.net>, Andreas Schulz wrote:
>Gautier responded to :
>> > The f77 version takes about 7.5 s and the Ada version takes
>> > about 38 s on my Linux/laptop.
>> > The actual build commands are:
>> > gnatmake -O4 test1.adb
>> Ok. Try gnatmake -O4 -ffast-math -gnatp test1.adb
>
>Maybe you'll be better off with -O3 ?? According to the manual,
>gnat accepts only 0..3 for -O, and I had the impression that
>4+ is read as 0.

Then you got the wrong impression. Anything higher than the highest
optimization level (-O3 for gnat) is read as the highest. Some
C programs around use -O99 to allways get the highest level of
optimization. 

The pentiumGCC project, which is an alternative experimental backend for
gcc, uses -O6 as highest level of optimization.

>
>> The -gnatp is essential (=pragma suppress(all_checks))
>> to compare with Fortran!
>
>Andreas


-- 
--
Gisle S�lensminde ( gisle@ii.uib.no )   

ln -s /dev/null ~/.netscape/cookies




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

* Re: fast computing with GNAT (?)
  2000-04-07  0:00 fast computing with GNAT (?) Reinert Korsnes
@ 2000-04-07  0:00 ` Gautier
  2000-04-07  0:00   ` Andreas Schulz
  2000-04-07  0:00 ` Robert Dewar
  1 sibling, 1 reply; 5+ messages in thread
From: Gautier @ 2000-04-07  0:00 UTC (permalink / raw)


Reinert Korsnes wrote:

> The f77 version takes about 7.5 s and the Ada version takes
> about 38 s on my Linux/laptop.
> 
> The actual build commands are:
> 
> f77 -c -O4 -ffast-math -malign-double test1.f
> 
> and
> 
> gnatmake -O4 test1.adb

Ok. Try gnatmake -O4 -ffast-math -gnatp test1.adb

The -gnatp is essential (=pragma suppress(all_checks))
to compare with Fortran!

In addition there are -funroll-loops, -fomit-frame-pointer,
etc. etc. to boost both G77 and GNAT. Maybe a -mpentium
is needed (otherwise GCC will think this is a 386!).

HTH
______________________________________________________
Gautier  --  http://members.xoom.com/gdemont/gsoft.htm




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

* Re: fast computing with GNAT (?)
  2000-04-07  0:00 fast computing with GNAT (?) Reinert Korsnes
  2000-04-07  0:00 ` Gautier
@ 2000-04-07  0:00 ` Robert Dewar
  1 sibling, 0 replies; 5+ messages in thread
From: Robert Dewar @ 2000-04-07  0:00 UTC (permalink / raw)


In article <8ck2ur$sgu$1@news.uit.no>,
  Reinert.Korsnes@npolar.no wrote:
> Hi,
>
> I am comparing GNAT and g77 on linux (RedHat 6.1).
>
> Is it possible to use GNAT in "fast-math mode" similar
> to using g77 like this:
>
> g77 -c -O -ffast-math -malign-double test1.f

A difference like this can be the result of many things, so
careful analysis is needed.

-malign-double can make a huge difference, but is gcc only,
since it violates the standard ABI rules.

Checks can often make a difference

-O4 is too high, we usually find that -O2 is fastest

The trig functions definitely do more in Ada than in Fortran
in terms of error checking and required accuracy. Try simply
importing the Fortran routines if you are satisfied with the
accuracy and lack of error checking in these routines.


Sent via Deja.com http://www.deja.com/
Before you buy.




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

* fast computing with GNAT (?)
@ 2000-04-07  0:00 Reinert Korsnes
  2000-04-07  0:00 ` Gautier
  2000-04-07  0:00 ` Robert Dewar
  0 siblings, 2 replies; 5+ messages in thread
From: Reinert Korsnes @ 2000-04-07  0:00 UTC (permalink / raw)


Hi,

I am comparing GNAT and g77 on linux (RedHat 6.1).

Is it possible to use GNAT in "fast-math mode" similar 
to using g77 like this:

g77 -c -O -ffast-math -malign-double test1.f 

?


I am comparing this f77 program:
------------------------------------------
      program test1
c
      integer i
      double precision x
c     real x
      x = 10.
      n = 50000

      do 10 i = 1,10000000,1
          x = x + real(i)/1000000
          x = x*0.5 + 1 + sin(x)*cos(x) + sin(x) + cos(x) +
     -                    sin(x)*sin(x) + cos(x)*cos(x)
          if(i/n*n.eq.i) print *,i,x
 10   continue

      end
----------------------------------------------
with the following Ada program:


....................................................
with Ada.Numerics.Generic_Elementary_Functions;
with Ada.Numerics; use Ada.Numerics;
With Gnat.IO; use Gnat.IO;
with Text_IO;
procedure test1 is
   package Flt_Io is new Text_IO.Float_Io (Float);
   package E_F is new
                  Ada.Numerics.Generic_Elementary_Functions (Float);
   use E_F;
   use Flt_Io;
   n : Integer;
   x : Standard.Float;
   begin
     x := 10.0;
     n := 50000;
       for I in 1 .. 10000000 loop
          x := x + Float(I)/1000000.0;
          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 n = 0 then
             put(I); Put (x);
             New_Line (1);
          end if;
   end loop;
end;
.......................................................

The f77 version takes about 7.5 s and the Ada version takes
about 38 s on my Linux/laptop.

The actual build commands are:

f77 -c -O4 -ffast-math -malign-double test1.f

and

gnatmake -O4 test1.adb


reinert

-- 
Norwegian Polar Institute
Polar Environment Center
N-9296 Tromso
Norway
Fax: +47 77750501

http://geophys.npolar.no/~reinert/personal.html




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

* Re: fast computing with GNAT (?)
  2000-04-07  0:00 ` Gautier
@ 2000-04-07  0:00   ` Andreas Schulz
  2000-04-07  0:00     ` Gisle S�lensminde
  0 siblings, 1 reply; 5+ messages in thread
From: Andreas Schulz @ 2000-04-07  0:00 UTC (permalink / raw)


Gautier responded to :
> > The f77 version takes about 7.5 s and the Ada version takes
> > about 38 s on my Linux/laptop.
> > The actual build commands are:
> > gnatmake -O4 test1.adb
> Ok. Try gnatmake -O4 -ffast-math -gnatp test1.adb

Maybe you'll be better off with -O3 ?? According to the manual,
gnat accepts only 0..3 for -O, and I had the impression that
4+ is read as 0.

> The -gnatp is essential (=pragma suppress(all_checks))
> to compare with Fortran!

Andreas




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

end of thread, other threads:[~2000-04-07  0:00 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-04-07  0:00 fast computing with GNAT (?) Reinert Korsnes
2000-04-07  0:00 ` Gautier
2000-04-07  0:00   ` Andreas Schulz
2000-04-07  0:00     ` Gisle S�lensminde
2000-04-07  0:00 ` Robert Dewar

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