Re: which is efficient



Mark Morss wrote:


PROGRAM test
IMPLICIT NONE

INTEGER :: i,j,k,m
REAL,DIMENSION(200,200,200) :: a
REAL :: out

DO m=1,100
DO i=1,200
DO j=1,200
DO k=1,200

a(i,j,k) = 0.0

END DO
END DO
END DO
END DO


Optimizing compilers will shuffle or combine the loops so as to
get stride 1 access, even though you have written this in an
apparent attempt to ruin cache performance. Many will go further,
and truncate the outer loop to DO m=100,100, as the results can
be seen to be identical.
.