280 likes | 423 Views
Explicit Preemption Placement f or Real-Time Conditional Code v ia Graph Grammars a nd Dynamic Programming. Bo Peng , Nathan Fisher, and Marko Bertogna Department of Computer Science, Wayne State University, USA Algorithmic Research Group, University of Modena, Italy. 1. 1. 2. 1. 2.
E N D
Explicit Preemption Placement for Real-TimeConditional Code via Graph Grammars and Dynamic Programming Bo Peng, Nathan Fisher, and Marko Bertogna Department of Computer Science, Wayne State University, USA Algorithmic Research Group, University of Modena, Italy 1 1 2 1 2 This research has been supported by US National Science Foundation and the European Commission.
Outline 2 Background Limited-preemption scheduling model in real -time code. Model Series-parallel flowgraphs. Problem Statement Optimize the WCET+CRPD of the flowgraphs. Solution Graph grammars; Dynamic programming.
Outline 3 Background Model Conclude the presentation Problem Statement Solution
Introduction • Background • Model • Problem Statement • Solutions • Conclusions 4 WCET+CRPD analysis Real-time schedulability analysis Reduce WCET+CRPD Limited preemption scheduling
Limited Preemption Scheduling CRPD • Cache evictions by preempting higher-priority tasks. • Background • Model • Problem Statement • Solutions • Conclusions 5 Reduce WCET when arbitrarily preempt • Precise upper bounds on the cache-related preemptiondelays (CRPD). • Delay the preemption to maintain a job's locality. Cache TAG A B Write B Cache reload Write A Read A Cache eviction
Limited Preemption Scheduling • Background • Model • Problem Statement • Solutions • Conclusions 6 Reduce WCET when arbitrarily preempt • Precise upper bounds on the cache-related preemptiondelays (CRPD). • Delay the preemption to maintain a job's locality. Our goal Reduce CRPD via limited preemption while preserving system schedulability.
Related Work • Background • Model • Problem Statement • Solutions • Conclusions 7 Preemption model Scheduling algorithm Code structure ?
Control flowgraph: : set of basic blocks (BBs) : set of edges : WCET function of BBs : CRPD function of edges : Potential Preemption Point : Effective Preemption Point Model • Background • Model • Problem Statement • Solutions • Conclusions 8
Model Series-parallel graphs: Observation Can handle "if else" and "switch" statements. • Background • Model • Problem Statement • Solutions • Conclusions 9 Graph Creation Series Composition Parallel Composition
Problem Statement • Background • Model • Problem Statement • Solutions • Conclusions 10 Series-parallel graphs Sum of selected edges' CRPD Choose the path with max WCET+CRPD Sum of BBs' WCET Upper bound of NPR from schedulability analysis NPR from e1 to
Problem Statement Find a selection of EPPs that minimizes the WCET+CRPD of a flowgraph. The cost of any non-preemptive region should less than Q. • Background • Model • Problem Statement • Solutions • Conclusions 11 Q=8 3 4 1 2 1 2 1 3 2 A C D F G H I B E 1 3 5 5 1 6 3 1 Optimal selection of EPPs insequential flowgraphs Bertogna et al.['11] Cost=7 Cost=7 Cost=7 Cost=3 Cost = 24
How about the previous algorithm for conditional structure? Problem Statement • Background • Model • Problem Statement • Solutions • Conclusions 12 Q=8 2 1 2 D F E 5 1 6 5 3 4 1 1 3 2 C A B J K L 1 3 3 1 7 5 1 2 3 G I H 1 6 WCET+CRPD • Upper path: 28 • Lower path: 25 • Combined result: 32(U) • Optimal result: 27(L) Observation • Previous algorithm is not optimal for conditional structure. • Use graph grammar and dynamic programming technique.
Graph Grammar Decompose control flowgraphs (Linear time parsing) Extended Backus-Naur Form (EBNF) • Background • Model • Problem Statement • Solutions • Conclusions 13
Dynamic Programming:Sequential Block Blocks contains and : Blocks only contains : A • Background • Model • Problem Statement • Solutions • Conclusions 14 <SB> Q=8 <SB> Cost matrices reflect optimal substructures 1 3 4 B 9/26/2014
Theorem Dynamic Programming:Conditional Block and Block Union Theorem <SB> Corollary 1 <SB> 3 4 (1)Preempt at the edge between the two blocks. Left block: cost[i][0]; Right block: cost[edge_value][j]; WCET+CRPD: cost[i][0]+ edge_value +cost[edge_value][j]. (2)Do not preempt at the edge between the two blocks. Leftblock: cost[i][x]; Rightblock: cost[Q-x][j]; x from 1to Q; WCET+CRPD: min{cost[i][x]+cost[Q-x][j]}. min{cost[i][x]+cost[Q-x][j]}. (3)Choose the smaller WCET+CRPD between (1) and (2) as cost[i][j] of the larger block. B A A optimal EPP selection of a larger block is combined by the optimal selections of left block and right block. A optimal EPP selection of a CB is combined by optimal selections of all sequential paths. Corollary (1)For each path Four possible situations: whether take the preemption before and after the middle block; Choose the min WCET+CRPD from thefour situations. (2)Choose the max WCET+CRPD among all paths. • Background • Model • Problem Statement • Solutions • Conclusions 15 (1) Get the optimal value of when preempt. Q=8 (2) Get the optimal value of when do not preempt. 2 1 2 D F E 5 1 6 5 3 4 1 1 3 2 C A B J K L 1 3 3 1 7 5 1 2 3 G I H 1 6
Dynamic Programming:Conditional Block and Block Union • Background • Model • Problem Statement • Solutions • Conclusions 16 Contribution In conditional structure: Optimal EPPs selection in pseudo-polynomial time. Q=8 2 1 2 D F E 5 1 6 5 3 4 1 1 3 2 C A B J K L 1 3 3 1 7 5 1 2 3 G I H 1 6
Approximate flexible matrix The WCET+CRPD will be larger than the optimal one. Reduce running time. Time complexity: An Alternative Heuristic • Background • Model • Problem Statement • Solutions • Conclusions 17 step each time 2 1 2 D F E 5 1 6 5 3 4 1 1 3 2 C A B J K L 1 3 3 1 7 5 1 2 3 G I H 1 6
Computational Complexity Consider parse tree and cost matrix: Optimal solution: Heuristic solution: • Background • Model • Problem Statement • Solutions • Conclusions 18
Randomly generate control flowgraphs: number of BBs. number of CBs. WCET of BBs: Gaussian distribution. CRPD: Correlates adjacent EPPs. Randomly generated with a gaussian factor. Simulations Similar to a realistic distribution Bertogna et al.['11] • Background • Model • Problem Statement • Solutions • Conclusions 19
Simulations: WCET WCET trend OPT (green mesh)<Alternative heuristic (black mesh)<SEQ (red mesh) • Background • Model • Problem Statement • Solutions • Conclusions 20 CRPD +
Simulations: Running time Time trend Alternative heuristic (black mesh) dominates over OPT and SEQ • Background • Model • Problem Statement • Solutions • Conclusions 21
Simulations: WCET Comparison of different setting for heuristics Smaller size of matrices does not significantly increase WCET+CRPD • Background • Model • Problem Statement • Solutions • Conclusions 22 CRPD +
Simulations: Running time Comparison of different setting for heuristics Smaller size of matrices significantly decreases running time • Background • Model • Problem Statement • Solutions • Conclusions 23
Additional Structure 24 (a) Loops: • Unrolled Loop • Non-Unrolled Loop (b) Function call: • Calculate the cost matrix of Fi • Embed Fito the main control flowgraph
Conlusions: Extend the structure to conditional blocks Optimal algorithm for selection of EPPs An alternative heuristic to reduce running time Exhaustive simulation Future work: Planar separator theory Parameterized theory NP-Completeness Conlusions and Future Work • Background • Model • Problem Statement • Solutions • Future Work 25 Do optimal algorithms using polynomial time exist? Or, is the problem NP-Complete?
Thanks! 26
Related Work 27
Additional Structure: Loops 28 (a) Non-Unrolled Loop: (b) Unrolled Loop: • Whether preempt at ei, ej, eloop: eight possible situations • Choose the smallest one as the value of the cost matrix • Preemption places inside the loop is not fixed • Integrate this structure to conditional structure