370 likes | 464 Vues
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.
E N D
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 VR 1 WDRR VR N CPU At admission, bandwidth and WCET are used to compute WDRR parameters
Context: Virtual Networking VR 1 WDRR VR N CPU If WCET is accurate, isolation is achieved
Context: Virtual Networking VR 1 WDRR VR N CPU If WCET is accurate, isolation is achieved
Context: Virtual Networking VR 1 WDRR VR N CPU What if the developer lies?
Context: Virtual Networking VR 1 WDRR 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 S 0 • Digraph representation of a program • Vertices represent pieces of code • Edges represent flow of control • Weights represent cycle counts to traverse vertex • Artificial source, sink: S, T A A;if (cond1) B;else C;D;if (cond2) E;else F;G; 2 B C 1 3 D 1 E F 4 1 G 1 T 0
S 0 A 2 B C 1 3 D 1 E F 4 1 G 1 T 0 Partial Program Admission: Concept
Infeasible! Partial Program Admission: Concept S 0 Consider the CFG as a collection of paths with lengths Suppose path SACDFGT is infeasible Then the exact WCET is 9 PPA can remove SACDFGT without affecting correctness! A 2 B C 1 3 D 1 E F 4 1 Paths Length SABDEGT 6 SABDFGT 9 SACDEGT 8 SACDFGT 11 G 1 T 0
S S 0 0 A A 2 2 B B C C 1 1 3 3 D D2 D1 1 1 1 E1 E E2 F1 F2 F 4 4 4 1 1 1 G1 G2 G G3 G4 1 1 1 1 1 T1 T T2 T3 T4 0 0 0 0 0 Partial Program Admission: Concept S What does it mean to remove a path? Suppose we split up all paths. A B C D D E E F F G G G G T T T T
S 0 A 2 B C 1 3 D2 D1 1 1 E1 E2 F1 F2 4 4 1 1 G1 G2 G3 G4 1 1 1 1 T1 T2 T3 T4 0 0 0 0 Partial Program Admission: Concept Now removing SACDFGT is easy We intercept at D2 and raise an exception This program is safe to run, but bloated. We can compact it by coalescing identical subtrees X
S 0 A 2 B C 1 3 D2 D1 1 1 F1 4 Partial Program Admission: Concept The program size is now reasonable. Separating all paths and then coalescing is usually impractical. What we really want is just to generate what we need. These two subtrees are identical. We can combine them. These are also identical. E1 E2 1 1 G1 G2 G3 1 1 1 T1 T2 T3 X 0 0 0
S 0 A 2 B C 1 3 D 1 E F 4 1 G 1 T 0 Partial Program Admission: Foundations • 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 • Two vertices can be coalescedif they have identical csets • cset3(E,G) = cset5(E,G) = {EGT}
S 0 A 2 B C 1 3 D 1 E F 4 1 G 1 T 0 Partial Program Admission: Foundations • 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} • Note that csetR(u,G) only changes when R crosses a value in clen(u,G) • We can use this to define equivalence classes of R over completion sets
S 0 A 2 B C 1 3 D 1 E F 4 1 G 1 T 0 Partial Program Admission: Foundations • New Concepts • We call these equivalence classes Intervals. • clen(D,G)={3,6} • Intervals at D: [-∞,2] [3,5] [6,∞] • These intervals form the basis of a dynamic programming approach
S 0 A 2 B C 1 3 D 1 E F 4 1 G 1 T 0 Generating clen Sets • Compute all clen sets • Starting from sink, weight-shift and push to predeccessor • We provide an O(mB) algorithm in the paper • We actually only need all clenB sets {6,8,9,11} {6,8,9,11} {6,9} {4,7} {6,9} {8,11} {6,9} {3,6} {4,7} {3,6} {3,6} {6} {5} {2} {3} {1} {2} {1} {5} {0} {1} {0}
S 0 A 2 B C 1 3 D 1 E F 4 1 G 1 T 0 Dynamic Programming Graph {6,8,9,11} • 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} {6,9} {4,7} {3,6} {5} {2} {1} {0}
S 0 A 2 B C 1 3 D 1 E F 4 1 G 1 T 0 Dynamic Programming Graph {6,8,9,11} S[-∞,5] S[6,7] S[8,8] S[9,10] S[11,∞] A[6,7] A[8,8] A[9,10] A[11,∞] A [-∞,5] {6,8,9,11} {6,9} {4,7} B[-∞,3] C[-∞,5] B[4,6] C[6,8] B[7 , ∞] C[9, ∞] D[3,5] D[6 , ∞] D[-∞,2] {3,6} {5} {2} E[- ∞,1] E[2 , ∞] F[5 , ∞] F[- ∞,4] G[- ∞,0] G[1 , ∞] {1} {0} T[0 , ∞] T[- ∞,-1]
Dynamic Programming Graph S[-∞,5] S[6,7] S[8,8] S[9,10] S[11,∞] Each vertex has a distinct cset except for empty csets. We can combine these and replace with an exception handler. A[6,7] A[8,8] A[9,10] A[11,∞] A [-∞,5] B[-∞,3] C[-∞,5] B[4,6] C[6,8] B[7 , ∞] C[9, ∞] D[3,5] D[6 , ∞] D[-∞,2] E[- ∞,1] E[2 , ∞] F[5 , ∞] F[- ∞,4] G[- ∞,0] G[1 , ∞] T[0 , ∞] T[- ∞,-1]
Dynamic Programming Graph S[6,7] S[8,8] S[9,10] S[11,∞] Finally, we return control from X to the caller. From this, we can generate our transformed CFG. For B=9, we want a graph with cset9(S,G). But this is the subgraph reachable from S[9,10]. A[6,7] A[8,8] A[9,10] A[11,∞] B[4,6] C[6,8] B[7 , ∞] C[9, ∞] D[3,5] D[6 , ∞] E[2 , ∞] F[5 , ∞] X G[1 , ∞] T[0 , ∞]
Complexity • Spatial Complexity • Duplication factor of each vertex u is upper-bounded 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 • 8 programs from the networking domain • Size is in instructions • Cyclic programs will be analyzed separately
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 Program Admission works! • Best used when: • Programs are small • Budgets are small and tight • Hardware model is tractable