Jeremy Siek 4 лет назад
Родитель
Сommit
d02d0059a1
2 измененных файлов с 247 добавлено и 4 удалено
  1. 129 4
      all.bib
  2. 118 0
      book.tex

+ 129 - 4
all.bib

@@ -2,18 +2,144 @@
 %% http://bibdesk.sourceforge.net/
 
 
-%% Created for Jeremy Siek at 2021-01-24 10:32:01 -0500 
+%% Created for Jeremy Siek at 2021-01-25 11:35:47 -0500 
 
 
 %% Saved with string encoding Unicode (UTF-8) 
 
 
 
+@incollection{Matula:1972aa,
+	abstract = {Publisher Summary
+This chapter focuses on sequential vertex colorings, where vertices are sequentially added to the portion of the graph already colored, and the new colorings are determined to include each newly adjoined vertex. Considerable literature in the field of graph theory has dealt with the coloring of graphs. The majority of this effort has been devoted to the theory of graph coloring, and relatively little study has been directed toward the design of efficient graph coloring procedures. Because numerous proofs of properties relevant to graph coloring are constructive, many coloring procedures are at least implicit in the theoretical development. The chapter describes the concept of sequential colorings is formalized and certain upper bounds on the minimum number of colors needed to color a graph, the chromatic number x(G). The chief results show that the recursive-smallest-vertex-degree-last-ordering-with-interchange coloring algorithm will color any planar graph in five or fewer colors. The algorithm is evidently quite efficient even on large planar graphs.},
+	author = {David W. Matula and George Marble and Joel D. Isaacson},
+	booktitle = {Graph Theory and Computing},
+	date-added = {2021-01-25 11:35:40 -0500},
+	date-modified = {2021-01-25 11:35:42 -0500},
+	doi = {https://doi.org/10.1016/B978-1-4832-3187-7.50015-5},
+	editor = {RONALD C. READ},
+	isbn = {978-1-4832-3187-7},
+	pages = {109 - 122},
+	publisher = {Academic Press},
+	title = {GRAPH COLORING ALGORITHMS††This research was supported in part by the Advanced Research Projects Agency of the Department of Defense under contract SD-302 and by the National Science Foundation under contract GJ-446.},
+	url = {http://www.sciencedirect.com/science/article/pii/B9781483231877500155},
+	year = {1972},
+	Bdsk-Url-1 = {http://www.sciencedirect.com/science/article/pii/B9781483231877500155},
+	Bdsk-Url-2 = {https://doi.org/10.1016/B978-1-4832-3187-7.50015-5}}
+
+@article{Matula:1983aa,
+	address = {New York, NY, USA},
+	author = {Matula, David W. and Beck, Leland L.},
+	date-added = {2021-01-25 11:32:15 -0500},
+	date-modified = {2021-01-25 11:32:19 -0500},
+	doi = {10.1145/2402.322385},
+	issn = {0004-5411},
+	issue_date = {July 1983},
+	journal = {J. ACM},
+	month = jul,
+	number = {3},
+	numpages = {11},
+	pages = {417--427},
+	publisher = {Association for Computing Machinery},
+	title = {Smallest-Last Ordering and Clustering and Graph Coloring Algorithms},
+	url = {https://doi.org/10.1145/2402.322385},
+	volume = {30},
+	year = {1983},
+	Bdsk-Url-1 = {https://doi.org/10.1145/2402.322385}}
+
+@article{Mitchem:1976aa,
+	author = {John Mitchem},
+	date-added = {2021-01-25 10:50:24 -0500},
+	date-modified = {2021-01-25 10:51:17 -0500},
+	journal = {The Computer Journal},
+	number = {2},
+	pages = {182-183},
+	title = {On Various Algorithms for Estimating the Chromatic Number of a Graph},
+	volume = {19},
+	year = {1976},
+	Bdsk-File-1 = {YnBsaXN0MDDRAQJccmVsYXRpdmVQYXRoXDE5LTItMTgyLnBkZggLGAAAAAAAAAEBAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAl}}
+
+@techreport{Schwartz:1975aa,
+	author = {Jacob T. Schwartz},
+	date-added = {2021-01-25 09:40:01 -0500},
+	date-modified = {2021-01-25 09:41:18 -0500},
+	institution = {Computer Science Dept., Courant Institute of Mathematical Sciences, New York University},
+	title = {On Programming: An Interim Report of the {SETL} Project},
+	year = {1975},
+	Bdsk-File-1 = {YnBsaXN0MDDRAQJccmVsYXRpdmVQYXRoWzcxOTY0ODAucGRmCAsYAAAAAAAAAQEAAAAAAAAAAwAAAAAAAAAAAAAAAAAAACQ=}}
+
+@inbook{Backus:1978aa,
+	address = {New York, NY, USA},
+	author = {Backus, John},
+	booktitle = {History of Programming Languages},
+	date-added = {2021-01-24 18:10:32 -0500},
+	date-modified = {2021-01-24 18:10:34 -0500},
+	isbn = {0127450408},
+	numpages = {50},
+	pages = {25--74},
+	publisher = {Association for Computing Machinery},
+	title = {The History of Fortran I, II, and III},
+	url = {https://doi.org/10.1145/800025.1198345},
+	year = {1978},
+	Bdsk-File-1 = {YnBsaXN0MDDRAQJccmVsYXRpdmVQYXRoXxASODAwMDI1LjExOTgzNDUucGRmCAsYAAAAAAAAAQEAAAAAAAAAAwAAAAAAAAAAAAAAAAAAAC0=},
+	Bdsk-Url-1 = {https://doi.org/10.1145/800025.1198345}}
+
+@phdthesis{New:2020ab,
+	author = {Max Stewart New},
+	date-added = {2021-01-24 16:50:36 -0500},
+	date-modified = {2021-01-24 16:51:12 -0500},
+	school = {Northeastern University},
+	title = {A Semantic Foundation for Sound Gradual Typing},
+	year = {2020},
+	Bdsk-File-1 = {YnBsaXN0MDDRAQJccmVsYXRpdmVQYXRoXxAUZGlzc2VydGF0aW9uLW5ldy5wZGYICxgAAAAAAAABAQAAAAAAAAADAAAAAAAAAAAAAAAAAAAALw==}}
+
+@phdthesis{Greenman:2020aa,
+	author = {Ben Greenman},
+	date-added = {2021-01-24 16:37:31 -0500},
+	date-modified = {2021-01-24 16:38:01 -0500},
+	month = {November},
+	school = {Northeastern University},
+	title = {Deep and Shallow Types},
+	year = {2020},
+	Bdsk-File-1 = {YnBsaXN0MDDRAQJccmVsYXRpdmVQYXRoXxAZZGlzc2VydGF0aW9uLWdyZWVubWFuLnBkZggLGAAAAAAAAAEBAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAA0}}
+
+@phdthesis{Takikawa:2016ab,
+	author = {Asumu Takikawa},
+	date-added = {2021-01-24 16:21:57 -0500},
+	date-modified = {2021-01-24 16:23:08 -0500},
+	month = {April},
+	school = {Northeastern University},
+	title = {The Design, Implementation, And Evaluation Of A Gradual Type System For Dynamic Class Composition},
+	year = {2016},
+	Bdsk-File-1 = {YnBsaXN0MDDRAQJccmVsYXRpdmVQYXRoXxAZZGlzc2VydGF0aW9uLXRha2lrYXdhLnBkZggLGAAAAAAAAAEBAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAA0}}
+
+@article{Horwitz:1966aa,
+	abstract = {A procedure for index register allocation is described. The rules of this procedure are shown to yield an optimal allocation for ``straight line'' programs.},
+	address = {New York, NY, USA},
+	author = {Horwitz, L. P. and Karp, R. M. and Miller, R. E. and Winograd, S.},
+	date-added = {2021-01-24 12:19:53 -0500},
+	date-modified = {2021-01-24 12:19:55 -0500},
+	doi = {10.1145/321312.321317},
+	issn = {0004-5411},
+	issue_date = {Jan. 1966},
+	journal = {J. ACM},
+	month = jan,
+	number = {1},
+	numpages = {19},
+	pages = {43--61},
+	publisher = {Association for Computing Machinery},
+	title = {Index Register Allocation},
+	url = {https://doi.org/10.1145/321312.321317},
+	volume = {13},
+	year = {1966},
+	Bdsk-File-1 = {YnBsaXN0MDDRAQJccmVsYXRpdmVQYXRoXxATMzIxMzEyLjMyMTMxNy0xLnBkZggLGAAAAAAAAAEBAAAAAAAAAAMAAAAAAAAAAAAAAAAAAAAu},
+	Bdsk-Url-1 = {https://doi.org/10.1145/321312.321317}}
+
 @phdthesis{Dybvig:1987ab,
 	author = {R. Kent Dybvig},
 	date-added = {2021-01-24 10:31:11 -0500},
 	date-modified = {2021-01-24 10:31:46 -0500},
-	school = {University of North Carolina at Chapel Hill },
+	school = {University of North Carolina at Chapel Hill},
 	title = {Three Implementation Models for Scheme},
 	year = {1987},
 	Bdsk-File-1 = {YnBsaXN0MDDRAQJccmVsYXRpdmVQYXRoXXRocmVlLWltcC5wZGYICxgAAAAAAAABAQAAAAAAAAADAAAAAAAAAAAAAAAAAAAAJg==}}
@@ -31575,8 +31701,7 @@ needed by type inference.
 	title = {Linear scan register allocation},
 	volume = {21},
 	year = {1999},
-	Bdsk-File-1 = {YnBsaXN0MDDRAQJccmVsYXRpdmVQYXRoXxAeLi4vLi4vLi4vcGFwZXJzL2xpbmVhcnNjYW4ucGRmCAsYAAAAAAAAAQEAAAAAAAAAAwAAAAAAAAAAAAAAAAAAADk=},
-	Bdsk-File-2 = {YnBsaXN0MDDRAQJccmVsYXRpdmVQYXRoXmxpbmVhcnNjYW4ucGRmCAsYAAAAAAAAAQEAAAAAAAAAAwAAAAAAAAAAAAAAAAAAACc=},
+	Bdsk-File-1 = {YnBsaXN0MDDRAQJccmVsYXRpdmVQYXRoXmxpbmVhcnNjYW4ucGRmCAsYAAAAAAAAAQEAAAAAAAAAAwAAAAAAAAAAAAAAAAAAACc=},
 	Bdsk-Url-1 = {http://doi.acm.org/10.1145/330249.330250}}
 
 @unpublished{Ghuloum:2006lr,

+ 118 - 0
book.tex

@@ -4439,6 +4439,124 @@ conclusion:
 \label{fig:running-example-x86}
 \end{figure}
 
+% challenge: prioritize variables based on execution frequencies
+%   and the number of uses of a variable
+
+% challenge: enhance the coloring algorithm using Chaitin's
+%  approach of prioritizing high-degree variables
+%  by removing low-degree variables (coloring them later)
+%  from the interference graph
+
+
+\section{Further Reading}
+\label{sec:register-allocation-further-reading}
+
+Early register allocation algorithms were developed for Fortran
+compilers in the 1950s~\citep{Horwitz:1966aa,Backus:1978aa}.  The use
+of graph coloring began in the late 1970s and early 1980s with the
+work of \citet{Chaitin:1981vl} on an optimizing compiler for PL/I. The
+algorithm is based on an observation of \citet{Kempe:1879aa}.  If a
+graph $G$ has a vertex $v$ with degree lower than $k$ (e.g. the number
+of registers), then $G$ is $k$ colorable if the subgraph of $G$ with
+$v$ removed is also $k$ colorable. Suppose that the subgraph is $k$
+colorable.  In the worst case the neighbors of $v$ are assigned
+different colors, but since there are less than $k$ of them, there
+will be one or more colors left over to use for coloring $v$ in $G$.
+
+The algorithm of \citet{Chaitin:1981vl} removes a low-degree vertex
+$v$ from the graph and recursively colors the rest of the graph. Upon
+returning from the recursion, it colors $v$ with one of the available
+colors and returns.  \citet{Chaitin:1982vn} augments this algorithm to
+handle spilling as follows. If there are no vertices of degree lower
+than $k$ then pick one at random, spill it, remove it from the graph,
+and proceed recursively on the rest of the graph.
+
+Prior to coloring, \citet{Chaitin:1981vl} merge variables that are
+move-related and that don't interfere with each other, a process
+called \emph{coalescing}. While coalescing decreases the number of
+moves, it can make the graph more difficult to
+color. \citet{Briggs:1994kx} proposes \emph{conservative coalescing}
+in which two variables are merged only if they have fewer than $k$
+neighbors of high degree. \citet{George:1996aa} observes that
+conservative coalescing is sometimes too conservative and make it more
+aggressive by iterating the coalescing with the removal of low-degree
+vertices.
+%
+Attacking the problem from a different angle, \citet{Briggs:1994kx}
+also proposes \emph{biased coloring} in which a variable is assigned
+to the same color as another move-related variable if possible, as
+discussed in Section~\ref{sec:move-biasing}.
+%
+The algorithm of \citet{Chaitin:1981vl} iteratively performs
+coalescing, graph coloring, and spill code insertion until all
+variables have been assigned a location.
+
+\citet{Briggs:1994kx} observes that \citet{Chaitin:1982vn} sometimes
+spills variables that don't have to be: a high-degree variable can be
+colorable if many of its neighbors are assigned the same color.
+\citet{Briggs:1994kx} proposes \emph{optimistic coloring}, in which a
+high-degree vertex is not immediately spilled. Instead the decision is
+deferred until after the recursive call, at which point it is apparent
+whether there is actually an available color or not. This algorithm is
+equivalent the smallest-last ordering algorithm~\citep{Matula:1972aa}
+if one takes the first $k$ colors to be registers and the rest to be
+stack locations.
+%% biased coloring
+Earlier editions of the compiler course at Indiana University
+\citep{Dybvig:2010aa} were based on the algorithm of
+\citet{Briggs:1994kx}.
+
+The smallest-last ordering algorithm is one of many \emph{greedy}
+coloring algorithms. A greedy coloring algorithm visits all the
+vertices in a particular order and assigns each one the first
+available color. An \emph{offline} greedy algorithm chooses the
+ordering up-front, prior to assigning colors. The algorithm of
+\citet{Chaitin:1981vl} should be considered offline because the vertex
+ordering does not depend on the colors assigned, so the algorithm
+could be split into two phases.  Other orderings are possible. For
+example, \citet{Chow:1984ys} order variables according an estimate of
+runtime cost.
+%
+An \emph{online} greedy coloring algorithm uses information about the
+current assignment of colors to influence the order in which the
+remaining vertices are colored. The saturation-based algorithm
+described in this chapter is one such algorithm.
+
+A register allocator may choose to map each variable to just one
+location, as in \citet{Chaitin:1981vl}, or it may choose to map a
+variable to one or more locations. The later can be achieved by
+\emph{live range splitting}, where a variable is replaced by several
+variables that each handle part of its live
+range~\citep{Chow:1984ys,Briggs:1994kx,Cooper:1998ly}.
+
+%% 1950s, Sheldon Best, Fortran \cite{Backus:1978aa}, Belady's page
+%% replacement algorithm, bottom-up local
+%% \citep{Horwitz:1966aa} straight-line programs, single basic block, 
+
+%% Cooper: top-down (priority bassed), bottom-up
+
+%% top-down
+%%   order variables by priority (estimated cost)
+%%   caveat: split variables into two groups:
+%%     constrained (>k neighbors) and unconstrained (<k neighbors)
+%%     color the constrained ones first
+
+%% \citet{Schwartz:1975aa} graph-coloring, no spill
+%% cite J. Cocke for an algorithm that colors variables
+%%   in a high-degree first ordering
+
+%Register Allocation via Usage Counts, Freiburghouse CACM
+
+\citet{Palsberg:2007si} observe that many of the interference graphs
+that arise from Java programs in the JoeQ compiler are \emph{chordal},
+that is, every cycle with four or more edges has an edge which is not
+part of the cycle but which connects two vertices on the cycle. Such
+graphs can be optimally colored by the greedy algorithm with a vertex
+ordering determined by maximum cardinality search.
+
+In situations where compile time is of utmost importance, such as in
+just-in-time compilers, graph coloring algorithms can be too expensive
+and the linear scan of \citet{Poletto:1999uq} may be more appropriate.
 
 
 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%