comp.lang.ada
 help / color / mirror / Atom feed
From: Reinert Korsnes <reinert.korsnes@chello.no>
Subject: comparing gnat/Ada95 and g77
Date: Thu, 14 Mar 2002 10:47:18 +0100
Date: 2002-03-14T10:47:18+01:00	[thread overview]
Message-ID: <a6prk9$jhc$1@snipp.uninett.no> (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
------------------------------------------------------------------------------



             reply	other threads:[~2002-03-14  9:47 UTC|newest]

Thread overview: 21+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-03-14  9:47 Reinert Korsnes [this message]
2002-03-14 10:37 ` comparing gnat/Ada95 and g77 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
replies disabled

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