performance question: cloning allocated arrays

Steve Kargl sgk@troutmask.apl.washington.edu
Mon Feb 26 18:47:00 GMT 2007


On Mon, Feb 26, 2007 at 07:12:59PM +0100, Daniel Franke wrote:
> I'd post this sort-of general question to c.l.f, but my newsserver
> doesn't work ...
> 
> Please consider this code:
> 
> TYPE :: summed_amplitude
>  COMPLEX(DBL), DIMENSION(:,:), POINTER :: alm
> END TYPE
> 
> SUBROUTINE summed_amplitude_init_copy(this, other)
>  TYPE(summed_amplitude), INTENT(out) :: this
>  TYPE(summed_amplitude), INTENT(in)  :: other
>  ALLOCATE(this%alm(size(other%alm,1), size(other%alm,2)))
>  this%alm = other%alm      !  <-----
> END SUBROUTINE
> 
> gprof shows, that my program spents about 20% of its runtime copying
> arrays. Checking the dump, gfortran seems to assign the array elements
> one by one (pasted below). Is there a way to get this done in a single
> memcpy (which hopefully would speed things up)?
> 

Not at the moment.  Roger Sayle has fixed several issues in the
dependency analysis that permits memcpy in certain array assignments, 
but I believe this does not extend to derived type components.

-- 
Steve



More information about the Fortran mailing list