# Generalized Index-Set Splitting

Document Sample

```					Generalized Index-Set Splitting

Christopher Barton
Arie Tal
Bob Blainey
Jose Nelson Amaral
Generalized Index-Set Splitting

●   Overview
●   Compile-time unknown split points
●   Loops with multiple split points
●   Nested inductive branches
●   Controlling Code Growth
●   Results
●   Conclusions
Index-Set Splitting

●   Divide the index-set (range) of a loop into
sub-ranges
●   Each sub-range represents a separate loop

for (i=0; i < 100; i++) {   for (i=0; i < 5; i++) {
if (i < 5)                  a[i] = 2 * a[i];
a[i] = 2 * a[i];          b[i] = a[i] * a[i];
else                      }
a[i] = 5 * a[i];        for (i=5; i < 100; i++) {
b[i] = a[i] * a[i];         a[i] = 5 * a[i];
}                             b[i] = a[i] * a[i];
}
Compile-time Unknown Split
Points
●   When the lower-bound, upper-bound or split-
point are unknown at compile time:
for (i=0; i < 100; i++) {   for (i=0; i < m; i++) {
if (i < m)                  a[i] = 2 * a[i];
a[i] = 2 * a[i];          b[i] = a[i] * a[i];
else                      }
a[i] = 5 * a[i];        for (i=m; i < 100; i++) {
b[i] = a[i] * a[i];         a[i] = 5 * a[i];
}                             b[i] = a[i] * a[i];
}

Problem: m may be smaller than 0 or greater than 100!
Compile-time Unknown Split
Points
●   To overcome this problem, we will use the
following sub-ranges:
–   First loop: 0 – min(m, 100)
–   Second loop: max(m,0) - 100
for (i=0; i < min(m,100); i++) {
a[i] = 2 * a[i];
b[i] = a[i] * a[i];
}
for (i=max(m,0); i < 100; i++) {
a[i] = 5 * a[i];
b[i] = a[i] * a[i];
}
Compile-time Unknown Split
Points
m ≤ 0:
for (i=0; i < min(m,100); i++) {  second loop iterates from 0 to 100
a[i] = 2 * a[i];
b[i] = a[i] * a[i];
0 < m < 100
}
first loop iterates from 0 to m
for (i=max(m,0); i < 100; i++) {
a[i] = 5 * a[i];                  second loop iterates from m to 100
b[i] = a[i] * a[i];
100 ≤ m:
}
first loop iterates from 0 to 100
Compile-time Unknown Split
Points
●   In general:
–   Given a range with lower bound lb, upper bound
ub, and split-point sp, we define two sub-ranges:
●   lb to min(sp, ub)
●   max(sp,lb) to ub
for (i=lb; i < min(sp,ub); i++) {
a[i] = 2 * a[i];                  No other conditions are
b[i] = a[i] * a[i];
}                                   needed in addition to the
for (i=max(sp,lb); i < ub; i++) {   loop structure
a[i] = 5 * a[i];
b[i] = a[i] * a[i];
}
Loops With Multiple Split Points

●    Multiple split points can be handled iteratively
●    Instead, we build a sub-range tree:

for (i=0; i < 100; i++) {                                   0,100
if (i < m)
a[i] = 2 * a[i];
if (i < n)                                 0,min(m,100)           max(m,0), 100
a[i] = 5 * a[i];
b[i] = a[i] * a[i];
}                           0,min(m,n,100)                                     max(m,n,0),100
max(0,n),min(m,100)     max(m,0),min(n,100)
Loops with multiple split points

●    The first level in the sub-range tree
corresponds to the original loop range

for (i=0; i < 100; i++) {                                   0,100
if (i < m)
a[i] = 2 * a[i];
if (i < n)                                 0,min(m,100)           max(m,0), 100
a[i] = 5 * a[i];
b[i] = a[i] * a[i];
}                           0,min(m,n,100)                                     max(m,n,0),100
max(0,n),min(m,100)     max(m,0),min(n,100)
Loops with multiple split points

●    The second level of the tree corresponds to
the two loops created to remove the (i < m)
inductive branch
for (i=0; i < min(m,100); i++) {                             0,100
a[i] = 2 * a[i];
if (i < n)
a[i] = 5 * a[i];
b[i] = a[i] * a[i];                         0,min(m,100)         max(m,0), 100
}
for (i=max(m,0); i < 100; i++) {
if (i < n)
0,min(m,n,100)                                  max(m,n,0),100
a[i] = 5 * a[i];
b[i] = a[i] * a[i];                      max(0,n),min(m,100) max(m,0),min(n,100)
}
Branches
●    To easily remove dead inductive-branches,
we mark the edges in the Then/Else to
correspond with the condition
for (i=max(0,n); i<min(m,100); i++) {                        0,100
if (i < m)
a[i] = 2 * a[i];
if (i < n)
a[i] = 5 * a[i];                         0,min(m,100)           max(m,0), 100
b[i] = a[i] * a[i];
}

0,min(m,n,100)                                     max(m,n,0),100
max(0,n),min(m,100)     max(m,0),min(n,100)
Branches
●    We examine the path that leads from the root
of the sub-range tree to the desired sub-
range node
for (i=max(0,n); i<min(m,100); i++) {                        0,100
if (i < m)
a[i] = 2 * a[i];
if (i < n)
a[i] = 5 * a[i];                         0,min(m,100)           max(m,0), 100
b[i] = a[i] * a[i];
}

0,min(m,n,100)                                     max(m,n,0),100
max(0,n),min(m,100)     max(m,0),min(n,100)
Nested Inductive-branches

●   Nested branches only split the nodes of the
ranges to which they apply

for (i=0; i < 100; i++) {                  0,100
if (i < m)
a[i] = 2 * a[i];
else                      0,min(m,100)           max(m,0), 100
if (i < n)
a[i] = 5 * a[i];
b[i] = a[i] * a[i];                  max(m,0),min(n,100)    max(m,n,0),100
}
Nested Inductive-branches

●   Nested branches only split the nodes of the
ranges to which they apply
●   The result will be three loops:
for (i=0; i < min(m,100; i++) {                          0,100
a[i] = 2 * a[i];
b[i] = a[i] * a[i];
}
0,min(m,100)           max(m,0), 100
for (i=max(m,0); i < min(n,100); i++) {
a[i] = 5 * a[i];
b[i] = a[i] * a[i];
}
max(m,0),min(n,100)    max(m,n,0),100
for (i=max(m,n,0); i < 100; i++) {
b[i] = a[i] * a[i];
}
Controlling Code Growth

●    We descend down the sub-range tree using

for (i=0; i < 100; i++) {                                   0,100
if (i < m)
a[i] = 2 * a[i];
if (i < n)                                 0,min(m,100)           max(m,0), 100
a[i] = 5 * a[i];
b[i] = a[i] * a[i];
}                           0,min(m,n,100)                                     max(m,n,0),100
max(0,n),min(m,100)     max(m,0),min(n,100)
Controlling Code Growth
●    We stop when we reach all the leaf nodes, or
the code growth limit
●    The selected nodes designate the loops that
will be generated             0,100
for (i=0; i<min(m,100); i++) {
a[i] = 2 * a[i];
if (i < n)
a[i] = 5 * a[i];
b[i] = a[i] * a[i];                              0,min(m,100)           max(m,0), 100
}
for (i=max(m,0); i<min(n,100); i++) {
a[i] = 5 * a[i];
b[i] = a[i] * a[i];
}                                   0,min(m,n,100)                                   max(m,n,0),100
for (i=max(m,n,0); i<100; i++) {                max(0,n),min(m,100)   max(m,0),min(n,100)
b[i] = a[i] * a[i];
}
Number of ISS Opportunities
bz

10
15
20
25

0
5
ip
cr 2
af
ty
eo
n
ga
p
g
pe zip
rlb
m
tw k
ol
f
vp
ap r
pl
u
ap
eq s i

Benchmarks
ua
fm ke
a3
ga d
lg
lu el
six cas
t ra
ck
ISS Opportunities in SPEC2000

Loop Fusion
No Loop Fusion
Compilation Time Increase (%)

-3
-2
-1
0
1
2
3
4
5
6
7
gz
i
8
lu p
ca
s
bz
eq ip2
ua
ke
vp
cr r
af
ty
ap
si
tw
o
ga lf
lg
e
ap l

Benchmarks
pe plu
rlb
m
k
eo
n
g
six ap
tra
c
fm k
a3
d
Compilation Times for SPEC2000
Runtime Reduction (%)

lu

-2.5
-1.5
-0.5
0.5
1.5

-3
-2
-1
0
1
ca           2
s
bz
ip
eq 2
ua
ke
vp
r
cr
af
ty
ap
si
tw
ol
ga f
lg
el
ap

Benchmark
p
pe lu
rlb
m
k
ga
six p
tra
ck
fm
a3
d
Runtimes for SPEC2000
Conclusions

●   Presented a technique to remove loop-variant
branches from loops by splitting the original
loop into several loops with varying ranges
●   Implemented in IBM’s XL Compiler suite and
showed ISS opportunities in benchmark suites
●   Exploring ways ISS can be used to improve
effectiveness of other optimizations

```
DOCUMENT INFO
Shared By:
Categories:
Stats:
 views: 4 posted: 4/8/2010 language: English pages: 20
How are you planning on using Docstoc?