The loop blocking transformation decomposes a
do-loop statement into blocks of a constant blocking factor (the step is
multiplied by this factor). The knowledge of the sign of the outer loop step
is necessary to obtain an efficient blocking. This information can be computed
automatically or can be specified by the user. The blocking factor must be
greater than 1. When it is applied to a perfect nest of loops, the outer loop
can be blocked in the body of the inner loop of the specified level.
Example 65: A loop blocking transformation applied to the
loop of index i with a level of 2 and a blocking factor of 4.
DO i = 1,m DO j = 1,n F(i,j,k) ENDDO ENDDO
DO Ti=1,m,4 DO j = 1,n DO i = Ti,MIN(Ti+4-1,m) F(i,j,k) ENDDO ENDDO ENDDO
The loop blocking transformation is generally followed by a loop interchanging or a loop transformation.