(j3.2006) More on "contiguous"

Michael Ingrassia michaeli
Tue May 15 19:17:48 EDT 2007

Bob Corbett asked me to forward this to the list.  He says that he is 
no longer allowed to post to the mailing list.  (Rich/Dan, can you check
if something has changed recently in the mailing list configuration?)

Van Snyder wrote:

 > Does "contiguous" make any sense and confer any benefit for other than
 > the first dimension?


Consider the simple example of a whole array assignment where the
arrays have rank greater than one.  If the arrays are known to be
contiguous, the loop control can be flattened to a single loop
instead of requiring nested loops.  The single loop form of the
assignment in turn can enable use of special hardware for block
moves.  The performance difference can be huge.

 > 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?

The two most useful cases are knowing that the whole array is contiguous
and knowing that the first dimension is contiguous.

Bob Corbett

----- End Included Message -----

More information about the J3 mailing list