What I would really like is a way to point a complex array at real and
imaginary components, and vice-versa. That would eliminate all data
motion. That was the game we could play in F77. A real array with
size 2*N could be passed to a subroutine and received as a complex
array of size N.
I cannot think of any legal way to do this in F90, but I wish it were
possible.
-robert ferrell
Pierre Hugonnet writes:
> Hello,
>
> In my applications, I used to associate REAL actual arguments with COMPLEX dummy arguments (and vice-versa). Since this is not possible when using F90 interfaces, I often have to transfer data between REAL and COMPLEX arrays.
>
> Hence, I am concerned about the most efficient method to do these copies. I have tested 3 of them:
> a) the scopy() routine
> b) the cmplx(), real(), and aimag() functions
> c) the transfer() functions
> (All are "legal" for the default real kind, but I'm aware that only b) is permitted for other kinds).
>
> I performed the test for small arrays (2**10 elements), which are in the cache, and for large arrays (2**20 elements), which result in cache misses.
>
> I tested 3 platforms: Sun (Enterprise 450, f90 Workshop 6.0), SGI (Origin 2000, f90 MipsPro 7), IBM (SP2 Power3, xlf90)
>
>
> Observations:
> -------------
>
> -- For real->complex, scopy() and cmplx() result in similar timings: sometimes scopy() is a bit faster, sometimes a bit slower.
> -- For complex->real, scopy() is signicantly faster than the 2 steps assignement real/aimag for large arrays on SGI, and in all cases on IBM. In others cases the two approacches have similar timings.
> -- The transfer() function has dramatically low performances on SUN and SGI. On IBM it seems to be better implemented, but however still significantly slower than the other approaches.
>
>
> Conclusions:
> ------------
>
> I would recommend as a general rule:
> For real->complex, use the intrinsic cmplx()
> For complex->real, scopy() should be prefered (note however that these tests were conducted for contiguous arrays. With non-contiguous arrays, scopy() would be much slower because copy-in/copy-out would occur)
>
>
> For the future: I think that an intrisic that would do in one step the real()/aimag() assignements could be useful (i.e. r(:)=re_im(c(:) instead of r(1::2)=real(c); r(2::2)=aimag(c) )
>
>
>
> Any comment ?
>
>
> Regards,
>
> Pierre
>
>
>
>
> --
> -----------------------------------------------------------------------
> Pierre Hugonnet R&D Data Processing
> COMPAGNIE GENERALE DE GEOPHYSIQUE - Paris Processing Centre
> 1, rue Leon Migaux / 91341 MASSY cedex / FRANCE
> phone:(33) 164 47 45 59 fax:(33) 164 47 32 49
> email:phugonnet(at)cgg.com (replace (at) by @)
> -----------------------------------------------------------------------
> The opinions expressed in this message are not necessarily
> those of CGG or of Jacques Chirac
|