[OG10] Fortran: delinearize multi-dimensional array accesses

Sandra Loosemore sandra@codesourcery.com
Thu Jan 7 19:35:36 GMT 2021


On 12/26/20 3:41 AM, Thomas Koenig wrote:
> 
> Hi Sandra,
> 
>> The attached patch implements delinearization of array accesses in the 
>> Fortran front end, something that has been discussed for a long time.
> 
> Definitely - among others, this is the subject of PR 14741, which is by
> now quite historic.
> 
>> I've been asked to try to get this patch committed on the OG10 branch 
>> since it is blocking some further optimization work with Graphite for 
>> OpenACC kernels regions.  I have a mainline version of this patch as 
>> well that I can send to anyone interested in trying it out, but TBH, I 
>> don't think this is ready for mainline yet.
> 
> That would be indeed interesting.  Could you post that to the list as
> well?

Attached to this mail.

> The current status is that
>> there are still two gfortran tests that are regressing 
>> (gfortran.dg/graphite/id-9.f and 
>> gfortran.dg/vect/fast-math-mgrid-resid.f), and while it's been 
>> confirmed that this helps with Graphite optimizations as intended, we 
>> haven't yet run any benchmarks to confirm that it doesn't make other 
>> things slower. 
> 
> It is probably too late; this could go in for the next stage 1.

Yes, I hope we can get this more polished by that time.

> Does the patch actually make loop interchange for matrix multiplication
> work (done with C for loops or Fortran DO loops), or is there additional
> work required?

There's some additional work required, and probably not by me since I 
know next to nothing about graphite or GCC's loop optimization framework 
generally.  :-(  (The motivation for this patch at this time is that we 
need the delinearization for some ongoing OpenACC parallelization work.)

> Regarding scalarized loops: We still to not collapse loops for
> 
>    subroutine foo(a)
>      real, dimension(:,:), contiguous :: a
>      a = 5.
>    end subroutine foo
> 
> so an extension to scalarized loops would be quite valuable.

Yes.  I guesstimated that would be a medium-sized project since the 
scalarized references are generated by a completely different code path.

> It would be interesting to see if
> 
>    subroutine foo(a,n,m)
>      real, dimension(n,m) :: a
>      do j=1,m
>        do i=1,n
>          a(i,j) = 5.
>        end do
>      end do
>    end subroutine foo
> 
> is collapsed to a single loop with the patch and Graphite.

This one also requires some additional work.  At least Graphite 
recognizes the SCoP around the loop nest with this patch which it did 
not do without delinearization.

-Sandra
-------------- next part --------------
A non-text attachment was scrubbed...
Name: delinearize-mainline-dec17.patch
Type: text/x-patch
Size: 24282 bytes
Desc: not available
URL: <https://gcc.gnu.org/pipermail/gcc-patches/attachments/20210107/840723b0/attachment-0001.bin>


More information about the Gcc-patches mailing list