WCETAware Stack Frame Management of Embedded Systems using
WCET-Aware Stack Frame Management of Embedded Systems using Scratchpad Memories Yooseong Kim, Mohammad Khayatian, Aviral Shrivastava Arizona State University M C L
Hard Real-time Systems �Strict timing constraints � Tasks have deadlines to finish execution Sensing Deadlines! Actuation �Timing determines correctness, not just performance � Missing a deadline can be catastrophic! M C L Image credit: Jason. Paris@Flickr Web page: aviral. lab. asu. edu
Ensuring Timing Correctness � Guarantee the absence of missed deadlines Number of occurrences � Worst-case execution time (WCET) analysis Execution Time WCET � How? � Testing based on measurement � No Guarantee! � Static analysis � Use structural information of HW/SW Web page: aviral. lab. asu. edu M C L
Challenges of Static Timing Analyses �WCET is Pessimistic � Microarchitectural state uncertainties �Cache, branch predictors, pipelines, … All execution scenarios Frequency of occurrence Observed by testing Analysis pessimism Execution Times WCET observed by WCET testing Web page: aviral. lab. asu. edu WCET calculated by static analysis M C L
Scratchpad Memories (SPM) : A Promising Alternative �Raw directly-addressable SPM SRAM 0 � Explicitly controlled by DMA (Direct Memory Access) �Provide time predictability … DMA load A to 0 … DMA load B to 1 … DMA load C to 0 … 1 A A B C B � Determine a memory access is a hit or miss Can completely avoid preemption delay τ1 Web page: aviral. lab. asu. edu τ2 τ3 τ2 τ1 time M C L
Stack Frame Management �Perform code transformation � Store frame stack in SPM before a function call � Load frame stack from SPM after a function call Inserted code before a call DMA_store(); Sp_reset(); // DMA stores the stack in the main memory // reset the stack pointer Foo(); // call a function DMA_load(); Sp_restore(); // DMA loads the stack from the main memory // restore the stack pointer Inserted code after a call Web page: aviral. lab. asu. edu M C L
Virtual Stack in Main Memory �Moving stack frames needs previous execution history Previously evicted stack frames Main Memory SPM CPU Stack Evict/Restore stack frames by DMA Web page: aviral. lab. asu. edu M C L
Problem Formulation from CFG � A() { … B(); … } … B(); … return …; B() { … return; … } (a) Web page: aviral. lab. asu. edu (b) M C L
Formulate as a Minimization Problem � Web page: aviral. lab. asu. edu M C L
Decision Variable � Web page: aviral. lab. asu. edu M C L
Testbed � Web page: aviral. lab. asu. edu M C L
WCET and Memory Overhead m 1 lm lu s dc m m p at m u m lt in ve r st qu at r em t at e nt fft pi c cr ex qu rt m at e 2) st at e er t ul in v m p m m dc at m s lm lu 1 fft nt ex pi c cr s pr es cn t m co 00 or t 1 bs pc m 0% cn t es s 20% pr 40% m 60% CONFIG 100% 80% 60% 40% 20% 0% -20% co 80% Reduction in Memory access overhead COMPARING WITH LIU AND ZHANG (MEMORY Reduction in Cycles (%) 2) Reduction in WCET ad p bs cm or t 1 00 WITH LU ET AL. (MEMORY CONFIG Reduction in WCET st qu at r em t at e ul t in ve r qu st rt at em at e p m m at s dc m lu lm 1 t fft in ex p Reduction in Memory access overhead 100% ad Reduction in Cycles (%) COMPARING cr c co cnt m pr es s rt 1 bs o ad p 00 0% lm s dc m m p at m u m lt in ve r 20% 1) lu 40% CONFIG 100% 80% 60% 40% 20% 0% -20% cr c ex pi nt fft 1 60% WITH LIU AND ZHANG (MEMORY co cn m t pr es s 80% Reduction in WCET COMPARING Reduction in Cycles (%) 1) ad p bs cm or t 1 00 WITH LU ET AL. (MEMORY CONFIG 100% cm Reduction in Cycles (%) COMPARING Reduction in Memory access overhead Web page: aviral. lab. asu. edu Reduction in WCET Reduction in Memory access overhead M C L
Comparing with Caches Web page: aviral. lab. asu. edu M C L
Conclusion �We Proposed a technique to find optimal locations to perform stack management operations in order to minimize the WCET of a given program. �We allocate the whole Stack in SPM which simplifies the WCET analysis. �Up to 48% reduction in WCET is achieved. Web page: aviral. lab. asu. edu M C L
- Slides: 14