This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: pr32512 - efficiency of RESHAPE and SPREAD
- From: Tobias Schlüter <tobias dot schlueter at physik dot uni-muenchen dot de>
- To: Paul Thomas <paulthomas2 at wanadoo dot fr>
- Cc: Fortran List <fortran at gcc dot gnu dot org>, highegg at gmail dot com
- Date: Mon, 13 Aug 2007 22:57:57 +0200
- Subject: Re: pr32512 - efficiency of RESHAPE and SPREAD
- References: <46C0C059.7080402@wanadoo.fr>
Paul Thomas wrote:
Dear All,
In contemplating this excellent suggestion from Jaroslav Hajek, I have
run into an interesting puzzle.
trans-array.c (gfc_conv_array_transpose) implements a transpose in which
the operation is entirely performed inline and only acts on the
descriptor. Jaroslav suggests that we do the same for reshape and spread.
In investigating this, I found the rather wierd and wonderful property
of gfortran; gfc_conv_array_transpose only works when it is the actual
argument of something. If I lift this constraint, it still works fine.
Does anybody know why this is so?
The original implementation of this feature (only modify the descriptor)
was intended for the special case MATMUL(TRANSPOSE(X),Y). It seems
nobody at the time thought that this optimization would work or be
beneficial outside these circumstances.
The original patch and its explanation can be found here:
<http://gcc.gnu.org/ml/fortran/2005-12/msg00113.html> and in the older
threads linked from there.
Cheers,
- Tobi