Re: Array puzzle
- From: glen herrmannsfeldt <gah@xxxxxxxxxxxxxxxx>
- Date: Thu, 31 Aug 2006 08:52:33 -0700
Jugoslav Dujic wrote:
Roy Lewallen wrote:
| I'm a relatively inexperienced Fortran programmer, so please go gently.
| While looking through the IVF documentation, I learned that it's(snip)
| inefficient to pass an assumed shape or allocatable array to a
| procedure, inside of which it's referenced as a non-deferred shape
| array. Further reading discourages using assumed size arrays. So I
| looked through the very old code I'd been using for some time, and found
| this:
The basic issue at stake is *contiguity* of the array [section] passed
as the real argument for an assumed-size or explicit-shape dummy. If the
section (can be proven to be) discontiguous, a "copy-in/copy-out" to/from
a stack temporary must be generated, causing a performance penalty in most
cases. For assumed-shape dummies, that is [almost] never an issue.
As far as I know, for some (maybe most) compilers, the copy is done if
it can't be proven to be contiguous. Maybe others will know for
specific compilers.
Now, how is that contiguity tested is an issue for itself. I find a blanket statement of "inefficient" to be too vague and imprecise to(snip)
be useful.
Also, the cache will often be more efficient on a contiguous array,
so if each element is being accessed many times it may be more efficient
with the copy, even including the overhead of doing the copy.
-- glen
.
- References:
- Array puzzle
- From: Roy Lewallen
- Re: Array puzzle
- From: Jugoslav Dujic
- Array puzzle
- Prev by Date: Re: problematic array assignment in double precision (ifort, windows)
- Next by Date: Re: Scope of implied-do index
- Previous by thread: Re: Array puzzle
- Next by thread: Re: Array puzzle
- Index(es):
Relevant Pages
|