(j3.2006) More on "contiguous"
Bill Long
longb
Tue May 15 17:59:07 EDT 2007
It is certainly useful to know that more that the first dimension is
contiguous. This allows the compiler to collapse loops (actual or
implied). This is one of the primary reasons for contiguous. If you
know that the leftmost dimension of the array D is contiguous, but other
dimensions might not qualify, then you could associate a contiguous
pointer with D(:,i) and reference the pointer.
I'd be skeptical of the claim by gprof that the statement D(:,i) = 0
consumes 8.8% of a program's time unless the value of n is really large
and there is not much else happening in the program. The performance
for that statement is probably limited by the hardware memory bandwidth,
pretty much independent of how much optimizing a reasonable compiler is
doing.
Cheers,
Bill
Van Snyder wrote:
>Does "contiguous" make any sense and confer any benefit for other than
>the first dimension?
>
>I have a dummy argument array D(:,:). I know the actual argument is
>contiguous in the first dimension because it's a section A(:n,:) of an
>automatic variable.
>
>The line-by-line profile says I'm spending 8.8% of a 25 hour run on one
>statement "D(:,i) = 0.0" -- unless I'm not interpreting the profiler's
>output correctly. I assume that by reporting line 312, gprof is telling
>me the basic block beginning (or ending?) at that line is what's being
>reported. Since the previous line is a DO statement and the next one is
>an IF statement, I assume the reported time is all spent at this line.
>
>The array D wouldn't be contiguous as a whole according to our current
>definition, but I suspect it would be helpful if the processor knew the
>first dimension were contiguous. Is it ever helpful to know that more
>dimensions are contiguous? If not, can/should we change the definition
>of "contiguous" to apply only to the first dimension?
>
>
>
--
Bill Long longb at cray.com
Fortran Technical Support & voice: 651-605-9024
Bioinformatics Software Development fax: 651-605-9142
Cray Inc., 1340 Mendota Heights Rd., Mendota Heights, MN, 55120
More information about the J3
mailing list