comp.lang.ada
 help / color / mirror / Atom feed
* 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

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