E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulati on F rank Mueller, David Whalley FSU DEPARTMENT OF COMPUTER SCIENCE Depa rtment of Computer Science Flo rida State Universit y T allahassee, FL 32304-4019 e-mail: mueller@cs.fsu.edu WWW: http://www.cs.fsu. edu /~mueller E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 1
Objective � p rovide faster cache p erfo rmance evaluation FSU DEPARTMENT OF COMPUTER SCIENCE - determine numb er of hits and misses of a p rogram execution - used to evaluate new cache designs - used to analyze new optimizati on techniques � p redict the caching b ehavio r (fo r real-time systems) E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 2
Metho ds in Contrast � Goal: faster cache p erfo rmance evaluation � traditional app roach: inline tracing - instrument p rogram on complement of min. spanning tree FSU - generate trace addresses DEPARTMENT OF COMPUTER SCIENCE - simulate caches based on trace � our app roach: on-the-�y analysis - analyze p rogram statically (static cache simulation) - instrument p rogram on \unique paths" - do NOT generate trace addresses - simulate remaining cache b ehavio r within p rogram execution E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 3
Small Set of Measurement P oints � covers all events and p reserves their o rder during execution � applicable fo r any on-the-�y analysis of p rogram b ehavio r � cannot use min. spanning tree if o rder of events critical FSU DEPARTMENT OF COMPUTER SCIENCE � need new metho d to �nd a small set of measure p oints � pa rtition control-�o w graph into unique paths: - unique transition fo r each path to place instrumentation co de - path contains sequence of basic blo cks in control �o w - blo cks in path not necessa rily consecutive co de - set of blo cks determines p o rtion of p rogram fo r static anal- ysis E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 4
De�nition of Unique P ath P a rtitioning (UPP A) 1. all vertices covered b y paths FSU 2. edges a re either in paths o r connect paths DEPARTMENT OF COMPUTER SCIENCE 3. each path has unique edge o r vertex 4. paths overlap only in initial o r �nal subpaths 5. paths a re chained p rop erly 6. calls terminate paths (op erational) 7. paths do not cross lo op b ounda ries (op erational) E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 5
Prop erties of UPP As FSU DEPARTMENT OF COMPUTER SCIENCE � basic blo ck pa rtitioning is a UPP A � Let j U P P A j denote numb er of paths in pa rtitioning � o rdering: U P P A < U P P A := j U P P A j < j U P P A j a a b b � goal: �nd minimal UPP A fo r a given control-�o w graph E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 6
FSU DEPARTMENT OF COMPUTER SCIENCE path 2 path 4 3 6 path 5 1 4 5 7 8 path 3 E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 7 path 1 2
Computation of a Small UPP A FSU 1. ma rk initial head and tail vertices DEPARTMENT OF COMPUTER SCIENCE 2. WHILE change DO (a) p ropagate heads and tails (b) fo r each new head vertex, �nd fo rk after join 3. UPP A = collect each path b et w een a head and a tail vertex E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 8
Example: Join follo w ed b y F o rk FSU DEPARTMENT OF COMPUTER SCIENCE join E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 9 tail fork head head
Example 1: Algo rithmic Construction of a Small UPP A FSU DEPARTMENT OF COMPUTER SCIENCE head head head 1 1 1 tail tail head head head 2 2 2 3 4 3 4 3 4 E�cient On-the-�y Analysis 5 of Program Behavio r and Static Cache Simulation 5 SAS'94 5 10 6 6 6 tail tail tail head head 7 7 7 tail tail tail
Example 2: Algo rithmic Construction of a Small UPP A FSU DEPARTMENT OF COMPUTER SCIENCE head head head 1 1 1 2 3 2 3 2 3 tail tail head 4 4 4 E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 11 tail tail head head 5 6 5 6 5 6 tail tail tail tail tail tail
Prop erties of the Algo rithm FSU � co rrectness p roved DEPARTMENT OF COMPUTER SCIENCE � minimal UPP A ) optimal on-the-�y analysis ?? - de�ne equivalence class of same-o rder UPP As - sho w that algo rithm constructs one such UPP A - sho w that no smaller UPP As exist E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 12
F unction-Instance Graph � decomp osition of call graph acco rding to call sites FSU DEPARTMENT OF COMPUTER SCIENCE � useful fo r inter-p ro cedural analysis in general � used here fo r static cache simulation � p rovides mo re detailed info rmation ab out a function instance � many applications: alias analysis, caller-save, inlining � sp ecial transitions to recognize recursion E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 13
Example of F unction-Instance Graph FSU DEPARTMENT OF COMPUTER SCIENCE Call Graph Function Instance Graph f f 0 g h g h h 0 0 1 E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 14 k i k i k k 1 2 0 0
P erfo rmance Evaluation FSU DEPARTMENT OF COMPUTER SCIENCE � UPP As and function instances vs. basic blo ck pa rtitioning � static savings: 24% few er measurement p oints � dynamic savings: 31% few er measurement p oints E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 15
What is Static Cache Simulation? � new app roach to analyze cache b ehavio r of p rograms statically FSU DEPARTMENT OF COMPUTER SCIENCE � applied to instruction caches (w o rking on data caches) � addresses of instructions kno wn statically � uses data-�o w analysis of call graph and control �o w � catego rizes each instruction � p redicts la rge p o rtion of instruction cache references E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 16
Instruction Catego rization � transfo rms call graph into function-instance graph (FIG) � p erfo rms analysis on FIG and UPP As � uses data-�o w analysis algo rithms fo r p rediction FSU DEPARTMENT OF COMPUTER SCIENCE � abstract cache state : p otentially cached p rogram lines � reaching state : reachable p rogram lines � catego ries based on these states: - alw a ys hit - alw a ys miss - �rst miss: miss on �rst reference, hit on consecutive ones - con�ict: either hit o r miss (dynamic) E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 17
E�cient main() FSU 1 a-miss a-hit program line 0 On-the-�y a-hit call foo() a-hit Analysis 2 a-miss of a-hit Program program line 1 3 conflict Behavio a-hit f-miss r and Static 4 a-hit program line 2 a-hit Cache a-hit Simulation 5 f-miss DEPARTMENT OF COMPUTER SCIENCE call foo() a-hit program line 3 6 f-miss a-hit SAS'94 7 a-hit a-hit program line 4 return a-hit (a) (b) foo() 8 a-miss a-hit a-miss a-miss program line 5 return a-hit a-hit 18
F rank Mueller, David Whalley SAS'94 � 4 cache lines � 16 b ytes p er line (4 instructions) � instances fo o (a) blo ck 8a and (b) blo ck 8b � 7(1): alw a ys hit, spacial lo calit y � 8b(1): alw a ys hit, temp o ral lo calit y � 3(3): �rst miss � 5(1) and 6(1): group �rst miss � 3(1): con�ict with 8b(2) conditionally executed E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation (notes) 18-1
F ast Instruction Cache P erfo rmance Analysis � uses e�cient on-the-�y analysis FSU DEPARTMENT OF COMPUTER SCIENCE � p erfo rms static instruction cache simulation � instruments p rogram � p rovides accurate cache p erfo rmance measurements � instrumented p rogram has only 1.2 to 2.2 execution overhead � faster than any other cache analysis metho d published so fa r E�cient On-the-�y Analysis of Program Behavio r and Static Cache Simulation SAS'94 19
Recommend
More recommend