High-Performance Parallel Graph Coloring with Strong Guarantees on Work, Depth, and Quality
Total Page:16
File Type:pdf, Size:1020Kb
High-Performance Parallel Graph Coloring with Strong Guarantees on Work, Depth, and Quality Maciej Besta1, Armon Carigiet1, Zur Vonarburg-Shmaria1, Kacper Janda2, Lukas Gianinazzi1, Torsten Hoefler1 1Department of Computer Science, ETH Zurich 2Faculty of Computer Science, Electronics and Telecommunications, AGH-UST Abstract—We develop the first parallel graph coloring heuris- to their degrees, random (R) [26] which chooses vertices tics with strong theoretical guarantees on work and depth and uniformly at random, incidence-degree (ID) [1] which picks coloring quality. The key idea is to design a relaxation of the vertices with the largest number of uncolored neighbors first, vertex degeneracy order, a well-known graph theory concept, and to color vertices in the order dictated by this relaxation. This saturation-degree (SD) [27], where a vertex whose neighbors introduces a tunable amount of parallelism into the degeneracy use the largest number of distinct colors is chosen first, and ordering that is otherwise hard to parallelize. This simple idea smallest-degree-last (SL) [28] that removes lowest degree enables significant benefits in several key aspects of graph color- vertices, recursively colors the resulting graph, and then colors ing. For example, one of our algorithms ensures polylogarithmic the removed vertices. All these ordering heuristics, combined depth and a bound on the number of used colors that is superior to all other parallelizable schemes, while maintaining work- with Greedy, have the inherent problem of no parallelism. efficiency. In addition to provable guarantees, the developed Jones and Plassmann combined this line of work with earlier algorithms have competitive run-times for several real-world parallel schemes for deriving maximum independent sets [29], graphs, while almost always providing superior coloring quality. [30] and obtained a parallel graph coloring algorithm (JP) that Our degeneracy ordering relaxation is of separate interest for colors a vertex v once all of v’s neighbors that come later in algorithms outside the context of coloring. the provided ordering have been colored. They showed that This is the full version of a paper published at JP, combined with a random vertex ordering (JP-R), runs in ACM/IEEE Supercomputing’20 under the same title expected depth O(log n= log log n) and O(n + m) work for constant-degree graphs (n and m are #vertices and #edges I. INTRODUCTION in G, respectively). Recently, Hasenplaugh et al. [31] extended Graph coloring, more specifically vertex coloring, is a well JP with the largest-log-degree first (LLF) and smallest-log- studied problem in computer science, with many practical degree-last (SLL) orderings with better bounds on depth; these applications in domains such as sparse linear algebra computa- orderings approximate the LF and SL orderings, respectively. tions [1]–[7], conflicting task scheduling [8]–[11], networking There is also another (earlier) work [32] that – similarly to and routing [12]–[20], register allocation [21], [22], and many JP-SLL – approximates SL with the “ASL” ordering. The others [23]. A vertex coloring of a graph G is an assignment resulting coloring combines JP with ASL, we denote it as JP- of colors to vertices, such that no two neighboring vertices ASL [32]. However, it offers no bounds for work or depth. share the same color. A k-coloring is a vertex coloring of G Overall, there is no parallel algorithm with strong theoreti- which uses k distinct colors. The minimal amount of colors k cal guarantees on work and depth and quality. Whilst having for which a k-coloring can be found for G is referred to as the a reasonable theoretical run-time, JP-R may offer colorings chromatic number χ(G). An optimal coloring, also sometimes of poor quality [31], [33]. On the other hand, JP-LF and JP- referred to as the coloring problem or a χ-coloring, is the SL, which provide a better coloring quality, run in Ω(n) or problem of coloring G with χ(G) colors. Finding such and Ω(∆2) for some graphs [31]. This was addressed by the recent arXiv:2008.11321v3 [cs.DS] 11 Nov 2020 optimal coloring was shown to be NP-complete [24]. JP-LLF and JP-SLL algorithms [31] that produce colorings Nonetheless, colorings with a reasonably low number of of similarly good quality to their counterparts JP-LF and JP- colors can in practice be computed quite efficiently in the SL, and run in an expected depth that is within a logarithmic sequential setting using heuristics. One of the most important factor of JP-R. However, no guaranteed upper bounds on the is the Greedy heuristic [25], which sequentially colors vertices coloring quality (#colors), better than the trivial ∆ + 1 bound by choosing, for each selected vertex v, the smallest color not from Greedy, exist for JP-LLF, JP-SLL, or JP-ASL. already taken by v’s neighbors. This gives a guarantee for To alleviate these issues, we present the first graph coloring a coloring of G with at most ∆ + 1 colors, where ∆ is the algorithms with provably good bounds on work and depth maximum degree in G. To further improve the coloring quality and quality, simultaneously ensuring high performance and (i.e., #colors used), Greedy is in practice often used with a competitive quality in practice. The key idea is to use a certain vertex ordering heuristic, which decides the order in novel vertex ordering, the provably approximate degeneracy which Greedy colors the vertices. Example heuristics are first- ordering (ADG, contribution #1) when selecting which vertex fit (FF) [25] which uses the default order of the vertices in G, is the next to be colored. The exact degeneracy ordering is – largest-degree-first (LF) [25] which orders vertices according intuitively – an ordering obtained by iteratively removing ver- 1 tices of smallest degrees. Using the degeneracy ordering with real-world graphs, while (2) offering superior coloring quality. JP leads to the best possible Greedy coloring quality [28]. Still, Only JP-SL and JP-SLL use comparably few colors, but they computing the exact degeneracy ordering is hard to parallelize: are at least 1.5× slower. Our routines are of interest for for some graphs, it leads to Ω(n) coloring run-time [31]. To coloring both small and large graphs, for example in online tackle this, we (provably) relax the strict degeneracy order by execution scheduling and offline data analytics, respectively. assigning the same rank (in the ADG ordering) to a batch We conclude that our algorithms offer the best coloring quality of vertices that – intuitively – have similarly small degrees. at the smallest required runtime overhead. This approach also results in provably higher parallelization In a brief summary, we offer the following: because each batch of vertices can be processed in parallel. • The first parallel algorithm for deriving the (approximate) This simple idea, when applied to graph coloring, gives graph degeneracy ordering (ADG). surprisingly rich outcome. We use it to develop three novel • The first parallel graph coloring algorithm (JP-ADG), in a graph coloring algorithms that enhance two relevant lines line of heuristics based on Jones and Plassman’s scheme, of research. We first combine ADG with JP, obtaining JP- with strong bounds on work, depth, and coloring quality. ADG (contribution #2), a coloring algorithm that is paral- • The first parallel graph coloring algorithm (DEC-ADG), lelizable: vertices with the same ADG rank are colored in in a line of heuristics based on speculative coloring, with 2 parallel. It has the expected worst-case depth of O(log n + strong bounds on work, depth, and coloring quality 2 log ∆(d log n + log d log n= log log n)). Here, d is the degen- • A use case of how ADG can seamlessly enhance an existing eracy of a graph G: an upper bound on the minimal degree of state-of-the-art graph coloring scheme (DEC-ADG-ITR). every induced subgraph of G (detailed in § II-B) [28]. JP-ADG • The most extensive (so far) theoretical analysis of parallel is also work-efficient (O(n + m) work) and has good coloring graph coloring algorithms, showing advantages of our quality: it uses at most 2(1 + ")d + 1 colors1, for any " > 0. algorithms over state-of-the-art in several dimensions. Moreover, we also combine ADG with another important • Superior coloring quality offered by our algorithms over line of graph coloring algorithms that are not based on JP tuned modern schemes for many real-world graphs. but instead use speculation [32], [34]–[46]. Here, vertices We note that degeneracy ordering is used beyond graph color- are colored independently (“speculative coloring”). Potential ing [49]–[52]; thus, our ADG scheme is of separate interest. coloring conflicts (adjacent vertices assigned the same colors) are resolved by repeating coloring attempts. Combining ADG II. FUNDAMENTAL CONCEPTS with this design gives DEC-ADG (contribution #3), the first We start with background; Table I lists key symbols. Vertex scheme based on speculative coloring with provable strong coloring was already described in Section I. guarantees on all key aspects of parallel graph coloring: work O(n + m), depth O(log d log2 n) , and quality (2 + ")d. A. Graph Model and Representation Finally, we combine key design ideas in DEC-ADG with We model a graph G as a tuple (V; E); V is a set of vertices an existing recent algorithm [40] (referred to as ITR) also and E ⊆ V × V is a set of edges; jV j = n and jEj = m. We based on speculative coloring. We derive an algorithm called focus on graph coloring problems where edge directions are DEC-ADG-ITR that improves coloring quality of ITR both not relevant. Thus, G is undirected. The maximum, minimum, in theory and practice.