From: reinert@ola.npolar.no (Reinert Korsnes)
Subject: fast computing with GNAT (?)
Date: 2000/04/07
Date: 2000-04-07T07:32:43+00:00 [thread overview]
Message-ID: <8ck2ur$sgu$1@news.uit.no> (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
next reply other threads:[~2000-04-07 0:00 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-04-07 0:00 Reinert Korsnes [this message]
2000-04-07 0:00 ` fast computing with GNAT (?) Gautier
2000-04-07 0:00 ` Andreas Schulz
2000-04-07 0:00 ` Gisle S�lensminde
2000-04-07 0:00 ` Robert Dewar
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox