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.9 required=5.0 tests=BAYES_00,FORGED_GMAIL_RCVD, FREEMAIL_FROM autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,5395b8f41548bf11 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!postnews.google.com!dq9g2000vbb.googlegroups.com!not-for-mail From: David Sauvage Newsgroups: comp.lang.ada Subject: Re: Interfacing Ada multidimensional arrays with Fortran. Date: Thu, 9 Jun 2011 00:55:02 -0700 (PDT) Organization: http://groups.google.com Message-ID: <9fd67d68-191b-4c05-a144-3d2c02e92d2c@dq9g2000vbb.googlegroups.com> References: <27d4e9af-ffd0-4c12-80ed-b51deea95506@q32g2000yqn.googlegroups.com> NNTP-Posting-Host: 197.224.110.104 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Trace: posting.google.com 1307606102 23937 127.0.0.1 (9 Jun 2011 07:55:02 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 9 Jun 2011 07:55:02 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: dq9g2000vbb.googlegroups.com; posting-host=197.224.110.104; posting-account=VT4k8QoAAAB0zUvVwUYyaKE5TB63pAuh User-Agent: G2/1.0 X-Google-Web-Client: true X-Google-Header-Order: HUALESNKRC X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux i686; fr; rv:1.9.2.15) Gecko/20110303 Ubuntu/9.10 (karmic) Firefox/3.6.15,gzip(gfe) Xref: g2news1.google.com comp.lang.ada:19713 Date: 2011-06-09T00:55:02-07:00 List-Id: On May 28, 8:45=A0pm, Simon Wright wrote: ... > -O1: > Transposition: 1200 us > Assignment: =A0 =A0 300 us > > -O2: > Transposition: =A0500 us > Assignment: =A0 =A0 300 us Using this testcase [1], here are my results using Intel Atom CPU N270 @ 1.60GHz / Linux (launched with root privilege) : -O1: Transposition: 2202 us Assignment: 1014 us -O2: Transposition: 2556 us Assignment: 885 us Transposition (using assignment via pragma Convention) seems to be quicker than Transposition (without pragma Convention). The reason why pragma Convention (Fortran, Type) is not used in Interfaces.Fortran... is unknown and seems to give slower compute time. [1] -- gnatmake -f compare.adb -cargs -gnat05 -O2 -- gnatmake -f compare.adb -cargs -gnat05 -O1 with Interfaces.Fortran.BLAS; with Ada.Text_IO, Ada.Calendar, Ada.Numerics.Generic_Real_Arrays; procedure Compare is Start, Stop : Ada.Calendar.Time; use type Ada.Calendar.Time; type Real_Matrix is array (Integer range <>, Integer range <>) of Interfaces.Fortran.Real; pragma Convention (Fortran, Real_Matrix); package GRA is new Ada.Numerics.Generic_Real_Arrays ( Interfaces.Fortran.Real); Row, Column : constant Positive :=3D 100; Iteration : constant Positive :=3D 10; M : Real_Matrix (1 .. Row, 1 .. Column) :=3D (others =3D> (others =3D> 2.0)); pragma Volatile (M); MFA, MFB : GRA.Real_Matrix (1 .. Row, 1 .. Column) :=3D (others =3D> (others =3D> 2.0)); pragma Volatile (MFA); pragma Volatile (MFB); use type Interfaces.Fortran.Real; begin Start :=3D Ada.Calendar.Clock; for I in 1 .. Iteration loop M :=3D Real_Matrix (MFB); end loop; Stop :=3D Ada.Calendar.Clock; Ada.Text_IO.Put_Line ("Assignation (Transposition via pragma Convention)" & Duration'Image (Stop - Start)); Start :=3D Ada.Calendar.Clock; for I in 1 .. Iteration loop MFA :=3D GRA.Transpose (MFB); end loop; Stop :=3D Ada.Calendar.Clock; Ada.Text_IO.Put_Line ("Transposition" & Duration'Image (Stop - Start)); end Compare;