Title: Comprehensive Isomorphic Subtree Enumeration
1Comprehensive Isomorphic Subtree Enumeration
- Partha Biswas
- Girish Venkataramani
2Two operation subtrees
A
B
-
-
-
3After swapping the subtrees
A
B
-
-
-
-
4Isomorphic Subtree
A
B
-
-
-
Finding complex shareable resources
Finding reusable instructions as ISEs
-
Finding code reuse patterns for code size
reduction
5Agenda
- Existing approaches
- Problem Definition
- Our approach
- Experimental results
6Existing Approaches
A
B
-
-
-
-
-
Maximal Subgraph
Bottom-up Approach (Aho et al., Valiente)
Common Application Value numbering
7Existing Approaches
A
B
-
-
-
Top-down Approach
Common Application Resource sharing
8Existing Approaches
A
B
-
Pattern matching (Aho et al., Keutzer et al.)
Common Applications Instruction selection,
technology mapping
9Problem Definition
A
B
-
-
-
-
Given two reference trees A and B, find all
isomorphic subtrees contained within the trees.
10Our Approach
- Convert reference trees into canonical strings.
- Apply dynamic programming on canonical strings.
- Map the solution back to the reference trees.
11Prefix String
-
-
-
(
(
(
,
(
,
(
,
)
-
,
(
)
(
)
,
)
)
,
)
,
)
12Step 1 Canonicalize
-
-((,),)
((,),(,))
-
13After canonicalization of tree B
A
B
-
-
-
A simple substring match is not a solution!
-
(,(-(,),((,),-(,))))
-((-((,),),((,),(,))),)
14Skipping subtrees OP notation
-
Prefix String
OP
(
(
,
(
,
(
,
)
-
,
(
)
(
)
,
)
)
,
)
,
)
15Case 1 for deciding a match
A
B
-
-
-
-
( , ( - ( , ) , ( ( , ) , - (
, ) ) ) )
- ( ( - ( ( , ) , ) , ( ( , ) ,
( , ) ) ) , )
16Case 2 for deciding a match
A
B
-
-
-
( , ( - ( , ) , ( ( , ) , - (
, ) ) ) )
-
- ( ( - ( ( , ) , ) , ( ( , ) ,
( , ) ) ) , )
OP
17Case 3 for deciding a match
A
B
-
-
-
( , ( - ( , ) , ( ( , ) , - (
, ) ) ) )
-
OP
- ( ( - ( ( , ) , ) , ( ( , ) ,
( , ) ) ) , )
OP
18Case 4 for deciding a match
A
B
-
-
-
-
( , ( - ( , ) , ( ( , ) , - (
, ) ) ) )
OP
- ( ( - ( ( , ) , ) , ( ( , ) ,
( , ) ) ) , )
OP
OP
19Step 2 Dynamic Programming
Input Prefix strings of lengths m and n
Output LCPSLp,q, (P_NEXT,Q_NEXT)p,q
Longest Common Prefix String Length
p
p
1
m
1
m
1
1
q
q
LCPSLp,q
(P_NEXT,Q_NEXT)p,q
n
n
Complexity O(mn)
20The LCPSL matrix
21The (PNEXT, QNEXT) Pairs
22The LCPSL matrix solution 1
B
A
Substring in A (-(,),((,),OP)))
Substring in B (-(OP,),((,),OP)))
23Step 3 Mapping solution 1 back
A
B
-
-
-
-
Substring in A (-(,),((,),OP)))
Substring in B (-(OP,),((,),OP)))
24The LCPSL matrix solution 2
B
A
Substring in A (,(OP,OP))
Substring in B (OP,(,))
25Step 3 Mapping solution 2 back
A
B
-
-
-
-
Substring in A (-(,),((,),OP)))
Substring in B (-(OP,),((,),OP)))
Substring in A (,(OP,OP))
Substring in B (OP,(,))
26Resource sharing opportunities
27Resource sharing opportunities
28Conclusion
- A fast dynamic programming based approach to
operation tree isomorphism - Successfully applied on resource sharing
- Other embedded applications can benefit from this
approach