This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [FORTRAN PATCH] PR 30404: Rewrite nested FORALL mask expansion
- From: Steve Kargl <sgk at troutmask dot apl dot washington dot edu>
- To: Roger Sayle <roger at eyesopen dot com>
- Cc: fortran at gcc dot gnu dot org, gcc-patches at gcc dot gnu dot org
- Date: Mon, 15 Jan 2007 16:02:42 -0800
- Subject: Re: [FORTRAN PATCH] PR 30404: Rewrite nested FORALL mask expansion
- References: <15967.68.35.10.103.1168729445.squirrel@mail.eyesopen.com>
On Sat, Jan 13, 2007 at 04:04:05PM -0700, Roger Sayle wrote:
>
> If someone could do the usual benchmarking and conformance testing,
> I'd be interested to know if there's a positive or negative impact.
>
Roger, I scanned my work/ directory where I store the Fortran
code I've snarfed from the internet. With over million lines of
code, there is exact ZERO ocurrences of FORALL. :( work/ includes
the Polyhedron Benchmarks, mpfun90, and moware as well as a few
other modern Fortran codes.
I asked for examples on comp.lang.fortran, and Mike Metcalf posted
a small program (that is from his book). Sorry about the long URL.
http://groups-beta.google.com/group/comp.lang.fortran/browse_thread/thread/9d261ff21ebf683c/fc5599887199f26b?hl=en#fc5599887199f26b
Your patch has no negative impact on runtime with Mike's code.
In fact, this code contains a RESHAPE command, which appears
to be also quadratic in time and accounts for over 99% of the
compile and execution times.
I think the patch is OK for trunk. See below for one change.
PS: I'm still trying to come up with additional codes that use FORALL.
> ! PR fortran/30404
> ! Checks that we correctly handle nested masks in nested FORALL blocks.
> ! Contributed by Paul Thomas <pault@gcc.gnu.org>
> !
> ! { dg-do run }
> logical :: l1(2,2) = reshape ((/.false.,.true.,.true.,.false./), (/2,2/))
> integer :: it(2,2) = reshape ((/1,2,3,4/), (/2,2/))
gfortran issues a warning with the above declarations. You need
to change this to
logical :: l1(2,2)
integer :: it(2,2)
l1 = reshape ((/.false.,.true.,.true.,.false./), (/2,2/))
it = reshape ((/1,2,3,4/), (/2,2/))
> forall (i = 1:2, i < 3)
> forall (j = 1:2, l1(i,j))
> it(i, j) = 0
> end forall
> end forall
> ! print *, l1
> ! print '(4i2)', it
> if (any (it .ne. reshape ((/1, 0, 0, 4/), (/2, 2/)))) call abort ()
> end