From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=0.2 required=5.0 tests=BAYES_00,INVALID_MSGID, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,93d51dcc531df27a,start X-Google-Attributes: gid103376,public From: reinert@ola.npolar.no (Reinert Korsnes) Subject: fast computing with GNAT (?) Date: 2000/04/07 Message-ID: <8ck2ur$sgu$1@news.uit.no>#1/1 X-Deja-AN: 607902272 X-Complaints-To: usenet@news.uit.no X-Trace: news.uit.no 955092763 29214 158.39.64.31 (7 Apr 2000 07:32:43 GMT) Organization: University of Troms� Reply-To: Reinert.Korsnes@npolar.no NNTP-Posting-Date: 7 Apr 2000 07:32:43 GMT Newsgroups: comp.lang.ada Date: 2000-04-07T07:32:43+00:00 List-Id: 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