From: David Sauvage <sauvage.david@gmail.com>
Subject: Re: Interfacing Ada multidimensional arrays with Fortran.
Date: Thu, 9 Jun 2011 00:55:02 -0700 (PDT)
Date: 2011-06-09T00:55:02-07:00 [thread overview]
Message-ID: <9fd67d68-191b-4c05-a144-3d2c02e92d2c@dq9g2000vbb.googlegroups.com> (raw)
In-Reply-To: m2pqn26aew.fsf@pushface.org
On May 28, 8:45 pm, Simon Wright <si...@pushface.org> wrote:
...
> -O1:
> Transposition: 1200 us
> Assignment: 300 us
>
> -O2:
> Transposition: 500 us
> Assignment: 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 := 100;
Iteration : constant Positive := 10;
M : Real_Matrix (1 .. Row, 1 .. Column) := (others => (others
=> 2.0));
pragma Volatile (M);
MFA, MFB : GRA.Real_Matrix (1 .. Row, 1 .. Column) := (others =>
(others => 2.0));
pragma Volatile (MFA);
pragma Volatile (MFB);
use type Interfaces.Fortran.Real;
begin
Start := Ada.Calendar.Clock;
for I in 1 .. Iteration loop
M := Real_Matrix (MFB);
end loop;
Stop := Ada.Calendar.Clock;
Ada.Text_IO.Put_Line
("Assignation (Transposition via pragma Convention)" &
Duration'Image (Stop - Start));
Start := Ada.Calendar.Clock;
for I in 1 .. Iteration loop
MFA := GRA.Transpose (MFB);
end loop;
Stop := Ada.Calendar.Clock;
Ada.Text_IO.Put_Line
("Transposition" & Duration'Image (Stop - Start));
end Compare;
prev parent reply other threads:[~2011-06-09 7:55 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-05-27 20:50 Interfacing Ada multidimensional arrays with Fortran David Sauvage
2011-05-28 9:41 ` Simon Wright
2011-05-28 16:45 ` Simon Wright
2011-06-09 7:55 ` David Sauvage [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox