
46 Cray T3E User’s Guide
!dir$ split
DOi=1,1000
a(i) = b(i) * c(i)
t = d(i) + a(i)
e(i)=f(i)+t*g(i)
h(i) = h(i) + e(i)
END DO
The directive is marked with the characters !dir$. If the source code
is written using the fixed source form, these characters must be at the
beginning of the line.
Due to the directive split, the compiler will split the above loop in two
as follows:
DOi=1,1000
a(i) = b(i) * c(i)
ta(i) = d(i) + a(i)
END DO
DOi=1,1000
e(i) = f(i) * ta(i) * g(i)
h(i) = h(i) + e(i)
END DO
This may make the code faster by reducing memory bandwidth. Instead
of loading and storing a lot of data in an iteration of the loop, the split
loop gives a better balance between computation and memory opera-
tions. This also improves the performance if we are using the streams
mechanism.
Here is an example of loop unrolling:
!dir$ unroll 2
DOi=1,10
DOj=1,100
a(j,i) = b(j,i) + 1
END DO
END DO
This results in the following unrolled loops (into two copies of the inner
loop):
DOi=1,10,2
DOj=1,100
a(j,i) = b(j,i) + 1
END DO
DOj=1,100
a(j,i+1) = b(j,i+1) + 1
END DO
END DO
The compiler may also fuse the two inner loops together to produce the
following final code:
DOi=1,10,2
DOj=1,100
Comentarios a estos manuales