[PATCH] Matrix Flattening and Transposing optimizations
Wed Mar 28 10:48:00 GMT 2007
Richard Henderson <email@example.com> wrote on 27/03/2007 23:16:16:
> On Sun, Mar 25, 2007 at 01:21:32PM +0200, Razya Ladelsky wrote:
> > a = (int **) malloc(dim1 * sizeof(int *));
> > for (i=0; i<dim1; i++)
> > a[i] = (int *) malloc (dim2 * sizeof(int));
> Do people really do this...
> > a = (int *) malloc (dim1 * dim2 *sizeof(int));
> ... as opposed to this?
> In what sorts of contexts do you expect this to trigger?
Yes. We can see these patterns in SPEC2000: for example in art and
equake a few matrices are allocated this way, and
and some variations of it in vpr.
However, even if the allocation itself is already done as in your example,
matrix flattening would change the access a[i][j] to an access to
a[i*dim2+j], eliminating one level of indirection for this access.
Furthermore, matrix transposing may also be applied to such matrices.
At the moment matrix flattening does not recognize these patterns, but
it could be extended to do so.
More information about the Gcc-patches