
58 Cray T3E User’s Guide
The split directive merely asserts that the loop can profit by splitting.
It will not cause incorrect code.
The compiler splits the loop only if it is safe. Generally, a loop is safe to
split under the same conditions that a loop is vectorizable. The compiler
only splits inner loops, but it may not split loops with conditional code.
The split directive also causes the original loop to be stripmined, and
therefore the data is processed in blocks small enough to fit in the cache.
Loop splitting can reduce the execution time of a loop by as much as
40%. Even loops with as few as 40 iterations may be split. The loops
must contain more than six different memory references with strides
less than 16.
Note that there is a slight risk on increasing the execution time of certain
loops. Loop splitting also increases compilation time, especially when
loop unrolling is also enabled.
Here is an example of loop splitting:
#pragma _CRI split
for (i=0; i<1000; i++) {
a[i] = b[i] * c[i];
t = d[i] + a[i];
e[i]=f[i]+t*g[i];
h[i] = h[i] + e[i];
}
First, the compiler generates the following loop:
for (i=0; i<1000; i++) {
a[i] = b[i] * c[i];
ta[i] = d[i] + a[i];
}
for (i=0; i<1000; i++) {
e[i] = f[i] * ta[i] * g[i];
h[i] = h[i] + e[i];
}
Finally, the compiler stripmines the loops to increase the potential for
cache hits and reduces the size of arrays created for scalar expansion:
for (i1=0; i1<1000; i1+=256) {
i2 = (i1+256 < 1000) ? i1+256 : 1000;
for (i=i1; i<i2; i++) {
a[i] = b[i] * c[i]
ta[i-i1] = d[i] + a[i]
}
for (i=i1; i<i2; i++) {
e[i] = f[i] * ta[i-i1] * g[i]
h[i] = h[i] + e[i]
}
}
Kommentare zu diesen Handbüchern