SlideShare a Scribd company logo
1 of 54
Download to read offline
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Paper Presentation: Efficient Path Profiling
Paper Author: Thomas Ball, James R. Larus
Aakriti Gupta
Topics in software bug detection
Instructor: Prof. M. K. Ramanathan
Indian Institute of Science
aakriti@cadl.iisc.ernet.in

January 20, 2014
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Path Profiling

How often does a control flow path execute?

Experimental Results
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Path Profiling

How often does a control flow path execute?
Used in program performance tuning, profile-directed
compilation and software test coverage etc.

Experimental Results
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Path Profiling

How often does a control flow path execute?
Used in program performance tuning, profile-directed
compilation and software test coverage etc.
Before this, basic block and control flow edge profiling were
used. Path profiling was assumed to be much more costly.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Path Profiling

How often does a control flow path execute?
Used in program performance tuning, profile-directed
compilation and software test coverage etc.
Before this, basic block and control flow edge profiling were
used. Path profiling was assumed to be much more costly.
This paper shows that accurate path profiling overhead is only
twice as compared to efficient edge profiling.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Path Profiling vs. Edge Profiling
A
150
120

Path
100

B

C

20
250
D

270
110

160
E

160

Prof1

Prof2

ACDF
ACDEF
ABCDF
ABCDEF
ABDF
ABDEF

90
60
0
100
20
0

110
40
0
100
0
20

F

Can’t uniquely identify path profile using edge profile
Vice versa is possible.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Edge Profiling Instrumentation
A

Edge

Value

AC
BC
BD
DE
AB
CD
DF
EF
FA

v
u
t
w
u+t
u+v
u+v+t-w
w
u+v+t

v++

u++

B

C

t++

D

w++
E

F

Many variables need to be stored; causes increased memory
accesses.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Path Profiling Instrumentation
A
r=0

Path
r=2

B

C

r=4

D

count[r]++
r+=1
E

Encoding

ACDF
ACDEF
ABCDF
ABCDEF
ABDF
ABDEF

0
1
2
3
4
5

F

Each path from A to F produces a unique state in register r, which
have been used as an index into an array of counters in block F.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Optimal Path Profiling
A
A
1
0
2

B

5
B

-2

A

C

C

0
1

4

+1

B

D
D

C

+3
-1

+1
E
E

D

F

F
+1

Optimal
4 instrumented
edges
Max 2 along a
path

4 instrumented
edges
Max along a
path can be
more than 2
(ABCDF)

E

F

5 instrumented
edges
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Step 1: Edge Assignment

Assign a non-negative constant value to each edge, such that
the sum of values along any path from ENTRY to EXIT is
unique.
Path sums should lie in the range 0 to (number of paths - 1).
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Edge Assignment Algorithm
Algorithm 1 for assigning values to
edges in a DAG.
1: for each vertex v in reverse topological order do
2:
if v is a leaf vertex then
3:
NPaths[v ] = 1
4:
else
5:
NPaths[v ] = 0
6:
for each edge e from v to w do
7:
val(e) = NPaths[v ]
8:
NPaths[v ]+ = NPaths[w ]
9:
end for
10:
end if
11: end for

A
0
2
0

B

C

2
0
D
0
1
E

0

F

Edge Assignment Output
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Step 2: Edge Selection (Maximal Spanning Tree)

Weigh edges by
execution frequency
(Edge Profiling is a
pre-requisite?)

A

B

C

Find maximal cost
spanning tree
D

This gives minimal
cost set of the chords
Maximal spanning
tree instruments least
traveled edges

E

F

Experimental Results
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Step 2: Edge Selection (Event Counting Algorithm)
In the tree found, put the edge assignments as per step 1. Now
one by one add a chord and note the weight of the cycle thus
formed. This will serve as the given chord’s instrumentation value.
A

A

A

0
2

0
B

2

2

B

2

0

B

C

C
4

D

2

0

0

D
F

D
0
1
E

0

F

Graph from step 1

Cycle weight = 4,
therefore BD is
instrumented with
value 4

1
E

F

Final result after
step 2
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Step 3: Instrumentation
PRELUDE :- Array of counters allocated and initialized to 0
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Step 3: Instrumentation
PRELUDE :- Array of counters allocated and initialized to 0
POSTLUDE :- Array is written out to permanent storage
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Step 3: Instrumentation
PRELUDE :- Array of counters allocated and initialized to 0
POSTLUDE :- Array is written out to permanent storage
ENTRY node :- Initialize r := 0
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Step 3: Instrumentation
PRELUDE :- Array of counters allocated and initialized to 0
POSTLUDE :- Array is written out to permanent storage
ENTRY node :- Initialize r := 0
CHORDS :- Update r += Inc(chord)
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Step 3: Instrumentation
PRELUDE :- Array of counters allocated and initialized to 0
POSTLUDE :- Array is written out to permanent storage
ENTRY node :- Initialize r := 0
CHORDS :- Update r += Inc(chord)
EXIT node :- Increment path counter count[r]++
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Step 3: Instrumentation
PRELUDE :- Array of counters allocated and initialized to 0
POSTLUDE :- Array is written out to permanent storage
ENTRY node :- Initialize r := 0
CHORDS :- Update r += Inc(chord)
EXIT node :- Increment path counter count[r]++
To avoid ENTRY node initialization
A chord ’c’ may initialize iff it is the first chord in every path from
ENTRY to EXIT containing ’c’.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Step 3: Instrumentation
PRELUDE :- Array of counters allocated and initialized to 0
POSTLUDE :- Array is written out to permanent storage
ENTRY node :- Initialize r := 0
CHORDS :- Update r += Inc(chord)
EXIT node :- Increment path counter count[r]++
To avoid ENTRY node initialization
A chord ’c’ may initialize iff it is the first chord in every path from
ENTRY to EXIT containing ’c’.
To avoid EXIT node updation
A chord ’c’ may update count[r+Inc(c)]++ iff it is the last chord
in every path from ENTRY to EXIT containing ’c’.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Step 3: Instrumentation Output

A

r=0

r=2

B

C

r=4

D
count[r]++

count[r+1]++
E

F

Experimental Results
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Step 4: Path Generation
Given ’r’ and the control flow graph from step 1, start from entry
vertex and choose the next edge ’e’ such that largest val(e) is less
than or equal to r. Make r = r - val(e) and proceed.
Suppose r = 3.

A

AB: r = 3-2 = 1

0
2
0

B

C

CD: r = 1

2
0

DE: r = 1-1 = 0

D

EF: r = 0

0
1
E

AB: r = 1

0

F

Hence, path corresponding to r=3 is
ABCDEF.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Dealing with Arbitrary Control Flow Graphs

The algorithm discussed is capabale of dealing only with
DAGs (Directed Acyclic Graphs)
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Dealing with Arbitrary Control Flow Graphs

The algorithm discussed is capabale of dealing only with
DAGs (Directed Acyclic Graphs)
But control flow graphs generally contains cycles
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Dealing with Arbitrary Control Flow Graphs

The algorithm discussed is capabale of dealing only with
DAGs (Directed Acyclic Graphs)
But control flow graphs generally contains cycles
With unbounded number of paths, which path to track?
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Dealing with Arbitrary Control Flow Graphs

The algorithm discussed is capabale of dealing only with
DAGs (Directed Acyclic Graphs)
But control flow graphs generally contains cycles
With unbounded number of paths, which path to track?
Approach: Break cycles at loop backedge.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Dealing with Arbitrary Control Flow Graphs

The algorithm discussed is capabale of dealing only with
DAGs (Directed Acyclic Graphs)
But control flow graphs generally contains cycles
With unbounded number of paths, which path to track?
Approach: Break cycles at loop backedge.
Instrument each backedge with [count[r]++; r=0], which
records the path upto the backedge and prepares to record the
path after the backedge.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Possible Paths

ENTRY
LOOPHEAD(w )

ENTRY

LOOPHEAD(w )
LOOPHEAD(w )
LOOPHEAD(y )

EXIT
EXIT
v

ENTRY to
EXIT

x

ENTRY to v,
then
backedge v
to w.

w to x, then
backedge x
to y.

v to w, then
w to EXIT.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Instrumenting Backedges: Example
A

r=0

B
4
2
C

D
count[r]++; r=0

E

F
1

count[r]++

G

H

I

This assignment
does not ensure
unique path values.
Example: BCE,
ABCE, ABCEFGI
and BCEFGI all
have value 2.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Solution

For each vertex v that is a target of any backedge, add a
dummy edge ENTRY to v.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Solution

For each vertex v that is a target of any backedge, add a
dummy edge ENTRY to v.
For each vertex w that is a source of any backedge, add a
dummy edge w to EXIT.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Solution

For each vertex v that is a target of any backedge, add a
dummy edge ENTRY to v.
For each vertex w that is a source of any backedge, add a
dummy edge w to EXIT.
Eliminate all backedges except EXIT to ENTRY.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Solution

For each vertex v that is a target of any backedge, add a
dummy edge ENTRY to v.
For each vertex w that is a source of any backedge, add a
dummy edge w to EXIT.
Eliminate all backedges except EXIT to ENTRY.
Apply first two steps of Path Profiling Algo (Edge value
assignment and chord increment).
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

After applying transformation and Edge value assignment
A

8

2

B
3
0
0

C

D

E

0
F
1
0
G

H

I

2
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

After computing chord increments
A(r = 0)
-6
B
13
10
C

2

D
r=0; count[r]++

E

F
-1
-2
count[r]++

G

H

I

’r’ uniquely
determines a
path now.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Dealing with Self Loops

Self loops are backedges with same source and target vertex.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Dealing with Self Loops

Self loops are backedges with same source and target vertex.
We can’t just remove them as it leaves nothing for
instrumentation.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Dealing with Self Loops

Self loops are backedges with same source and target vertex.
We can’t just remove them as it leaves nothing for
instrumentation.
Approach: Add a counter along them to record the number of
times they execute.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Optimizations

Instead of storing r as index into the count array, make it a
pointer. (saves 2 instructions per path)
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Optimizations

Instead of storing r as index into the count array, make it a
pointer. (saves 2 instructions per path)
Initialize r with base address of the array and do pointer
arithmetic when r is updated.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Optimizations

Instead of storing r as index into the count array, make it a
pointer. (saves 2 instructions per path)
Initialize r with base address of the array and do pointer
arithmetic when r is updated.
This optimization, however reduces the range of increments.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Optimizations

Instead of storing r as index into the count array, make it a
pointer. (saves 2 instructions per path)
Initialize r with base address of the array and do pointer
arithmetic when r is updated.
This optimization, however reduces the range of increments.
In step 1, we can choose edges (v,w) such that NumPath[w] is
max of the set to reduce the range of increments.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Example

A

A

2

0
5

0

4

B

D
C

1

B

D
C

numPaths[B] = 1; numPaths[C] = 1; numPaths[D] = 4.

Experimental Results
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Path profiling overhead - 30.9% (5.5 to 96.9%).

Experimental Results
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Path profiling overhead - 30.9% (5.5 to 96.9%).
Edge profiling overhead - 16.1% (-2.6 to 52.8%).

Experimental Results
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Path profiling overhead - 30.9% (5.5 to 96.9%).
Edge profiling overhead - 16.1% (-2.6 to 52.8%).
Programs with litte hashing have comparable or lower
overhead.

Experimental Results
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Experimental Results

Path profiling overhead - 30.9% (5.5 to 96.9%).
Edge profiling overhead - 16.1% (-2.6 to 52.8%).
Programs with litte hashing have comparable or lower
overhead.
Programs with considerable hashing have lower overheads if
they have large blocks or longer paths and infrequent
execution of path increments.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Experimental Results
Results of comparing path predicted from edge profiling
against measured paths.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Experimental Results
Results of comparing path predicted from edge profiling
against measured paths.
Prediction approach: Use the most frequently executed edge
out of a block.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Experimental Results
Results of comparing path predicted from edge profiling
against measured paths.
Prediction approach: Use the most frequently executed edge
out of a block.
On average 37.9% (4.3-57.1%) paths correctly predicted.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Experimental Results
Results of comparing path predicted from edge profiling
against measured paths.
Prediction approach: Use the most frequently executed edge
out of a block.
On average 37.9% (4.3-57.1%) paths correctly predicted.
Also computed the length of the predicted path upto first
mispredicted edge.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Experimental Results
Results of comparing path predicted from edge profiling
against measured paths.
Prediction approach: Use the most frequently executed edge
out of a block.
On average 37.9% (4.3-57.1%) paths correctly predicted.
Also computed the length of the predicted path upto first
mispredicted edge.
Weighted by the execution frequency, predicted paths were
nearly as good as measured paths (5.1 vs 6.9) but contained
fewer instructions (33.6 vs 88.4).
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Optimizations

Experimental Results

Experimental Results
Results of comparing path predicted from edge profiling
against measured paths.
Prediction approach: Use the most frequently executed edge
out of a block.
On average 37.9% (4.3-57.1%) paths correctly predicted.
Also computed the length of the predicted path upto first
mispredicted edge.
Weighted by the execution frequency, predicted paths were
nearly as good as measured paths (5.1 vs 6.9) but contained
fewer instructions (33.6 vs 88.4).
Result is attributed to simple nature of benchmarks.
Consistent with: branches typically follow one direction with
high probability which remains same for different input.
Path Profiling

Path Profiling Algorithm

Arbitrary Control Flow Graph

Thank you.

Optimizations

Experimental Results

More Related Content

Similar to Efficient path profiling

Algorithm analysis and design
Algorithm analysis and designAlgorithm analysis and design
Algorithm analysis and designMegha V
 
Making Custom Oscilloscope Measurements
Making Custom Oscilloscope MeasurementsMaking Custom Oscilloscope Measurements
Making Custom Oscilloscope Measurementsteledynelecroy
 
7-White Box Testing.ppt
7-White Box Testing.ppt7-White Box Testing.ppt
7-White Box Testing.pptHirenderPal
 
IAP presentation-1.pptx
IAP presentation-1.pptxIAP presentation-1.pptx
IAP presentation-1.pptxHirazNor
 
TMPA-2017: The Quest for Average Response Time
TMPA-2017: The Quest for Average Response TimeTMPA-2017: The Quest for Average Response Time
TMPA-2017: The Quest for Average Response TimeIosif Itkin
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhPankaj Thakur
 
detail of flowchart and algorithm that are used in programmingpdf
detail of flowchart and algorithm that are used in programmingpdfdetail of flowchart and algorithm that are used in programmingpdf
detail of flowchart and algorithm that are used in programmingpdfssuserf86fba
 
Algorithm Flowchart Manual ALGORITHM FLOWCHART MANUAL For STUDENTS
Algorithm   Flowchart Manual ALGORITHM   FLOWCHART MANUAL For STUDENTSAlgorithm   Flowchart Manual ALGORITHM   FLOWCHART MANUAL For STUDENTS
Algorithm Flowchart Manual ALGORITHM FLOWCHART MANUAL For STUDENTSAlicia Edwards
 
Arima model (time series)
Arima model (time series)Arima model (time series)
Arima model (time series)Kumar P
 
Robust and Tuneable Family of Gossiping Algorithms
Robust and Tuneable Family of Gossiping AlgorithmsRobust and Tuneable Family of Gossiping Algorithms
Robust and Tuneable Family of Gossiping AlgorithmsVincenzo De Florio
 
A Dynamic Logistic Dispatching System With Set-Based Particle Swarm Optimization
A Dynamic Logistic Dispatching System With Set-Based Particle Swarm OptimizationA Dynamic Logistic Dispatching System With Set-Based Particle Swarm Optimization
A Dynamic Logistic Dispatching System With Set-Based Particle Swarm OptimizationRajib Roy
 
Meeting w10 chapter 3 part 3
Meeting w10   chapter 3 part 3Meeting w10   chapter 3 part 3
Meeting w10 chapter 3 part 3Hattori Sidek
 
Adjusting PageRank parameters and comparing results : REPORT
Adjusting PageRank parameters and comparing results : REPORTAdjusting PageRank parameters and comparing results : REPORT
Adjusting PageRank parameters and comparing results : REPORTSubhajit Sahu
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithmDevaKumari Vijay
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basicsayeshasafdar8
 
Effective data pre-processing for AutoML
Effective data pre-processing for AutoMLEffective data pre-processing for AutoML
Effective data pre-processing for AutoMLJoseph Giovanelli
 

Similar to Efficient path profiling (20)

Algorithm analysis and design
Algorithm analysis and designAlgorithm analysis and design
Algorithm analysis and design
 
Making Custom Oscilloscope Measurements
Making Custom Oscilloscope MeasurementsMaking Custom Oscilloscope Measurements
Making Custom Oscilloscope Measurements
 
7-White Box Testing.ppt
7-White Box Testing.ppt7-White Box Testing.ppt
7-White Box Testing.ppt
 
IAP presentation-1.pptx
IAP presentation-1.pptxIAP presentation-1.pptx
IAP presentation-1.pptx
 
TMPA-2017: The Quest for Average Response Time
TMPA-2017: The Quest for Average Response TimeTMPA-2017: The Quest for Average Response Time
TMPA-2017: The Quest for Average Response Time
 
White Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR ChandigarhWhite Box testing by Pankaj Thakur, NITTTR Chandigarh
White Box testing by Pankaj Thakur, NITTTR Chandigarh
 
detail of flowchart and algorithm that are used in programmingpdf
detail of flowchart and algorithm that are used in programmingpdfdetail of flowchart and algorithm that are used in programmingpdf
detail of flowchart and algorithm that are used in programmingpdf
 
Algorithm Flowchart Manual ALGORITHM FLOWCHART MANUAL For STUDENTS
Algorithm   Flowchart Manual ALGORITHM   FLOWCHART MANUAL For STUDENTSAlgorithm   Flowchart Manual ALGORITHM   FLOWCHART MANUAL For STUDENTS
Algorithm Flowchart Manual ALGORITHM FLOWCHART MANUAL For STUDENTS
 
Algorithm manual
Algorithm manualAlgorithm manual
Algorithm manual
 
Arima model (time series)
Arima model (time series)Arima model (time series)
Arima model (time series)
 
Robust and Tuneable Family of Gossiping Algorithms
Robust and Tuneable Family of Gossiping AlgorithmsRobust and Tuneable Family of Gossiping Algorithms
Robust and Tuneable Family of Gossiping Algorithms
 
A Dynamic Logistic Dispatching System With Set-Based Particle Swarm Optimization
A Dynamic Logistic Dispatching System With Set-Based Particle Swarm OptimizationA Dynamic Logistic Dispatching System With Set-Based Particle Swarm Optimization
A Dynamic Logistic Dispatching System With Set-Based Particle Swarm Optimization
 
Meeting w10 chapter 3 part 3
Meeting w10   chapter 3 part 3Meeting w10   chapter 3 part 3
Meeting w10 chapter 3 part 3
 
Adjusting PageRank parameters and comparing results : REPORT
Adjusting PageRank parameters and comparing results : REPORTAdjusting PageRank parameters and comparing results : REPORT
Adjusting PageRank parameters and comparing results : REPORT
 
Digital design chap 6
Digital design  chap 6Digital design  chap 6
Digital design chap 6
 
Introduction to design and analysis of algorithm
Introduction to design and analysis of algorithmIntroduction to design and analysis of algorithm
Introduction to design and analysis of algorithm
 
Data structures algorithms basics
Data structures   algorithms basicsData structures   algorithms basics
Data structures algorithms basics
 
Mvs adas
Mvs adasMvs adas
Mvs adas
 
Internet
InternetInternet
Internet
 
Effective data pre-processing for AutoML
Effective data pre-processing for AutoMLEffective data pre-processing for AutoML
Effective data pre-processing for AutoML
 

Recently uploaded

Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxAvyJaneVismanos
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...M56BOOKSTORE PRODUCT/SERVICE
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...jaredbarbolino94
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerunnathinaik
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaVirag Sontakke
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxJiesonDelaCerna
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentInMediaRes1
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Celine George
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfSumit Tiwari
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitolTechU
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxsocialsciencegdgrohi
 

Recently uploaded (20)

Final demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptxFinal demo Grade 9 for demo Plan dessert.pptx
Final demo Grade 9 for demo Plan dessert.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
KSHARA STURA .pptx---KSHARA KARMA THERAPY (CAUSTIC THERAPY)————IMP.OF KSHARA ...
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...Historical philosophical, theoretical, and legal foundations of special and i...
Historical philosophical, theoretical, and legal foundations of special and i...
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
9953330565 Low Rate Call Girls In Rohini Delhi NCR
9953330565 Low Rate Call Girls In Rohini  Delhi NCR9953330565 Low Rate Call Girls In Rohini  Delhi NCR
9953330565 Low Rate Call Girls In Rohini Delhi NCR
 
internship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developerinternship ppt on smartinternz platform as salesforce developer
internship ppt on smartinternz platform as salesforce developer
 
Painted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of IndiaPainted Grey Ware.pptx, PGW Culture of India
Painted Grey Ware.pptx, PGW Culture of India
 
CELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptxCELL CYCLE Division Science 8 quarter IV.pptx
CELL CYCLE Division Science 8 quarter IV.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Meghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media ComponentMeghan Sutherland In Media Res Media Component
Meghan Sutherland In Media Res Media Component
 
Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17Computed Fields and api Depends in the Odoo 17
Computed Fields and api Depends in the Odoo 17
 
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdfEnzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
Enzyme, Pharmaceutical Aids, Miscellaneous Last Part of Chapter no 5th.pdf
 
Capitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptxCapitol Tech U Doctoral Presentation - April 2024.pptx
Capitol Tech U Doctoral Presentation - April 2024.pptx
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)ESSENTIAL of (CS/IT/IS) class 06 (database)
ESSENTIAL of (CS/IT/IS) class 06 (database)
 
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptxHistory Class XII Ch. 3 Kinship, Caste and Class (1).pptx
History Class XII Ch. 3 Kinship, Caste and Class (1).pptx
 

Efficient path profiling

  • 1. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Paper Presentation: Efficient Path Profiling Paper Author: Thomas Ball, James R. Larus Aakriti Gupta Topics in software bug detection Instructor: Prof. M. K. Ramanathan Indian Institute of Science aakriti@cadl.iisc.ernet.in January 20, 2014
  • 2. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Path Profiling How often does a control flow path execute? Experimental Results
  • 3. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Path Profiling How often does a control flow path execute? Used in program performance tuning, profile-directed compilation and software test coverage etc. Experimental Results
  • 4. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Path Profiling How often does a control flow path execute? Used in program performance tuning, profile-directed compilation and software test coverage etc. Before this, basic block and control flow edge profiling were used. Path profiling was assumed to be much more costly.
  • 5. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Path Profiling How often does a control flow path execute? Used in program performance tuning, profile-directed compilation and software test coverage etc. Before this, basic block and control flow edge profiling were used. Path profiling was assumed to be much more costly. This paper shows that accurate path profiling overhead is only twice as compared to efficient edge profiling.
  • 6. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Path Profiling vs. Edge Profiling A 150 120 Path 100 B C 20 250 D 270 110 160 E 160 Prof1 Prof2 ACDF ACDEF ABCDF ABCDEF ABDF ABDEF 90 60 0 100 20 0 110 40 0 100 0 20 F Can’t uniquely identify path profile using edge profile Vice versa is possible.
  • 7. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Edge Profiling Instrumentation A Edge Value AC BC BD DE AB CD DF EF FA v u t w u+t u+v u+v+t-w w u+v+t v++ u++ B C t++ D w++ E F Many variables need to be stored; causes increased memory accesses.
  • 8. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Path Profiling Instrumentation A r=0 Path r=2 B C r=4 D count[r]++ r+=1 E Encoding ACDF ACDEF ABCDF ABCDEF ABDF ABDEF 0 1 2 3 4 5 F Each path from A to F produces a unique state in register r, which have been used as an index into an array of counters in block F.
  • 9. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Optimal Path Profiling A A 1 0 2 B 5 B -2 A C C 0 1 4 +1 B D D C +3 -1 +1 E E D F F +1 Optimal 4 instrumented edges Max 2 along a path 4 instrumented edges Max along a path can be more than 2 (ABCDF) E F 5 instrumented edges
  • 10. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Step 1: Edge Assignment Assign a non-negative constant value to each edge, such that the sum of values along any path from ENTRY to EXIT is unique. Path sums should lie in the range 0 to (number of paths - 1).
  • 11. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Edge Assignment Algorithm Algorithm 1 for assigning values to edges in a DAG. 1: for each vertex v in reverse topological order do 2: if v is a leaf vertex then 3: NPaths[v ] = 1 4: else 5: NPaths[v ] = 0 6: for each edge e from v to w do 7: val(e) = NPaths[v ] 8: NPaths[v ]+ = NPaths[w ] 9: end for 10: end if 11: end for A 0 2 0 B C 2 0 D 0 1 E 0 F Edge Assignment Output
  • 12. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Step 2: Edge Selection (Maximal Spanning Tree) Weigh edges by execution frequency (Edge Profiling is a pre-requisite?) A B C Find maximal cost spanning tree D This gives minimal cost set of the chords Maximal spanning tree instruments least traveled edges E F Experimental Results
  • 13. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Step 2: Edge Selection (Event Counting Algorithm) In the tree found, put the edge assignments as per step 1. Now one by one add a chord and note the weight of the cycle thus formed. This will serve as the given chord’s instrumentation value. A A A 0 2 0 B 2 2 B 2 0 B C C 4 D 2 0 0 D F D 0 1 E 0 F Graph from step 1 Cycle weight = 4, therefore BD is instrumented with value 4 1 E F Final result after step 2
  • 14. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Step 3: Instrumentation PRELUDE :- Array of counters allocated and initialized to 0
  • 15. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Step 3: Instrumentation PRELUDE :- Array of counters allocated and initialized to 0 POSTLUDE :- Array is written out to permanent storage
  • 16. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Step 3: Instrumentation PRELUDE :- Array of counters allocated and initialized to 0 POSTLUDE :- Array is written out to permanent storage ENTRY node :- Initialize r := 0
  • 17. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Step 3: Instrumentation PRELUDE :- Array of counters allocated and initialized to 0 POSTLUDE :- Array is written out to permanent storage ENTRY node :- Initialize r := 0 CHORDS :- Update r += Inc(chord)
  • 18. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Step 3: Instrumentation PRELUDE :- Array of counters allocated and initialized to 0 POSTLUDE :- Array is written out to permanent storage ENTRY node :- Initialize r := 0 CHORDS :- Update r += Inc(chord) EXIT node :- Increment path counter count[r]++
  • 19. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Step 3: Instrumentation PRELUDE :- Array of counters allocated and initialized to 0 POSTLUDE :- Array is written out to permanent storage ENTRY node :- Initialize r := 0 CHORDS :- Update r += Inc(chord) EXIT node :- Increment path counter count[r]++ To avoid ENTRY node initialization A chord ’c’ may initialize iff it is the first chord in every path from ENTRY to EXIT containing ’c’.
  • 20. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Step 3: Instrumentation PRELUDE :- Array of counters allocated and initialized to 0 POSTLUDE :- Array is written out to permanent storage ENTRY node :- Initialize r := 0 CHORDS :- Update r += Inc(chord) EXIT node :- Increment path counter count[r]++ To avoid ENTRY node initialization A chord ’c’ may initialize iff it is the first chord in every path from ENTRY to EXIT containing ’c’. To avoid EXIT node updation A chord ’c’ may update count[r+Inc(c)]++ iff it is the last chord in every path from ENTRY to EXIT containing ’c’.
  • 21. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Step 3: Instrumentation Output A r=0 r=2 B C r=4 D count[r]++ count[r+1]++ E F Experimental Results
  • 22. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Step 4: Path Generation Given ’r’ and the control flow graph from step 1, start from entry vertex and choose the next edge ’e’ such that largest val(e) is less than or equal to r. Make r = r - val(e) and proceed. Suppose r = 3. A AB: r = 3-2 = 1 0 2 0 B C CD: r = 1 2 0 DE: r = 1-1 = 0 D EF: r = 0 0 1 E AB: r = 1 0 F Hence, path corresponding to r=3 is ABCDEF.
  • 23. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Dealing with Arbitrary Control Flow Graphs The algorithm discussed is capabale of dealing only with DAGs (Directed Acyclic Graphs)
  • 24. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Dealing with Arbitrary Control Flow Graphs The algorithm discussed is capabale of dealing only with DAGs (Directed Acyclic Graphs) But control flow graphs generally contains cycles
  • 25. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Dealing with Arbitrary Control Flow Graphs The algorithm discussed is capabale of dealing only with DAGs (Directed Acyclic Graphs) But control flow graphs generally contains cycles With unbounded number of paths, which path to track?
  • 26. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Dealing with Arbitrary Control Flow Graphs The algorithm discussed is capabale of dealing only with DAGs (Directed Acyclic Graphs) But control flow graphs generally contains cycles With unbounded number of paths, which path to track? Approach: Break cycles at loop backedge.
  • 27. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Dealing with Arbitrary Control Flow Graphs The algorithm discussed is capabale of dealing only with DAGs (Directed Acyclic Graphs) But control flow graphs generally contains cycles With unbounded number of paths, which path to track? Approach: Break cycles at loop backedge. Instrument each backedge with [count[r]++; r=0], which records the path upto the backedge and prepares to record the path after the backedge.
  • 28. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Possible Paths ENTRY LOOPHEAD(w ) ENTRY LOOPHEAD(w ) LOOPHEAD(w ) LOOPHEAD(y ) EXIT EXIT v ENTRY to EXIT x ENTRY to v, then backedge v to w. w to x, then backedge x to y. v to w, then w to EXIT.
  • 29. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Instrumenting Backedges: Example A r=0 B 4 2 C D count[r]++; r=0 E F 1 count[r]++ G H I This assignment does not ensure unique path values. Example: BCE, ABCE, ABCEFGI and BCEFGI all have value 2.
  • 30. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Solution For each vertex v that is a target of any backedge, add a dummy edge ENTRY to v.
  • 31. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Solution For each vertex v that is a target of any backedge, add a dummy edge ENTRY to v. For each vertex w that is a source of any backedge, add a dummy edge w to EXIT.
  • 32. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Solution For each vertex v that is a target of any backedge, add a dummy edge ENTRY to v. For each vertex w that is a source of any backedge, add a dummy edge w to EXIT. Eliminate all backedges except EXIT to ENTRY.
  • 33. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Solution For each vertex v that is a target of any backedge, add a dummy edge ENTRY to v. For each vertex w that is a source of any backedge, add a dummy edge w to EXIT. Eliminate all backedges except EXIT to ENTRY. Apply first two steps of Path Profiling Algo (Edge value assignment and chord increment).
  • 34. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results After applying transformation and Edge value assignment A 8 2 B 3 0 0 C D E 0 F 1 0 G H I 2
  • 35. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results After computing chord increments A(r = 0) -6 B 13 10 C 2 D r=0; count[r]++ E F -1 -2 count[r]++ G H I ’r’ uniquely determines a path now.
  • 36. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Dealing with Self Loops Self loops are backedges with same source and target vertex.
  • 37. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Dealing with Self Loops Self loops are backedges with same source and target vertex. We can’t just remove them as it leaves nothing for instrumentation.
  • 38. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Dealing with Self Loops Self loops are backedges with same source and target vertex. We can’t just remove them as it leaves nothing for instrumentation. Approach: Add a counter along them to record the number of times they execute.
  • 39. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Optimizations Instead of storing r as index into the count array, make it a pointer. (saves 2 instructions per path)
  • 40. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Optimizations Instead of storing r as index into the count array, make it a pointer. (saves 2 instructions per path) Initialize r with base address of the array and do pointer arithmetic when r is updated.
  • 41. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Optimizations Instead of storing r as index into the count array, make it a pointer. (saves 2 instructions per path) Initialize r with base address of the array and do pointer arithmetic when r is updated. This optimization, however reduces the range of increments.
  • 42. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Optimizations Instead of storing r as index into the count array, make it a pointer. (saves 2 instructions per path) Initialize r with base address of the array and do pointer arithmetic when r is updated. This optimization, however reduces the range of increments. In step 1, we can choose edges (v,w) such that NumPath[w] is max of the set to reduce the range of increments.
  • 43. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Example A A 2 0 5 0 4 B D C 1 B D C numPaths[B] = 1; numPaths[C] = 1; numPaths[D] = 4. Experimental Results
  • 44. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Path profiling overhead - 30.9% (5.5 to 96.9%). Experimental Results
  • 45. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Path profiling overhead - 30.9% (5.5 to 96.9%). Edge profiling overhead - 16.1% (-2.6 to 52.8%). Experimental Results
  • 46. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Path profiling overhead - 30.9% (5.5 to 96.9%). Edge profiling overhead - 16.1% (-2.6 to 52.8%). Programs with litte hashing have comparable or lower overhead. Experimental Results
  • 47. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Experimental Results Path profiling overhead - 30.9% (5.5 to 96.9%). Edge profiling overhead - 16.1% (-2.6 to 52.8%). Programs with litte hashing have comparable or lower overhead. Programs with considerable hashing have lower overheads if they have large blocks or longer paths and infrequent execution of path increments.
  • 48. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Experimental Results Results of comparing path predicted from edge profiling against measured paths.
  • 49. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Experimental Results Results of comparing path predicted from edge profiling against measured paths. Prediction approach: Use the most frequently executed edge out of a block.
  • 50. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Experimental Results Results of comparing path predicted from edge profiling against measured paths. Prediction approach: Use the most frequently executed edge out of a block. On average 37.9% (4.3-57.1%) paths correctly predicted.
  • 51. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Experimental Results Results of comparing path predicted from edge profiling against measured paths. Prediction approach: Use the most frequently executed edge out of a block. On average 37.9% (4.3-57.1%) paths correctly predicted. Also computed the length of the predicted path upto first mispredicted edge.
  • 52. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Experimental Results Results of comparing path predicted from edge profiling against measured paths. Prediction approach: Use the most frequently executed edge out of a block. On average 37.9% (4.3-57.1%) paths correctly predicted. Also computed the length of the predicted path upto first mispredicted edge. Weighted by the execution frequency, predicted paths were nearly as good as measured paths (5.1 vs 6.9) but contained fewer instructions (33.6 vs 88.4).
  • 53. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Optimizations Experimental Results Experimental Results Results of comparing path predicted from edge profiling against measured paths. Prediction approach: Use the most frequently executed edge out of a block. On average 37.9% (4.3-57.1%) paths correctly predicted. Also computed the length of the predicted path upto first mispredicted edge. Weighted by the execution frequency, predicted paths were nearly as good as measured paths (5.1 vs 6.9) but contained fewer instructions (33.6 vs 88.4). Result is attributed to simple nature of benchmarks. Consistent with: branches typically follow one direction with high probability which remains same for different input.
  • 54. Path Profiling Path Profiling Algorithm Arbitrary Control Flow Graph Thank you. Optimizations Experimental Results