Open main menu
Home
Random
Recent changes
Special pages
Community portal
Preferences
About Wikipedia
Disclaimers
Incubator escapee wiki
Search
User menu
Talk
Dark mode
Contributions
Create account
Log in
Editing
Dominator (graph theory)
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
{{Short description|When every path in a control-flow graph must go through one node to reach another}} {{distinguish|dominating set}} {| style="float:right" | [[File:Dominator control flow graph.svg|thumb|200px|Example control-flow graph with entry node 1]] |} {| style="float:right" class=wikitable |- ! 1 | dom || {{color|#c0c0c0|1}} || {{color|#F00000|2}} || 3 || 4 || 5 || 6 |- ! 2 | dom || || {{color|#c0c0c0|2}} || {{color|#F00000|3}} || {{color|#F00000|4}} || {{color|#F00000|5}} ||{{color|#F00000|6}} |- ! 3 | dom || || || {{color|#c0c0c0|3}} || || || |- ! 4 | dom || || || || {{color|#c0c0c0|4}} || || |- ! 5 | dom || || || || || {{color|#c0c0c0|5}} || |- ! 6 | dom || || || || || || {{color|#c0c0c0|6}} |- | colspan=8 | Corresponding domination relation:<br>{{color|#c0c0c0|Grey nodes}} are not strictly dominated<br>{{color|#F00000|Red nodes}} are immediately dominated |} [[File:Dominator tree.svg|thumb|200px|Corresponding ''dominator tree'' of the control flow graph]] In [[computer science]], a [[basic block|node]] {{mvar|d}} of a [[control-flow graph]] '''dominates''' a node {{mvar|n}} if every path from the ''entry node'' to {{mvar|n}} must go through {{mvar|d}}. Notationally, this is written as {{math|''d'' dom ''n''}} (or sometimes {{math|''d'' β« ''n''}}). By definition, every node dominates itself. There are a number of related concepts: * A node {{mvar|d}} ''strictly dominates'' a node {{mvar|n}} if {{mvar|d}} dominates {{mvar|n}} and {{mvar|d}} does not equal {{mvar|n}}. * The ''immediate dominator'' or '''idom''' of a node {{mvar|n}} is the unique node that strictly dominates {{mvar|n}} but does not strictly dominate any other node that strictly dominates {{mvar|n}}. Every node reachable from the entry node has an immediate dominator (except the entry node).<ref name="fastdom"/> * The ''dominance frontier'' of a node {{mvar|d}} is the set of all nodes {{mvar|n{{sub|i}}}} such that {{mvar|d}} dominates an immediate predecessor of {{mvar|n{{sub|i}}}}, but {{mvar|d}} does not strictly dominate {{mvar|n{{sub|i}}}}. It is the set of nodes where {{mvar|d}}'s dominance stops. * A ''dominator tree'' is a [[tree (graph theory)|tree]] where each node's children are those nodes it immediately dominates. The start node is the root of the tree. == History == Dominance was first introduced by [[Reese Prosser|Reese T. Prosser]] in a 1959 paper on analysis of flow diagrams.<ref>{{cite book |last=Prosser |first=Reese T. |title=Papers presented at the December 1-3, 1959, eastern joint IRE-AIEE-ACM computer conference on - IRE-AIEE-ACM '59 (Eastern) |chapter=Applications of Boolean matrices to the analysis of flow diagrams |chapter-url=http://portal.acm.org/ft_gateway.cfm?id=1460314&type=pdf&coll=GUIDE&dl=GUIDE&CFID=79528182&CFTOKEN=33765747 |pages=133β138 |year=1959 |doi=10.1145/1460299.1460314 |s2cid=15546681 |author-link=Reese Prosser }}</ref> Prosser did not present an algorithm for computing dominance, which had to wait ten years for Edward S. Lowry and C. W. Medlock.<ref>{{cite journal |title=Object code optimization |journal=Communications of the ACM |volume=12 |issue=1 |date=January 1969 |pages=13β22 |first=Edward S. |last=Lowry |author2=Medlock, Cleburne W. |doi=10.1145/362835.362838|s2cid=16768560 |doi-access=free }}</ref> Ron Cytron ''et al.'' rekindled interest in dominance in 1989 when they applied it to the problem of efficiently computing the placement of Ο functions, which are used in [[static single assignment form]].<ref>{{cite book |first1=Ron |last1=Cytron |first2=Jeanne |last2=Ferrante |first3=Barry K. |last3=Rosen |first4=Mark N. |last4=Wegman |first5=F. Kenneth |last5=Zadeck |title=Proceedings of the 16th ACM SIGPLAN-SIGACT symposium on Principles of programming languages - POPL '89 |chapter=An efficient method of computing static single assignment form |chapter-url = http://portal.acm.org/citation.cfm?doid=75277.75280 |doi = 10.1145/75277.75280 |isbn = 0897912942 |year=1989 |pages=25β35|s2cid=8301431 }}</ref> == Applications == Dominators, and dominance frontiers particularly, have applications in [[compiler]]s for computing [[static single assignment form]]. A number of compiler optimizations can also benefit from dominators. The flow graph in this case comprises [[basic block]]s. Dominators play a crucial role in control flow analysis by identifying the program behaviors that are relevant to a specific statement or operation, which helps in optimizing and simplifying the control flow of programs for analysis.<ref>{{Cite journal |last1=Tamrawi |first1=Ahmed |last2=Kothari |first2=Suresh |date=2018-10-01 |title=Projected control graph for computing relevant program behaviors |url=https://www.sciencedirect.com/science/article/pii/S0167642318301497 |journal=Science of Computer Programming |volume=163 |pages=93β114 |doi=10.1016/j.scico.2018.04.003 |issn=0167-6423}}</ref> Automatic parallelization benefits from postdominance frontiers. This is an efficient method of computing control dependence, which is critical to the analysis. Memory usage analysis can benefit from the dominator tree to easily find leaks and identify high memory usage.<ref>{{cite web |url=http://help.eclipse.org/juno/index.jsp?topic=%2Forg.eclipse.mat.ui.help%2Fconcepts%2Fdominatortree.html |title=Dominator Tree |author=<!--Staff writer(s); no by-line.--> |orig-year=2008|year=2012 |website=eclipse.org |publisher=SAP AG and IBM Corporation |access-date=21 June 2013 }}</ref> In hardware systems, dominators are used for computing signal probabilities for test generation, estimating switching activities for power and noise analysis, and selecting cut points in equivalence checking.<ref>{{cite book |last=Teslenko |first=Maxim |author2=Dubrova, Elena |title=Design, Automation and Test in Europe |chapter=An Efficient Algorithm for Finding Double-Vertex Dominators in Circuit Graphs |url=http://dl.acm.org/citation.cfm?id=1049138 |pages=406β411 |year=2005 |doi=10.1109/DATE.2005.53 |isbn=9780769522883 |citeseerx=10.1.1.598.3053 |s2cid=10305833 }}</ref> In software systems, they are used for reducing the size of the test set in structural testing techniques such as statement and branch coverage.<ref>{{cite book |last=Dubrova |first=Elena |title=Design, Automation and Test in Europe |chapter=Structural Testing Based on Minimum Kernels |chapter-url=http://dl.acm.org/citation.cfm?id=1049294 |pages=1168β1173 |year=2005 |doi=10.1109/DATE.2005.284 |isbn=9780769522883 |citeseerx=10.1.1.583.5547 |s2cid=11439732 }}</ref> == Algorithms == Let <math>n_0</math> be the source node on the [[Control-flow graph]]. The dominators of a node <math>n</math> are given by the maximal solution to the following data-flow equations: : <math>\operatorname{Dom}(n) = \begin{cases} \left \{ n \right \} & \mbox{ if } n = n_0 \\ \left \{ n \right \} \cup \left ( \bigcap_{p \in \text{preds}(n)}^{} \operatorname{Dom}(p) \right ) & \mbox{ if } n \neq n_0 \end{cases} </math> The dominator of the start node is the start node itself. The set of dominators for any other node <math>n</math> is the intersection of the set of dominators for all predecessors <math>p</math> of <math>n</math>. The node <math>n</math> is also in the set of dominators for <math>n</math>. An algorithm for the direct solution is: // dominator of the start node is the start itself Dom(n<sub>0</sub>) = {n<sub>0</sub>} // for all other nodes, set all nodes as the dominators '''for each''' n '''in''' N - {n<sub>0</sub>} Dom(n) = N; // iteratively eliminate nodes that are not dominators '''while''' changes in any Dom(n) '''for each''' n '''in''' N - {n<sub>0</sub>}: Dom(n) = {n} union with intersection over Dom(p) for all p in pred(n) The direct solution is [[quadratic growth|quadratic]] in the number of nodes, or O(''n''<sup>2</sup>). [[Thomas Lengauer|Lengauer]] and [[Robert Endre Tarjan|Tarjan]] developed an algorithm which is almost linear,<ref name="fastdom">{{cite journal |first1=Thomas |last1=Lengauer |author-link1=Thomas Lengauer |first2=Robert Endre |last2=Tarjan |author-link2=Robert Tarjan |date=July 1979 |title=A fast algorithm for finding dominators in a flowgraph |journal=ACM Transactions on Programming Languages and Systems |volume=1 |issue=1 |pages=121β141 |doi=10.1145/357062.357071 |citeseerx=10.1.1.117.8843 |s2cid=976012 }}</ref> and in practice, except for a few artificial graphs, the algorithm and a simplified version of it are as fast or faster than any other known algorithm for graphs of all sizes and its advantage increases with graph size.<ref>{{cite web |author1=Georgiadis, Loukas |author2=Tarjan, Robert E. |author-link2=Robert Tarjan |author3=Werneck, Renato F. |year=2006 |title=Finding Dominators in Practice |url=https://www.cs.uoi.gr/~loukas/index.files/dominators_esa04.pdf |archive-url=https://web.archive.org/web/20240415132509/https://www.cs.uoi.gr/~loukas/index.files/dominators_esa04.pdf |archive-date=15 Apr 2024}}</ref> [[Keith D. Cooper]], Timothy J. Harvey, and [[Ken Kennedy (computer scientist)|Ken Kennedy]] of [[Rice University]] describe an algorithm that essentially solves the above data flow equations but uses well engineered data structures to improve performance.<ref>{{cite web |title=A Simple, Fast Dominance Algorithm |url=http://www.hipersoft.rice.edu/grads/publications/dom14.pdf |author1=Cooper, Keith D. |author2=Harvey, Timothy J |author3=Kennedy, Ken |author-link1=Keith D. Cooper |author-link3=Ken Kennedy (computer scientist) |year=2001 }}</ref> == Postdominance == Analogous to the definition of dominance above, a node ''z'' is said to '''post-dominate''' a node ''n'' if all paths to the exit node of the graph starting at ''n'' must go through ''z''. Similarly, the '''immediate post-dominator''' of a node ''n'' is the postdominator of ''n'' that doesn't strictly postdominate any other strict postdominators of ''n''. ==See also== * [[Control-flow graph]] * [[Interval (graph theory)]] * [[Static single assignment form]] ==References== <references /> ==External links== *[https://web.archive.org/web/20090714130243/http://www.eecs.harvard.edu/hube/software/nci/cfa.html The Machine-SUIF Control Flow Analysis Library] {{Graph Theory-footer}} {{DEFAULTSORT:Dominator (Graph Theory)}} [[Category:Graph theory]] [[Category:Compiler construction]] [[Category:Directed graphs]]
Edit summary
(Briefly describe your changes)
By publishing changes, you agree to the
Terms of Use
, and you irrevocably agree to release your contribution under the
CC BY-SA 4.0 License
and the
GFDL
. You agree that a hyperlink or URL is sufficient attribution under the Creative Commons license.
Cancel
Editing help
(opens in new window)
Pages transcluded onto the current version of this page
(
help
)
:
Template:Cite book
(
edit
)
Template:Cite journal
(
edit
)
Template:Cite web
(
edit
)
Template:Color
(
edit
)
Template:Distinguish
(
edit
)
Template:Graph Theory-footer
(
edit
)
Template:Ifsubst
(
edit
)
Template:Math
(
edit
)
Template:Mvar
(
edit
)
Template:Short description
(
edit
)