Fortran array slices and -frepack-arrays

Richard Biener richard.guenther@gmail.com
Wed Apr 18 13:16:00 GMT 2018


On Wed, Apr 18, 2018 at 2:29 PM, Wilco Dijkstra <Wilco.Dijkstra@arm.com> wrote:
> Steve Kargl wrote:
>
>> The description of -frepack-arrays suggests that a temporary
>> array is created.  What impact does this have on stack usage?
>> What impact does it have on code size?  Other than some unnamed
>> code that you have, have you tried -frepack-arrays on say the
>> Polyhedron Benchmarks to investigate trade-offs with this
>> option.
>
> The step is checked at function entry, and the array is only copied to
> a malloc'd temporary if it is not 1. Generally Fortran uses malloc even for
> small temporaries - with -fstack-arrays it uses alloca even for huge
> temporaries. This is far from ideal, it should choose between malloc and
> alloca depending on a configurable size.
>
> The vast majority of steps in array slices are 1, so it mostly adds extra
> code. The codesize cost on SPEC2017 is 2% on exchange2_r, 6.6% on
> roms_r (large number of array slices, so if function versioning is feasible
> then that is preferable) - the rest is either identical or ~0.2% larger.
>
> I'll see whether I can run some more benchmarks.

Well, an immediate benefit would be to improve vectorization which
no longer needs to handle arbitrary strided loads/stores but can rely
on stride 1 if that is properly communicated by the frontend with
-frepack-arrays.

Of course here inputs are not everything but outputs have to be
considered as well...

Richard.

> Wilco



More information about the Fortran mailing list