On Wed, Apr 22, 2015 at 10:05 PM, Toon Moene <t...@moene.org> wrote:
> On 04/22/2015 09:10 PM, Steven Bosscher wrote:
>
>> On Wed, Apr 22, 2015 at 6:59 PM, Toon Moene wrote:
>
>
>>> Why is loop fusion important, especially in Fortran 90 and later programs
>>> ?
>>>
>>> Because without it, every array assignment is a single loop nest,
>>> isolated
>>> from related, same-shape assignments.
>>
>>
>> Why is this a bad thing? When you're talking about single-node
>> machines, separate loops is probably faster if your arrays are large
>> enough: better cache locality and easier to vectorize.
>
>
>> Loop fusion is only a win if you iterate through the same array
>> variables. Writing such a pass is not so hard for the simple, most
>> common cases. The front end could do some of the rewriting from
>> F90-style array assignments to fused loops if it notices consecutive
>> array assignments/operations on the same variables.
>
>
> It could well be that my artificial example was not what my colleague
> measured ...
>
> Indeed, I thought about the front end doing this, but that would limit it to
> those that the front end could recognize; on the other hand, that might be
> the right limitation.

Generally loop fusion is a nice-to-have thing but as Steven points out
your example isn't particularly well-suited here.  In fact loop distribution
(which performs fission) would undo such fusion.

But it also points to infrastructure we already have - loop distribution
can do the reverse transform so doing fusion there as well looks
natural (given you might fuse parts of a loop with parts of another
loop but keep parts separate as well - all based on data locality
analysis loop distribution performs).

But usually fusion requires some enablement transform(s) to make
the loop iteration spaces match.

Oh, and it's probably time to commit the patches I developed some
years ago to make loop distribution handle loop nests...

Oh, and I'm probably going to look into this and related transforms
(that enablement stuff) for GCC 6.

Richard.

> Thanks !
>
>
> --
> Toon Moene - e-mail: t...@moene.org - phone: +31 346 214290
> Saturnushof 14, 3738 XG  Maartensdijk, The Netherlands
> At home: http://moene.org/~toon/; weather: http://moene.org/~hirlam/
> Progress of GNU Fortran: http://gcc.gnu.org/wiki/GFortran#news

Reply via email to