This is the mail archive of the
fortran@gcc.gnu.org
mailing list for the GNU Fortran project.
Re: [FORTRAN PATCH] Implement a(:) = b(:) using memcpy when possible
Hi Paul,
On Fri, January 5, 2007 12:11 am, Paul Thomas wrote:
>> As with the previous patch, this optimization only affects assignments
>> that involve entire arrays that don't require a descriptor (i.e. whose
>> bounds are known at compile-time). Additionally, I've discovered that
>> gfortran supports "arrays of derived types containing allocatable
>> components" which can't be directly copied using a block move, but
>> require what the C++ front-end might call a copy constructor. Hence the
>> optimization below applies only to arrays of numeric/logical types.
>>
> I would have thought that the derived types with allocatable components
> would make perfect candidates for memcpy. The library memcpy is already
> used to copy allocated components, since they malloc'ed. It would be a
> shame to leave derived types out of your scheme IMHO.
Agreed. The issue is purely my limited understanding of F2003's type
system, and how this is represented in gfortran. I believe that all that
might be required is to add a case to handle BT_DERIVED to the new
copyable_array_p function, that checks the fields are all copyable.
Does the Fortran spec have the equivalent of C/C++'s POD or primitive
types? I could find a gfc_numeric_ts, but this didn't include LOGICAL.
And I believe that both ALLOCATABLE types and CHARACTER types can't be
memcpy copied. So I guess that a type is copyable if its POD type, or a
derived type consisting only of copyable types?
Any help from folks that can actually program in FORTRAN would be much
appreciated :-). I'm not sure I speak the language well enough to even
compose a testcase, let alone the exceptions that I'm unaware of.
Roger
--