From: claude.simon@equipement.gouv.fr
Subject: Re: GNAT compiler switches and optimization
Date: 25 Oct 2006 08:32:53 -0700
Date: 2006-10-25T08:32:53-07:00 [thread overview]
Message-ID: <1161790373.277521.105970@i3g2000cwc.googlegroups.com> (raw)
In-Reply-To: <2h3314-gak.ln1@newserver.thecreems.com>
A way to have better performance is to optimize the use of the memory
cache.
An Ada writen matmul procedure to tend to the fortran intrinsic matmul
speed with -O2 and -gnatp
ada version with array size of 600 : time = 0.6722
fortran version with array size of 600 : time = 0.6094
package Array_Product is
type Real_Matrix is array(Integer range <>,Integer range <>) of
Float;
type Matrix_Access is access Real_Matrix;
procedure Matmul (A, B : in Real_Matrix; C : out Real_Matrix);
end Array_Product;
package body Array_Product is
procedure Matmul (A, B : in Real_Matrix; C : out Real_Matrix)
is
BL : array (1 .. B'Length (1) * B'Length (2)) of Float;
D : Natural := 0;
Sum : Float := 0.0;
begin
D := 0;
-- transposition gave the best speedup cache + only one indice
Transpose_B_in_BL :
for J in B'Range (1) loop
for R in B'Range (2) loop
BL( D + R) := B(R,J);
end loop;
D := D + B'Length (2);
end loop Transpose_B_in_BL;
for I in A'Range (1) loop
declare
-- give the cache best chance with A second speedup
Ai : array (A'range (2)) of Float;
begin
for R in Ai'Range loop
Ai (R) := A (I, R);
end loop;
D := 0;
for J in A'range(2) loop
Sum := 0.0;
for R in A'Range (2) loop
Sum := Sum + Ai(R)*BL(D + R);
end loop;
D := D + A'Length (2);
C(I,J) := Sum;
end loop;
end;
end loop;
end Matmul;
end Array_Product;
Jeffrey Creem a écrit :
> Jeffrey R. Carter wrote:
> > Jeffrey Creem wrote:
> >
> >>
> >> 2) Small changes to the original code that still meet the original
> >> structure and intent of the original code can move the run time up and
> >> down by at least 50%
> >> 3) The two task based version of the code is running more than 2x
> >> faster than the single task version on a 2 processor machine. Some of
> >> this is from the two tasks but looking at the assembly, another
> >> portion of it is related to #2 above in that the re-arrangement of
> >> the math allows the compiler to get less brain dead.
> >
> >
> > These seem quite odd to me. Perhaps whatever is causing this is also the
> > cause of the speedup I saw in the sequential case when the
> > multiplication is put in a procedure.
> >
>
> Ok, we are all probably tired of taking about this topic but I posted
> what I think will be the final write-up on this (until the bugzilla
> issue for it is resolved).
>
> http://gnuada.sourceforge.net/pmwiki.php/Main/Oct2006CLAGFORTRANComparison
>
> And I agree that the > 2x speedup for the two task version is not real.
> There are now other versions that are coded in a similar maner to the 2
> task version but which are single threaded. The 2 task version runs
> almost exactly 2x faster (sometimes slightly slower) on my dual
> processor machine.
next prev parent reply other threads:[~2006-10-25 15:32 UTC|newest]
Thread overview: 68+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-10-20 10:47 GNAT compiler switches and optimization tkrauss
2006-10-20 11:04 ` Duncan Sands
2006-10-21 10:45 ` Stephen Leake
2006-10-20 11:42 ` Duncan Sands
2006-10-20 15:41 ` Martin Krischik
2006-10-20 12:09 ` Samuel Tardieu
2006-10-20 12:18 ` Samuel Tardieu
2006-10-20 12:12 ` Gautier
2006-10-20 12:35 ` Dmitry A. Kazakov
2006-10-20 15:53 ` Martin Krischik
2006-10-20 12:52 ` Gautier
2006-10-20 13:27 ` claude.simon
2006-10-20 15:38 ` Robert A Duff
2006-10-20 19:32 ` Gautier
2006-10-20 15:56 ` Jeffrey Creem
2006-10-20 16:30 ` Martin Krischik
2006-10-20 19:51 ` Gautier
2006-10-20 22:11 ` Jeffrey R. Carter
2006-10-20 23:52 ` Jeffrey Creem
2006-10-21 7:37 ` Gautier
2006-10-21 16:35 ` Jeffrey Creem
2006-10-21 17:04 ` Pascal Obry
2006-10-21 21:22 ` Jeffrey Creem
2006-10-22 3:03 ` Jeffrey Creem
2006-10-22 7:39 ` Jeffrey R. Carter
2006-10-22 11:48 ` tkrauss
2006-10-22 18:02 ` Georg Bauhaus
2006-10-22 18:24 ` Jeffrey Creem
2006-10-23 0:10 ` Georg Bauhaus
2006-10-22 20:20 ` Jeffrey R. Carter
2006-10-22 12:31 ` Gautier
2006-10-22 20:26 ` Jeffrey R. Carter
2006-10-22 21:22 ` Gautier
2006-10-22 18:01 ` tmoran
2006-10-22 20:54 ` Jeffrey R. Carter
2006-10-22 13:50 ` Alinabi
2006-10-22 15:41 ` Jeffrey Creem
2006-10-23 0:02 ` Alinabi
2006-10-23 5:28 ` Gautier
2006-10-23 16:32 ` Alinabi
2006-10-22 15:57 ` Jeffrey Creem
2006-10-22 19:32 ` Damien Carbonne
2006-10-22 20:00 ` Gautier
2006-10-22 20:51 ` Damien Carbonne
2006-10-23 2:15 ` Jeffrey Creem
2006-10-23 2:29 ` Jeffrey R. Carter
2006-10-23 1:31 ` Jeffrey Creem
2006-10-23 3:10 ` Jeffrey Creem
2006-10-23 7:31 ` Jeffrey R. Carter
2006-10-23 11:55 ` Jeffrey Creem
2006-10-23 19:52 ` Wiljan Derks
2006-10-23 20:25 ` Jeffrey R. Carter
2006-10-24 9:52 ` Dr. Adrian Wrigley
2006-10-24 11:50 ` Jeffrey Creem
2006-10-24 16:24 ` Jeffrey R. Carter
2006-10-25 3:50 ` Jeffrey Creem
2006-10-25 15:32 ` claude.simon [this message]
2006-10-24 19:21 ` Wiljan Derks
2006-10-23 12:33 ` Warner BRUNS
2006-10-23 12:40 ` Warner BRUNS
2006-10-23 13:52 ` Georg Bauhaus
2006-10-23 17:11 ` Warner BRUNS
2006-10-23 17:57 ` Dr. Adrian Wrigley
2006-10-23 15:02 ` Robert A Duff
2006-10-23 20:22 ` Jeffrey R. Carter
2006-10-21 18:28 ` tmoran
2006-10-23 6:28 ` Martin Krischik
2006-10-21 12:39 ` Dr. Adrian Wrigley
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox