Partial Program Admission

Download Report

Transcript Partial Program Admission

Partial Program Admission
Mike Wilson, Ron Cytron, and
Jon Turner
Computer Science & Engineering
Presentation Roadmap
 Context
and Problem
 Partial Program Admission
» Concept
» Algorithm
» Complexity
 Evaluation
» Real Programs
 Future
Directions
 Conclusions
‹#›
Presentation Roadmap
 Context
and Problem
 Partial Program Admission
» Concept
» Algorithm
» Complexity
 Evaluation
» Real Programs
 Future
Directions
 Conclusions
‹#›
Context: Virtual Networking
Outside developer provides
virtual router code
Developer requests bandwidth
amount, supplies WCET
WDRR
VR 1
VR N
CPU
At admission,
bandwidth and WCET
are used to compute
WDRR parameters
‹#›
Context: Virtual Networking
WDRR
VR 1
VR N
CPU
If WCET is accurate,
isolation is achieved
‹#›
Context: Virtual Networking
WDRR
VR 1
VR N
CPU
If WCET is accurate,
isolation is achieved
‹#›
Context: Virtual Networking
WDRR
VR 1
VR N
CPU
What if the developer lies?
‹#›
Context: Virtual Networking
WDRR
VR 1
VR N
CPU
If WCET is wrong,
guarantees are missed
‹#›
Problem: Enforcing Execution Bounds
Need a way to enforce assertions of WCET
 Preemption?
» Unavailable
 Runtime
instrumentation?
» Adds too much overhead
 WCET
Analysis?
» Can be too pessimistic
‹#›
Presentation Roadmap
 Context
and Problem
 Partial Program Admission
» Concept
» Algorithm
» Complexity
 Evaluation
» Real Programs
 Future
Directions
 Conclusions
‹#›
Partial Program Admission

Partial Program Admission (PPA)
» Inputs:
• Program CFG
• Cycle Budget
• Exception Handler
» Outputs:
• Program CFG which adheres to budget
• calls exception handler before overrun
• No runtime overhead

Relies on an idealized processor model
» No cache (data or instruction)
» No pipeline, one instruction/cycle
» Single-threaded
‹#›
Control Flow Graph

A;
if (cond1)
B;
else
C;
D;
if (cond2)
E;
else
F;
G;


Digraph representation of
a program
Vertices represent pieces
of code
1
Weights represent cycle
counts to traverse vertex

Artificial source, sink: S, T
0
A
2
B
Edges represent flow of
control

S
D
1
C
3
F
4
1
E
G
1
T
0
‹#›
Partial Program Admission: Concept
1
S
0
A
2
B
D
1
C
3
F
4
1
E
G
1
T
0
‹#›
Partial Program Admission: Concept
1
S
0
A
2
B
C
D
1
Consider the CFG as a
collection of paths with lengths
3
Then the exact WCET is 9
PPA can remove SACDFGT
without affecting correctness!
1
E
F
G
1
T
0
Suppose path SACDFGT is
infeasible
4
Paths
SABDEGT
SABDFGT
SACDEGT
SACDFGT
Length
6
9
8
11
Infeasible!
‹#›
Partial Program Admission: Concept
S
0
0
S
What does it mean to remove a path?
A
1
B
C
D
1
Suppose we split up all paths. A
2
3
1
E
F
4
2
1
B
C
3
1
D1
D2
1
1
E1
F1
4
1
E2
F2
4
G
1
1
G1
G2
1
1
G3
G4
1
T
0
0
T1
T2
0
0
T3
T4
0
‹#›
Partial Program Admission: Concept
0
S
Now removing SACDFGT is easy
We intercept at D2 and raise
A 2 an
exception
1
B
C
This program is safe to run, but
1 compact
D2
D1
bloated. We can
it by
coalescing identical subtrees
X
3
1
1
E1
F1
4
1
E2
F2
4
1
G1
G2
1
1
G3
G4
1
0
T1
T2
0
0
T3
T4
0
‹#›
Partial Program Admission: Concept
S
0
A
2
The program
size
is are
nowidentical.
These
two also
are
subtrees
identical.
reasonable.
We
can combine them.
1
B
C
3
1
D1
D2
1
1
E1
F1
4
1
E2
1
G1
G2
1
1
G3
0
T1
T2
0
0
T3
Separating all paths and then
coalescing is usually impractical.
What we really want is just to
generate what we need.
X
‹#›
Partial Program Admission: Foundations

0
A
2
New Concepts
» Completion Set of u
• cset(u,G) – all paths from u to the sink
• csetR(u,G) – all paths in cset(u,G) of
length R or less

S
1
B
D
Two vertices can be coalesced
if they have identical csets
» cset3(E,G) = cset5(E,G) = {EGT}
1
C
3
F
4
1
E
G
1
T
0
‹#›
Partial Program Admission: Foundations

0
A
2
New Concepts
» clen(u,G) – set of lengths of all paths in cset(u,G)
» clenR(u,G) – set of lengths of all paths in csetR(u,G)
» cset(D,G)={DEGT, DFGT}
» clen(D,G)={3,6}

S
Note that csetR(u,G) only changes when R
crosses a value in clen(u,G)
1
B
D
1
» We can use this to define equivalence classes
of R over completion sets
C
3
F
4
1
E
G
1
T
0
‹#›
Partial Program Admission: Foundations

S
0
A
2
New Concepts
» We call these equivalence classes
Intervals.
clen(D,G)={3,6}
 Intervals at D: [-∞,2] [3,5] [6,∞]
1
B
C
3
F
4


These intervals form the basis of a
dynamic programming approach
D
1
1
E
G
1
T
0
‹#›
Generating clen Sets
S
0

A
1
{4,7}
B {6,9}
D
1
» Starting from sink,
weight-shift and push
to predeccessor
{6,8,9,11}
2
C
{6,9}
3{8,11}
» We provide an O(mB)
algorithm in the paper
1{4,7}
{6,9}
{3,6}
{3,6}
E {2}
{3}
F
4
G
1
{2}
{1}
{5}
T
0
{0}
{1}
Compute all clen sets
{6}
{5}

We actually only need
all clenB sets
‹#›
Dynamic Programming Graph
S
A
1
1
C
1
E {2}

From clen sets, we know
all intervals

Intervals give our
equivalence classes of
csets

Each vertex u and interval
[i,j] becomes a new
vertex u[i,j]

Edges are connected to
keep csets correct
{6,8,9,11}
2
B {4,7}
D
{6,8,9,11}
0
3 {6,9}
{3,6}
F
G
1
{1}
T
0
{0}
4 {5}
‹#›
Dynamic Programming Graph
1
S
0
A
2
B {4,7}
D
1
{6,8,9,11}
{6,8,9,11}
C
1
E {2}
3 {6,9}
G
1
{1}
T
0
{0}
4 {5}
S[6,7]
S[8,8]
S[9,10]
S[11,∞]
A [-∞,5]
A[6,7]
A[8,8]
A[9,10]
A[11,∞]
B[4,6]
C[6,8]
B[7 , ∞]
C[9, ∞]
B[-∞,3]
{3,6}
F
S[-∞,5]
C[-∞,5]
D[-∞,2]
E[- ∞,1]
F[- ∞,4]
D[3,5]
D[6 , ∞]
E[2 , ∞]
F[5 , ∞]
G[- ∞,0]
G[1 , ∞]
T[- ∞,-1]
T[0 , ∞]
‹#›
Dynamic Programming Graph
Each vertex has a
distinct cset
except for empty
csets.
S[-∞,5]
S[6,7]
S[8,8]
S[9,10]
S[11,∞]
A [-∞,5]
A[6,7]
A[8,8]
A[9,10]
A[11,∞]
B[4,6]
C[6,8]
B[7 , ∞]
C[9, ∞]
B[-∞,3]
We can combine
these and replace
with an exception
handler.
C[-∞,5]
D[-∞,2]
E[- ∞,1]
F[- ∞,4]
D[3,5]
D[6 , ∞]
E[2 , ∞]
F[5 , ∞]
G[- ∞,0]
G[1 , ∞]
T[- ∞,-1]
T[0 , ∞]
‹#›
Dynamic Programming Graph
Finally, we return
control from X to the
caller.
S[6,7]
S[8,8]
S[9,10]
S[11,∞]
A[6,7]
A[8,8]
A[9,10]
A[11,∞]
From this, we can
generate our
transformed CFG.
B[4,6]
C[6,8]
B[7 , ∞]
C[9, ∞]
For B=9, we want a
graph with cset9(S,G).
But this is the
subgraph reachable
from S[9,10].
X
D[3,5]
D[6 , ∞]
E[2 , ∞]
F[5 , ∞]
G[1 , ∞]
T[0 , ∞]
‹#›
Complexity
 Spatial
Complexity
»Duplication factor of each vertex u is upperbounded by the smallest of three factors:
• Number of paths s↝u
• Number of paths u↝t
• Budget
‹#›
Presentation Roadmap
 Context
and Problem
 Partial Program Admission
» Concept
» Algorithm
» Complexity
 Evaluation
» Real Programs
 Future
Directions
 Conclusions
‹#›
Evaluation: Real Programs
Program
Size
Cyclic
count
23
No
nstats
368
No
ipv4_parse
614
No
ipv4_hdrfmt_encap
497
No
i3_parse
734
No
i3_hdrfmt_encap
582
No
port_count
229
Yes
port_reporter
133
Yes

8 programs from the
networking domain

Size is in instructions

Cyclic programs will be
analyzed separately
‹#›
Evaluation: Acyclic Programs
‹#›
Evaluation: Cyclic Programs
‹#›
Evaluation: Cyclic, Unrolled
‹#›
Evaluation: Assessment
 Bad
news:
» Some significant duplication
 Good
news: for the inlined, unrolled
programs, all eight programs can fit into one
IXP instruction store with room leftover for
the scheduler.
» 7,018 instructions; istore is 8,192 instructions.
‹#›
Presentation Roadmap
 Context
and Problem
 Partial Program Admission
» Concept
» Algorithm
» Complexity
 Evaluation
» Real Programs
 Future
Directions
 Conclusions
‹#›
Future Directions
 Code
Generation
 Annotated
infeasible paths
» Reduces bloat of loops
» Adds function-call handling
‹#›
Presentation Roadmap
 Context
and Problem
 Partial Program Admission
» Concept
» Algorithm
» Complexity
 Evaluation
» Real Programs
 Future
Directions
 Conclusions
‹#›
Conclusions
 Partial
 Best
Program Admission works!
used when:
» Programs are small
» Budgets are small and tight
» Hardware model is tractable
‹#›
Questions?
‹#›