Chapter 18 Graph traversal
Chapter 18 Graph traversal
CHAPTER
Graph traversal
With special contributions from John Owens and Juan Gómez-Luna CONTENTS 18.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425 18.2 Breadthfirst search . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 429 18.3 Vertex-centric parallelization of BFS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 431 18.4 Edge-centric parallelization of BFS. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 436 18.5 Improving work efficiency with frontiers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 438 18.6 Reducing contention with privatization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442 18.7 Reducing launch overhead with cooperative groups . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445 18.8 Other optimizations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 448 18.9 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 18.10 Exercises. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451 A graph is a data structure that represents the relations between entities. The entities involved are represented as vertices and the relations are represented as edges. Many important real-world problems are naturally formulated as large-scale graph problems and can benefit from massively parallel computation. Prominent examples include social networks and driving direction map services. There are multiple strategies for parallelizing graph computations, some of which are centered on processing vertices in parallel while others are centered on processing edges in parallel. Graphs are intrinsically related to sparse matrices because graph adjacency matrices tend to be very sparse. Graph computation can be formulated in terms of sparse matrix operations on square matrices. However, one can often improve the efficiency of graph computation by exploiting properties that are specific to the type of graph computation being performed. In this chapter, we will focus on breadth first search, a graph traversal computation that underlies many real-world applications.
A graph is a data structure that represents the relations between entities. The entities involved are represented as vertices and the relations are represented as edges. Many important real-world problems are naturally formulated as large-scale graph problems and can benefit from massively parallel computation. Prominent examples include social networks and driving direction map services. There are multiple strategies for parallelizing graph computations, some of which are centered on processing vertices in parallel while others are centered on processing edges in parallel. Graphs are intrinsically related to sparse matrices because graph adjacency matrices tend to be very sparse. Graph computation can be formulated in terms of sparse matrix operations on square matrices. However, one can often improve the efficiency of graph computation by exploiting properties that are specific to the type of graph computation being performed. In this chapter, we will focus on breadth first search, a graph traversal computation that underlies many real-world applications.
18.1 Background
A graph data structure represents the relations between entities. For example, in social media, the entities are users and the relations are connections between users. As another example, in driving direction map services, the entities are locations and the Programming Massively Parallel Processors. https://doi.org/10.1016/B978-0-44-343900-1.00029-9 Copyright © 2027 Elsevier Inc. All rights are reserved, including those for text and data mining, AI training, and similar technologies.
FIGURE 18.1. A simple graph example with nine vertices and fifteen directional edges.
FIGURE 18.2. Adjacency matrix representation of the simple graph example.
relations are the roadways between them. Some relations are bidirectional, such as friend connections in a social network. Other relations are directional, such as oneway streets in a road network. In this chapter, we will focus on directional relations. Bidirectional relations can be represented with two directional relations, one for each direction. Fig. 18.1 shows an example of a simple graph with directional edges. A directional relation is represented as an arrowed edge going from a source vertex to a destination vertex. We assign a unique number to each vertex, also called the vertex id. There is one edge going from vertex 0 to vertex 1 and one going from vertex 0 to vertex 2, etc. An intuitive representation of a graph is an adjacency matrix. In an adjacency matrix A, if there is an edge going from a source vertex i to a destination vertex j , the value of element Ai,j of the adjacency matrix is 1. Otherwise, it is 0. Fig. 18.2 shows the adjacency matrix for the simple graph in Fig. 18.1. We see that A1,3 and A4,5 are both 1 since there are edges going from vertex 1 to vertex 3 and from vertex 4 to vertex 5. For clarity, we leave the 0 values out of the adjacency matrix. That is, if an element is empty, its value is understood to be 0. If a graph with N vertices is fully connected, i.e., every vertex is connected with all other vertices, each vertex should have N − 1 outgoing edges. There should be a total of N · (N − 1) edges, since there is no edge going from a vertex to itself. For example, if our nine-vertex graph were fully connected, there should be 8 edges going out of each vertex. There should be a total of 72 edges. Obviously, our graph is much less connected; each vertex has three or fewer outgoing edges. Such a graph is referred to as being sparsely connected. That is, the average number of outgoing edges from each vertex is much smaller than N − 1. At this point, the reader has most likely made the correct observation that sparsely connected graphs can probably benefit from a sparse matrix representation. As we have seen in Chapter 17, using a compressed representation of the matrix can drastically reduce the amount of storage required and the number of wasted operations on the zero elements. Indeed, many real-world graphs are sparsely connected. For example, in a social network, the average number of connections for each user is much smaller than the total number of users. This makes the number of non-zero elements in the adjacency matrix much smaller than the total number of elements. Fig. 18.3 shows three representations of our simple graph example using three different storage formats: CSR, CSC, and COO. We will refer to the row indices and offsets arrays as the src and srcPtrs arrays, respectively, and the column indices and offsets arrays as the dst and dstPtrs arrays, respectively. If we take CSR as an example, recall that in a CSR representation of a sparse matrix, each row offset in the rowPtrs array gives the starting location for the non-zero elements in a row. Similarly, in a CSR representation of a graph, each source vertex offset in the srcPtrs array gives the starting location of the outgoing edges of the vertex. For example, srcPtrs[3]=7 gives the starting location of the non-zero elements in row 3 of the original adjacency matrix. Also, srcPtrs[4]=9 gives the starting location of the non-zero elements in row 4 of the original matrix. Thus, we expect to find the non-zero data for row 3 in data[7] and data[8] and the column indices (destination vertices) for these elements in dst[7] and dst[8]. These are the data and column indices for the two edges leaving vertex 3. The reason we call the column index array dst is that the column index of an element in the adjacency matrix gives the destination vertex of the represented edge. In our example, we see that the destination of the two edges for source vertex 3 are dst[7]=4 and dst[8]=8. We leave it as an exercise to the reader to draw similar analogies for the CSC and COO representations. Note that the data array in this example is unnecessary. Since the value of all its elements is 1, we do not need to store it. We can make the data implicit, i.e., whenever a non-zero element exists, we can just assume it is 1. For example, the existence of each column index in the destination array of a CSR representation implies that an edge exists. However, in some applications, the adjacency matrix may store additional information about the relationship, such as the distance between two locations or the date when two social network users became connected. In those applications, the data array will need to be explicitly stored.
FIGURE 18.3. Three sparse matrix representations of the adjacency matrix: (a) CSR, (b) CSC, and (c) COO.
Sparse representation can lead to significant savings in storing the adjacency matrix. For our example, assuming that the data array can be eliminated, the CSR representation requires storage for 25 locations, in contrast with 92 = 81 locations if we stored the entire adjacency matrix. For real-life problems where a very small fraction of the adjacency matrix elements are non-zero, the savings can be tremendous. Different graphs may have drastically different structures. One way to characterize these structures is to look at the distribution of the number of edges connected to each vertex (the vertex degree''). A road network, expressed as a graph, would have a relatively uniform degree distribution with a low average degree per vertex, because each road intersection (vertex) would typically have a low number of roads (edges) connected to it. On the other hand, a graph of social network followers, where each incoming edge represents a follow’’, has a much broader distribution of vertex degrees, with a large-degree vertex representing a popular social network user. The structure of the graph may influence the choice of algorithm to implement a particular graph application. Recall from Chapter 17 that each sparse matrix representation gives different accessibility to the represented data. Hence, the choice of which representation to use FIGURE 18.4 (a and b) Two examples of breadthfirst search results for two different root vertices. The labels adjacent to each vertex indicate the number of hops (``depth’’) from the root vertex.
18.2 Breadthfirst search
for the graph has implications on which information about the graph is made easily accessible to the graph traversal algorithm. The CSR representation gives easy access to the outgoing edges of a given vertex. The CSC representation gives easy access to the incoming edges of a given vertex. The COO representation gives easy access to the source and destination vertices of a given edge. Therefore, the choice of the graph representation comes hand-in-hand with the choice of the graph traversal algorithm. We demonstrate this concept throughout this chapter by examining different parallel implementations of breadth first search, a widely used graph traversal computation.
An important graph traversal computation is breadthfirst search (BFS). Breadthfirst search is often used to discover the shortest number of edges that one needs to traverse in order to go from one vertex to any other vertex of the graph. In the graph example in Fig. 18.1, we may need to find all the alternative routes that we could take going from the location represented by vertex 0 to that represented by vertex 5. By visual inspection, we see that there are three possible paths: 0→1→3→4→5, 0→1→4→5, and 0→2→5, with 0→2→5 being the shortest. There are different ways of summarizing the outcome of a BFS traversal. One way is, given a vertex referred to as the root, to label each vertex with the smallest number of edges that one needs to traverse to go from the root to that vertex. The outcome of BFS can also be useful for understanding the topology of a graph. Fig. 18.4(a) shows the desired breadthfirst search result with vertex 0 as the root. Through one edge, we can get to vertices 1 and 2. Thus, we label these vertices as belonging to level 1. By traversing another edge, we can get to vertices 3 (through vertex 1), 4 (through vertex 1), 5 (through vertex 2), 6 (through vertex 2), and 7 FIGURE 18.5 Maze routing in integrated circuits – an application for breadthfirst search: (a) breathfirst search, (b) identifying a routing path.
(through vertex 2). Thus, we label these vertices as belonging to level 2. Finally, by traversing one more edge, we can get to vertex 8 (through any of vertices 3, 4 or 6). The breadthfirst search result would be quite different with another vertex as the root. Fig. 18.4(b) shows the desired result of breadthfirst search with vertex 2 as the root. The level 1 vertices are 5, 6, and 7. The level 2 vertices are 8 (through vertex 6) and 0 (through vertex 7). Only vertex 1 is at level 3 (through vertex 0). Finally, the level 4 vertices are 3 and 4 (both through vertex 1). It is interesting to note that the outcome is quite different for each vertex even though we moved the root to a vertex that is only one edge away from the original root. One can view the labeling actions of BFS as constructing a BFS tree that is rooted in the root node of the search. The tree consists of all the labeled vertices and only the edges traversed during the search that go from a vertex at one level to vertices at the next level. Once we have all the vertices labeled with their level, we can easily find a path from the root vertex to any of the vertices where the number of edges traveled is equivalent to the level. For example, in Fig. 18.4(b), we see that vertex 1 is labeled as level 3, so we know that the smallest number of edges between the root (vertex 2) and vertex 1 is 3. If we need to find the path, we can simply start from the destination vertex and trace back to the root. At each step, we select the predecessor whose level is one less than the current vertex. If there are multiple predecessors with the same level, we can randomly pick one. Any vertex thus selected would give a sound solution. The fact that there are multiple predecessors to choose from means that there are multiple equally good solutions to the problem. In our example, we can find a shortest path from vertex 2 to vertex 1 by starting from vertex 1, choosing vertex 0, then vertex 7, and then vertex 2. Therefore, a solution path is 2→7→0→1. This of course assumes that each vertex has a list of the source vertices of all the incoming edges so that one can find the predecessors of a given vertex. Fig. 18.5 shows an important application of breadthfirst search in computer aided design (CAD). When designing an integrated circuit chip, there are many electronic components that need to be connected to complete the design. The connectors of these components are called net terminals. Fig. 18.5(a) shows two such net terminals as round dots, one belongs to a component in the upper left part and the other belongs to another component in the lower right part of the chip. Assume that the design requires that these two net terminals be connected. This is done by running, or routing, a wire of a given width from the first net terminal to the second net terminal. The routing software represents the chip as a grid of wiring blocks where each block can potentially serve as a piece of a wire. A wire can be formed by extending in either the horizontal or the vertical direction. For example, the black J-shaped obstacle in the lower half of the chip consists of 21 wiring blocks and connects three net terminals. Once a wiring block is used as part of a wire, it can no longer be used as part of any other wires. Furthermore, it forms a blockage for wiring blocks around it. No wires can be extended from a used block’s lower neighbor to its upper neighbor, or from its left neighbor to its right neighbor, etc. Once a wire is formed, all other wires must the routed around it. Routing blocks can also be occupied by circuit components, which imposes the same blockage constraint as when they are used as part of a wire. This is why the problem is called a maze routing problem. The previously formed circuit components and wires form a maze for the wires that are yet to be formed. The maze routing software finds a route for each additional wire given all the constraints from the previously formed components and wires. The maze routing application represents the chip as a graph. The routing blocks are vertices. An edge from vertex i to vertex j indicates that one can extend a wire from block i to block j. Once a block is occupied by a wire or a component, it is either marked as a blockage vertex or taken away from the graph, depending on the design of the application. Fig. 18.5 shows that the application solves the maze routing problem with a breadthfirst search from the root net terminal to the target net terminal. This is done by starting with the root vertex and labeling the vertices into levels. The immediate vertical or horizontal neighbors (a total of four) that are not blockages are marked as level 1. We see that all four neighbors of the root are reachable and will be marked as level 1. The neighbors of level 1 vertices that are neither blockages nor visited by the current search will be marked as level 2. The reader should verify that there are four level-1 vertices, eight level-2 vertices, and twelve level-3 vertices, etc. in Fig. 18.5(a). As we can see, the breadthfirst search essentially forms a wavefront of vertices for each level. These wavefronts start small for level 1 but can grow very large very quickly in a few levels. Fig. 18.5(b) shows that once the breadthfirst search is complete, we can form a wire by finding a shortest path from the root to the target. As explained earlier, this can be done by starting with the target vertex and tracing back to the predecessors whose levels are one lower than the current vertex. Whenever there are multiple predecessors that have equivalent levels, there are multiple routes that are of the same length. One could design heuristics to choose the predecessor in such a way that minimizes the difficulty of constraints for wires that are yet to be formed.
18.3 Vertex-centric parallelization of BFS
A natural way to parallelize graph algorithms is to perform operations on different vertices or edges in parallel. In fact, many parallel implementations of graph algorithms can be classified as vertex-centric or edge-centric. A vertex-centric parallelimplementation assigns threads to vertices and has each thread perform an operation on its vertex, which usually involves iterating over the neighbors of that vertex. Depending on the algorithm, the neighbors of interest may be those that are reachable via the outgoing edges, the incoming edges, or both. In contrast, an edge-centric parallel implementation assigns threads to edges and has each thread perform an operation on its edge, which usually involves looking up the source and destination vertices of that edge. In this section, we look at two different vertex-centric parallel implementations of BFS: one that iterates over outgoing edges and one that iterates over incoming edges. In Section 18.4, we look at an edge-centric parallel implementation of BFS and compare. The parallel implementations we will look at follow the same strategy when it comes to iterating over levels. In all implementations, we start by labeling the root vertex as belonging to level 0. We then call a kernel to label all the neighbors of the root vertex as belonging to level 1. After that, we call a kernel to label all the unvisited neighbors of the level 1 vertices as belonging to level 2. Then, we call a kernel to label all the unvisited neighbors of the level 2 vertices as belonging to level 3. This process continues until no new vertices are visited and labeled. The reason a separate kernel is called for each level is that we need to wait until all vertices in a previous level are labeled before proceeding to label vertices in the next level. Otherwise, we risk labeling a vertex incorrectly. In the rest of this section, we focus on implementing the kernel that is called for each level. That is, we will implement a BFS kernel that, given a level, labels all the vertices that belong to that level based on the labels of the vertices from previous levels. We will revise this approach in Section 18.7 where we will iterate over multiple BFS levels with a single kernel. The first vertex-centric parallel implementation assigns each thread to a vertex to iterate over the vertex’s outgoing edges. Each thread first checks if its vertex belongs to the previous level. If so, the thread iterates over the outgoing edges to label all the unvisited neighbors as belonging to the current level. This vertex-centric implementation is often referred to as a top-down or push implementation.1 Since this implementation requires accessibility to the outgoing edges of a given source vertex (i.e., non-zero elements of a given row of the adjacency matrix), a CSR representation is needed. Fig. 18.6 shows the kernel code for the vertex-centric push implementation, while Fig. 18.7 shows an example of how this kernel performs a traversal from level 1 (previous level) to level 2 (current level). The kernel starts by assigning a thread to each vertex (line 03) and each thread ensures that its vertex id is within bounds (line 04). Next, each thread checks if its vertex belongs to the previous level (line 05). In Fig. 18.7, only the threads assigned to vertices 1 and 2 pass this check. The threads 1 If we are constructing a BFS tree, this implementation can be seen as assigning threads to parent vertices in the BFS tree in search of their children, hence the name top-down. This terminology assumes that the root of the tree is on the top and the leaves of the tree are at the bottom. Push refers to each active vertex’s action of pushing its depth via its outgoing edges to all its neighbors.
FIGURE 18.6. A vertex-centric push (top-down) BFS kernel.
FIGURE 18.7. Example of a vertex-centric push BFS traversal from level 1 to level 2.
that pass this check then use the CSR srcPtrs array to locate the outgoing edges of the vertex and iterate over them (lines 06-07). For each outgoing edge, the thread finds the neighbor at the destination of the edge using the CSR dst array (line 08). The thread then checks if the neighbor has not been visited (line 09). To enable this check, all vertex levels are initially set to a special value UNVISITED. For example, UNVISITED could be set to the largest possible unsigned integer cuda::std::numeric_limits
situations are technically race conditions: multiple threads access the same memory location without ordering and at least one of the accesses is a write. As discussed in Chapter 14, such race conditions are benign in practice because the operation is idempotent, having the same effect regardless of how many times it is applied. However, although this code may work in practice, it violates the C++ memory model and is not guaranteed to work. Conservative programmers should use an atomic operation for these two operations. The second vertex-centric parallel implementation assigns each thread to a vertex to iterate over the vertex’s incoming edges. Each thread first checks if its vertex has been visited yet. If not, the thread will iterate over the incoming edges to find if any of the neighbors belong to the previous level. If the thread finds a neighbor that belongs to the previous level, the thread will label its vertex as belonging to the current level. This vertex-centric implementation is often referred to as a bottom-up or pull implementation.2 Since this implementation requires accessibility to the incoming edges of a given destination vertex (i.e., non-zero elements of a given column of the adjacency matrix), a CSC representation is needed. Fig. 18.8 shows the kernel code for the vertex-centric pull implementation, while Fig. 18.9 shows an example of how this kernel performs a traversal from level 1 to level 2. The kernel starts by assigning a thread to each vertex (line 03) and each thread ensures that its vertex id is within bounds (line 04). Next, each thread checks if its vertex has not been visited yet (line 05). In Fig. 18.9, the threads assigned to vertices 3 to 8 all pass this check. The threads that pass this check use the CSC dstPtrs array to locate the incoming edges of the vertex and iterate over them (lines 06-07). For each incoming edge, the thread finds the neighbor at the source of the edge using 2 If we are constructing a BFS tree, this implementation can be seen as assigning threads to potential childvertices in the BFS tree in search of their parents, hence the name bottom-up. Pull refers to each vertex’s action of reaching back to its predecessors and pulling active status from them.
FIGURE 18.9. Example of a vertex-centric pull (bottom-up) traversal from level 1 to level 2.
the CSC src array (line 08). The thread then checks if the neighbor belongs to the previous level (line 09). If so, the thread labels its vertex as belonging to the current level (line 10) and sets a flag indicating that a new vertex has been visited (line 11). The thread also breaks out of the loop (line 12). The justification for breaking out of the loop is as follows. For a thread to establish that its vertex is in the current level, it is sufficient for the thread’s vertex to have one neighbor in the previous level. Therefore, it is unnecessary for the thread to check the rest of the neighbors. Only the threads whose vertices do not have any neighbors in the previous level end up looping over the entire neighbors list. In Fig. 18.9, only the thread assigned to vertex 8 loops over the entire neighbor list without breaking. When comparing the push and pull vertex-centric parallel implementations, there are two key differences to consider that have an important impact on performance. The first difference is that in the push implementation, a thread loops over its vertex’s entire neighbor list, whereas in the pull implementation, a thread may break out of the loop early. For graphs with low-degree and low-variance such as road networks or CAD circuit models, this difference may not be important because the neighbor lists are small and similar in size. However, for graphs with high-degree and high-variance such as social networks, the neighbor lists are long and may vary substantially in size resulting in high load imbalance and control divergence across threads. For this reason, breaking out of the loop early can provide substantial performance gains by reducing load imbalance and control divergence. The second important difference between the two implementations is that in the push implementation, only the threads assigned to vertices in the previous level loop over their neighbor list, whereas in the pull implementation, all the threads assigned to any unvisited vertex loop over their neighbor list. For earlier levels, we expect to have a relatively small number of vertices per level and a large number of unvisited vertices in the graph. For this reason, the push implementation typically performs better forearlier levels because it iterates over fewer neighbor lists. In contrast, for later levels, we expect to have more vertices per level and fewer unvisited vertices in the graph. Moreover, the chances of finding a visited neighbor in the pull approach and exiting the loop early are higher. For this reason, the pull implementation typically performs better for later levels. Based on this observation, a common optimization is to use the push implementation for earlier levels, then switch to the pull implementation for later levels. This approach is often referred to as a direction-optimized implementation. The choice of when to switch between implementations usually depends on the type of graph. Graphs with low average degree and variance usually have many levels and it takes a while to reach a point where the levels have many vertices and a substantial number of vertices have already been visited. On the other hand, graphs with high average degree and variance usually have few levels, and the levels grow very quickly. Such graphs where it takes only a few levels to get from any vertex to any other vertex are usually referred to as small world graphs. Because of these properties, switching from the push implementation to the pull implementation usually happens much earlier for graphs with high average degree than for those with low average degree. Recall that the push implementation uses a CSR representation of the graph, whereas the pull implementation uses a CSC representation of the graph. For this reason, if a direction-optimized implementation is to be used, both a CSR and a CSC representation of the graph need to be stored. In many applications, such as social networks or maze routing, the graph is undirected which means that the adjacency matrix is symmetric. In this case, the CSR and CSC representations are equivalent so only one of them needs to be stored and can be used by both implementations.
18.4 Edge-centric parallelization of BFS
In this section, we look at an edge-centric parallel implementation of BFS. In this implementation, each thread is assigned to an edge. It checks if the source vertex of the edge belongs to the previous level and if the destination vertex of the edge is unvisited. If so, it labels the unvisited destination vertex as belonging to the current level. Since this implementation requires accessibility to the source and destination vertices of a given edge (i.e., row and column indices of a given non-zero), a COO data structure is needed. Fig. 18.10 shows the kernel code for the edge-centric parallel implementation, while Fig. 18.11 shows an example of how this kernel performs a traversal from level 1 to level 2. The kernel starts by assigning a thread to each edge (line 03) and each thread ensures that its edge id is within bounds (line 04). Next, each thread finds the source vertex of its edge using the COO src array (line 05) and checks if the vertex belongs to the previous level (line 06). In Fig. 18.11, only the threads assigned to the outgoing edges of vertices 1 and 2 pass this check. The threads that pass this check locate the neighbor at the destination of the edge using the COO dst array (line 07) and check if the neighbor has not been visited (line 08). If not, the thread labels the FIGURE 18.10 An edge-centric BFS kernel.
FIGURE 18.11. Example of an edge-centric traversal from level 1 to level 2.
neighbor as belonging to the current level (line 09). Finally, the thread sets a flag indicating that a new vertex has been visited (line 10). The edge-centric parallel implementation has two main advantages over the vertex-centric parallel implementations. The first advantage is that the edge-centric implementation exposes more parallelism. In the vertex-centric implementations, if the number of vertices is small, we may not launch enough threads to fully occupy the device. Since a graph typically has many more edges than vertices, the edge-centric implementation can launch more threads. Hence, the edge-centric implementation is usually more suitable for small graphs. The second advantage of the edge-centric implementation over the vertex-centric implementations is that it exhibits less load imbalance and control divergence. In the vertex-centric implementations, each thread iterates over a different number of edges depending on the degree of the vertex it is assigned to. In contrast, in the edge-centric implementation, each thread traverses only one edge. With respect to the vertex-centric implementation, the edge-centric implementation is an example of rearranging the mapping of threads to work/data to reduce control divergence, as discussed in Chapter 6. The edge-centric implementation is usually more suitable for graphs with high average degree and that have a large variation in the degrees of their vertices. The disadvantage of the edge-centric implementation is that it checks every edge in the graph. In contrast, the vertex-centric implementations can skip an entire edgelist if they determine that a vertex is not relevant for the level. For example, consider the case where some vertex v has n edges and is not relevant for a particular level. In the edge-centric implementation, our launch includes n threads, one for each edge, and each of these threads independently inspects v and discovers that the edge is irrelevant. In contrast, in the vertex-centric implementations, our launch only includes one thread for v that skips all n edges after inspecting v once to determine that it is irrelevant. Another disadvantage of the edge-centric implementation is that it uses COO which requires more storage space to store the edges compared to CSR and CSC which are used by the vertex-centric implementations. The reader may have noticed that the code examples in the previous section and this one resemble our implementations of SpMV in Chapter 17. In fact, with a slightly different formulation, we can express a BFS level iteration entirely in terms of SpMV and a few other vector operations, where the SpMV operation is the dominant operation. Beyond BFS, many other graph computations can also be formulated in terms of sparse matrix computations using the adjacency matrix [1]. Such a formulation is often referred to as the linear algebraic formulation of graph problems and is the focus of an API specification called GraphBLAS [2]. The advantage of linear algebraic formulations is that they can leverage mature and highly optimized parallel libraries for sparse linear algebra to perform graph computations. The disadvantage of linear algebraic formulations is that they may miss out on optimizations that take advantage of specific properties of the graph algorithm in question.
18.5 Improving work efficiency with frontiers
In the approaches discussed in the previous two sections, we have been checking every vertex or edge in every iteration for their relevance to the level in question. The advantage of this strategy is that the kernels are highly parallel and do not require any synchronization across threads. However, the disadvantage is that many unnecessary threads are launched every iteration and a lot of wasted work is performed making the approaches not work efficient. For example, in the vertex-centric implementations, we launch a thread for every vertex in the graph, many of which simply discover that the vertex is not relevant and do not perform any work. Similarly, in the edgecentric implementation, we launch a thread for every edge in the graph, many of which simply discover that the edge is not relevant and do not perform any useful work. To quantify the work efficiency of these approaches, let us consider a graph with n vertices and m edges that has a diameter d, i.e., d BFS levels excluding level 0.
FIGURE 18.12. A vertex-centric push (top-down) BFS kernel with frontiers.
Ideally, every vertex and edge is visited only once, making the ideal work complexity of BFS O(n + m). In the vertex-centric push approach, every vertex is checked at every level, but each edge is only traversed once when its source vertex matches the previous level. Hence, the work performed is O(d · n + m). In the vertex-centric pull approach, every vertex is checked at every level, but also, every edge is checked in multiple levels up to the last level as long as its destination vertex is not visited. Hence, the work performed is O(d · n + d · m)). In the edge-centric approach, every edge is checked at every level. Hence, the work performed is O(d · m). None of these work complexities matches the ideal work complexity, which shows that all the implementations are not work-eicient. In this section, we aim to improve the work efficiency of parallel BFS by avoiding launching unnecessary threads and eliminating the redundant checks that they perform in each iteration. We will focus on the vertex-centric push approach that was presented in Section 18.3. Recall that in the vertex-centric push approach, for each level, a thread is launched for each vertex in the graph. The thread checks if its vertex is in the previous level, and if so, it labels all the vertex’s unvisited neighbors as belonging to the current level. On the other hand, the threads whose vertices are not in the current level do not do anything. Ideally, these threads should not even be launched. To avoid launching these threads, we can have the threads processing the vertices in the previous level collaborate to construct a frontier of the vertices that they visit. Hence, for the current level, threads only need to be launched for the vertices in that frontier [3]. In this way, each vertex is only checked once and each edge is only traversed once, which results in O(n + m) work complexity. Fig. 18.12 shows the kernel code for the vertex-centric push implementation that uses frontiers, while Fig. 18.13 shows an example of how this kernel performs a traversal from level 1 to level 2. A key distinction from the previous approach is that the kernel takes additional parameters to represent the frontiers. The additional FIGURE 18.13 Example of a vertex-centric push (top-down) BFS traversal from level 1 to level 2 with frontiers.
parameters include the arrays prevFrontier and currFrontier to store the vertices in the previous and current frontiers, respectively. They also include pointers to the counters numPrevFrontier and numCurrFrontier that store the number of vertices in each frontier. Note that the flag for indicating that a new vertex has been visited is no longer needed. Instead, the host can tell that the end has been reached when the number of vertices in the current frontier is 0. We now look at the body of the kernel in Fig. 18.12. The kernel starts by assigning a thread to each element of the previous frontier (line 05) and each thread ensures that its element id is within bounds (line 06). In Fig. 18.13, only vertices 1 and 2 are in the previous frontier, so only two threads are launched. Each thread loads its element from the previous frontier, which contains the index of the vertex that it is processing (line 07). The thread uses the CSR srcPtrs array to locate the outgoing edges of the vertex and iterate over them (lines 08-09). For each outgoing edge, the thread finds the neighbor at the destination of the edge using the CSR dst array (line 10). The thread then calls a device function visitVertexAtomically that checks if the neighbor has not been visited, and if not, labels the neighbor as belonging to the current level (line 11). The implementation of visitVertexAtomically will be discussed shortly. If the function returns that it succeeded in labeling the neighbor, the thread must add the neighbor to the current frontier. To do so, the thread atomically increments the size of the current frontier (lines 12-15) and inserts the neighbor at the corresponding location (line 16). The size of the current frontier needs to be incremented atomically because multiple threads may be incrementing it simultaneously, so we need to ensure that no race condition takes place. We now turn our attention to the visitVertexAtomically device function that is called on line 11. As a thread iterates through the neighbors of its vertex, it checks FIGURE 18.14 A device function that visits a vertex atomically using an atomic compare-and-swap operation.
if the neighbor has been visited, and if not, it labels the neighbor as belonging to the current level. In the vertex-centric push kernel without frontiers in Fig. 18.12, this checking and labeling operation is performed without atomic operations (09-10). In that implementation, if multiple threads check the old label of the same unvisited neighbor before any of them can label it, multiple threads may end up labeling the neighbor. Since all threads are labeling the neighbor with the same label (the operation is idempotent), it is okay to allow the threads to label the neighbor redundantly. In contrast, in the frontier-based implementation in Fig. 18.12, each thread not only labels the unvisited neighbor, but also adds it to the frontier. Hence, if multiple threads observe the neighbor as unvisited, they will all add the neighbor to the frontier, causing it to be added multiple times. If the neighbor is added multiple times to the frontier, it will be processed multiple times in the next level, which is redundant and wasteful. To avoid having multiple threads observe the neighbor as unvisited, the checking and updating of the neighbor’s label should be performed atomically. In other words, we must check if the neighbor is not visited, and if not, label it as part of the current level all in one atomic operation. An atomic operation that can perform all of these steps is compare-and-swap, which is provided by the C++ function compare_exchange_strong. The visitVertexAtomically device function uses this C++ function to visit the vertex. Fig. 18.14 shows the implementation of the visitVertexAtomically device function. First, we create an atomic reference to level[vertex], i.e., the level of the vertex that we would like to visit (lines 03-04). Using this reference, we invoke the compare_exchange_strong function to atomically update the level value (lines 06-07). The function takes four parameters. The first parameter is the value we want to compare the referenced data to. In our case, we would like to compare level[vertex] to UNVISITED to check if the vertex is unvisited. However, we cannot pass UNVISITED directly because it is a constant and the function expects a reference to an object. For this reason, we create an integer unvisited and initialize it to the constant UNVISITED (line 05), then pass the integer as the first parameter (line 06). The second parameter is the value we would like to set the referenced data to if the comparison succeeds. In our case, we would like to set level[vertex] to the current level if the comparison succeeds, so we pass currLevel as the second parameter (line 07).
The third and fourth parameters are the ordering requirements of the memory accesses performed by the atomic operations in the case of success (third parameter) and failure (fourth parameter), respectively. In our case, the atomic operation does not need to be ordered in a particular way with respect to other independent memory accesses performed by the kernel. For this reason, we select cuda::memory_order_relaxed in both cases (line 07). The return value of the compare_exchange_strong indicates if the swap operation was successful. We take this value and return it as the result of the device function (line 08), indicating if the vertex level was successfully updated. As mentioned earlier, the advantage of this frontier-based approach over the approach described in the previous section is that it reduces redundant work by only launching threads to process the relevant vertices. On the other hand, the disadvantage of this frontier-based approach is the overhead of the long-latency atomic operations, especially when these operations contend on the same data. For the compare-andswap operation used to update the vertex levels, we expect the contention to be moderate because only some threads, not all, will visit the same unvisited neighbor. However, for the atomic addition operation used to increment the frontier size, we expect the contention to be high because all threads increment the same counter to add vertices to the same frontier. In the next section, we look at how this contention can be reduced.
18.6 Reducing contention with privatization
The pattern of having different threads insert elements into a frontier should remind the reader of the unstable filter pattern covered in Chapter 12. Two optimizations that we applied to unstable filter to reduce the contention of atomic operations were coalesced atomic operations and privatization. These two optimizations are also applicable to our frontier-based BFS kernel. As mentioned in Chapter 12, we can assume that the coalescing of atomic operations is applied by the compiler. In this section, we will focus on how to leverage privatization to reduce the contention of atomic operations when adding vertices to the current iteration’s frontier. Recall from Chapter 6 that privatization reduces contention of atomic operations by applying partial updates to a private copy of the data, then updating the public copy when done. Privatization can be applied in the context of concurrent frontier updates (increments to numCurrFrontier) to reduce the contention on inserting into the frontier. We can have each thread block maintain its own private frontier throughout the computation and update the public frontier when done. Hence, threads will only contend on the same data with other threads in the same block. Moreover, the private frontier and its counter can be stored in shared memory, which enables lower-latency atomic operations on the counter and stores to the private frontier. Furthermore, when the private frontier in shared memory is stored to the public frontier in global memory, the accesses can be coalesced.
FIGURE 18.15. A vertex-centric push (top-down) BFS kernel with privatization of frontiers.
Fig. 18.15 shows the kernel code for the vertex-centric push implementation that uses privatized frontiers, while Fig. 18.16 illustrates the privatization of the frontiers. The kernel starts by declaring a private frontier for each thread block in shared mem FIGURE 18.16 Privatization of frontiers example.
ory (lines 07-08). One thread in the block initializes the private frontier’s counter to 0 (lines 09-11) and all threads in the block wait at the __syncthreads() barrier for the initialization to complete before they start using the counter (line 12). The next part of the code is similar to the previous version: each thread loads its vertex from the frontier (line 17), iterates over its outgoing edges (lines 18-19), finds the neighbor at the destination of the edge (line 20), and atomically checks if the neighbor is unvisited and visits it if it is unvisited (line 21). If the thread succeeds in visiting the neighbor, i.e., the neighbor is unvisited, it adds the neighbor to the private frontier. The thread first atomically increments the private frontier counter (lines 22-25). If the private frontier is not full (line 26), the thread inserts the neighbor into the private frontier (line 27). Otherwise, if the private frontier has overflowed, the thread restores the value of the private frontier counter (line 29) and inserts the neighbor to the public frontier by atomically incrementing the public frontier counter (lines 30-33) and storing the neighbor at the corresponding location (line 34). After all threads in a block have iterated over their vertices’ neighbors, they need to store the private frontier elements to the public frontier. First, the threads wait for each other to complete to ensure that no more neighbors will be added to the private frontier (line 39). Next, one thread in the block acts on behalf of the others to allocate space in the public frontier for all the elements in the private frontier (lines 42-48) while all the other threads wait for it (line 49). Finally, the threads iterate over the vertices in the private frontier (lines 52-53) and store them in the public frontier (line 54-55). Notice that the index into the public frontier currFrontierIdx is expressed in terms of currFrontierIdx_s which is expressed in terms of threadIdx.x. Therefore, threads with consecutive thread index values store to consecutive global memory locations, which means that the stores are coalesced.
18.7 Reducing launch overhead with cooperative groups
The BFS kernels that we have developed so far are designed to be called multiple times from the host CPU, once for every BFS level. When frontiers are large, which is the case when processing graphs with high average degree such as social networks, the overhead of launching a grid is negligible compared to the amount of work done by the grid. However, when frontiers are small, which is the case when processing graphs with low average degree such as road networks, the overhead of launching a grid may dominate the overall performance. To mitigate the overhead of launching multiple grids, we would like to be able to perform the entire computation with just a single grid launch. However, doing so would require the ability to perform a grid-wide barrier synchronization in between levels to ensure that threads have finished finding the vertices in a level before proceeding to the next level. Performing such a grid-wide barrier synchronization is possible with the cooperative groups API in CUDA. However, performing a gridwide barrier synchronization imposes a constraint on the number of thread blocks that the grid can be launched with. Recall from Chapter 4 that grids may be launched with a larger number of thread blocks than the number that can be executed simultaneously. In this case, the hardware will schedule and execute as many thread blocks as possible simultaneously and bring in more thread blocks as the older ones complete. The problem with this scheduling approach is that we cannot perform an unrestricted grid-wide barrier synchronization across all thread blocks because it could result in a deadlock. Thread blocks that are scheduled would wait for thread blocks that are not schedule to reach the barrier, while thread blocks that are not scheduled would wait for thread blocks that are scheduled to complete to take their place. To be able to perform a grid-wide barrier synchronization, we need to have the guarantee that all thread blocks participating in the barrier are actively executing on the SMs so they can reach the barrier. To provide this guarantee, we cannot launch a larger number of thread blocks than the maximum number that is allowed to execute simultaneously. To find the maximum number of thread blocks that can execute simultaneously, we can use the CUDA occupancy calculation functions mentioned in Chapter 4. In particular, we can find the maximum number of thread blocks that can execute per SM as follows: int numBlocksPerSM; cudaOccupancyMaxActiveBlocksPerMultiprocessor(&numBlocksPerSM, bfs_kernel, numThreadsPerBlock, 0);
Here, the cudaOccupancyMaxActiveBlocksPerMultiprocessor function takes the kernel of interest bfs_kernel, the number of threads per block, and the amount of dynamic shared memory needed per block (0 in this case) as its second, third, and fourth argument. It calculates the maximum number of thread blocks that can execute per SM and writes the result to numBlocksPerSM whose pointer is passed as the first argument to the function.
Knowing the maximum number of thread blocks that can execute per SM, to find the maximum that can execute in total, we need to find the number of SMs in the target GPU. As mentioned in Chapter 4, the number of SMs in a GPU can be found by querying the device properties as follows: cudaDeviceProp deviceProp; cudaGetDeviceProperties(&deviceProp, 0); int numSMs = deviceProp.multiProcessorCount;
We then find the maximum number of thread blocks that can run simultaneously by multiplying the maximum that can run per SM with the number of SMs as follows: unsigned int numBlocks = numSMs*numBlocksPerSM;
If we launch the grid with only this number of thread blocks, we can perform a gridwide barrier synchronization without fearing deadlock because we know that all the thread blocks will execute simultaneously and can reach the barrier. To be able to use cooperative groups inside the kernel to perform a grid-wide barrier synchronization, we cannot use the usual interface that we introduced in Chapter 2. Instead, we must call the kernel in a special way as follows: void *kernelArgs[] = { (void*)&csrGraph_d, (void*)&level_d, (void*)&prevFrontier_d, (void*)&currFrontier_d, (void*)&numPrevFrontier, (void*)&numCurrFrontier_d }; cudaLaunchCooperativeKernel((void*)bfs_kernel, numBlocks, numThreadsPerBlock, kernelArgs);
We first store all the kernel arguments to a void* array. We then call the kernel via the cudaLaunchCooperativeKernel API and pass to it the kernel to be called, which is bfs_kernel, the number of thread blocks previously computed, the number of threads per block, and the array of kernel arguments. Having seen how the BFS kernel must be called to use cooperative groups, we can now turn our attention to implementing the kernel itself. Fig. 18.17 shows a BFS kernel that iterates over multiple BFS levels and uses cooperative groups to perform a grid-wide barrier synchronization between levels. Before the kernel is defined, we include the cooperative groups library (lines 01-02), which is needed to use the cooperative groups API. At the beginning of the kernel, we obtain a handle on the grid (line 08) which is useful for synchronizing the grid later on. The outermost loop of the kernel iterates over the BFS levels as long as the frontier to be processed is not empty (line 10). Most of the body of this loop (lines 12 to 62) resembles the frontier-based kernel from Fig. 18.15, which reads the vertices in the previous frontier, iterates over their neighbors, and atomically visits the unvisited neighbors while inserting them into the current frontier. The main difference from the code in Fig. 18.15 is that in Fig. 18.15, we assumed that each thread handled a single vertex. On the other hand, in Fig. 18.17, the number of threads is limited by the maximum number that can execute simultaneously, so a single thread may FIGURE 18.17 A multi-level BFS kernel that uses cooperative groups.
have to handle multiple vertices. For this reason, each thread iterates over the vertices it is responsible for (lines 21-22) based on its position in the grid (obtained via grid.thread_rank()) and the total number of threads in the grid (obtained via grid.num_threads()). After the threads of the grid finish constructing the frontier, they must swap the frontiers for the next iteration (lines 65-74) such that the current frontier becomes the previous frontier and the memory used for the previous frontier is repurposed to construct the new current frontier. To do so, the first step is to perform a grid-wide barrier synchronization to ensure that all threads in the grid have finished adding vertices to the current frontier. This grid-wide barrier synchronization is performed by calling the cooperative groups API function grid.sync() (line 65). Next, all the threads read the size of the current frontier to become the size of the new previous frontier (line 66). Another grid-wide barrier synchronization (line 67) ensures that all threads finish reading the size of the current frontier before it is reset to 0 by one of the threads (lines 68-70). Yet another grid-wide barrier synchronization (line 71) ensures that the size of the current frontier is reset to 0 before any thread begins adding to it. Finally, the memory buffers for the frontiers are swapped (lines 72-74) before the threads proceed to the next iteration to construct the frontier for the next level. Note that although three grid-wide barrier synchronizations are used in this implementation, two of them can be eliminated by using a different counter for each level and resetting them all to 0 before the kernel starts. This optimization resembles the double-buffering optimization, but in a more general form. We leave this optimization as an exercise for the reader. Using cooperative groups for grid-wide barrier synchronization has multiple benefits besides just mitigating the overhead of grid launches. One benefit is that performing all BFS iterations in a single kernel frees up the CPU to do other useful work rather than having to call the kernel for each iteration. Another benefit that is not observed in this chapter’s example, but may occur in other contexts, is the ability to keep data in shared memory or registers across grid-wide barrier synchronizations – data that would have otherwise been written to and re-read from global memory if the kernel was terminated and called again. This benefit of fusing kernels to keep data in shared memory or registers is similar to that achieved in Chapter 11 where multiple stages of the grid-wide prefix sum were fused into a single kernel. The difference is that the kernels in Chapter 11 were fused by using grid-wide unidirectional synchronization, as opposed to grid-wide barrier synchronization.
18.8 Other optimizations
Recall that in the vertex-centric implementations, the amount of work to be done by each thread depends on the connectivity of the vertex assigned to it. In some graphs, such as social network graphs, some vertices (celebrities) may have several orders of magnitude higher degrees than others. When this happens, one or a few of the threads can take excessively long and slow down the execution of the entire grid. We haveseen one way to address this issue, which is by using an edge-centric parallel implementation instead. Another way we can potentially address this issue is by sorting the vertices of a frontier into buckets depending on their degree and processing each bucket in a separate kernel with an appropriately sized group of processors. One notable implementation [4] uses three different buckets for vertices with small, medium, and large degrees. The kernel processing the small buckets assigns each vertex to a single thread; the kernel processing the medium buckets assigns each vertex to a single warp; and the kernel processing the large buckets assigns each vertex to an entire thread block. This technique is particularly useful on graphs with a high variation in vertex degrees. While BFS is among the simplest graph applications, it exhibits the challenges characteristic of more complex applications: problem decomposition for extracting parallelism, taking advantage of privatization, implementing fine-grained loadbalancing, and ensuring proper synchronization. Graph computation is applicable to a wide range of interesting problems, particularly in the areas of making recommendations, detecting communities, finding patterns within a graph, and identifying anomalies. One significant challenge is to handle graphs whose size exceeds the memory capacity of the GPU. Another interesting opportunity is to preprocess the graph into other formats or reorder the vertices in the graph before beginning computation in order to expose more parallelism or locality, or facilitate load balancing.
18.9 Summary
In this chapter, we have seen the challenges associated with parallelizing graph traversal computations, using breadthfirst search as an example. We started with a brief introduction to the representation of graphs. We discussed the difference between vertex-centric and edge-centric parallel implementations and observed the trade-offs between them. We saw how to eliminate redundant work and improve work efficiency by using frontiers, and we optimized the use of frontiers using privatization. We also showed how cooperative groups can be used to perform a grid-wide barrier synchronization to avoid the overhead of terminating grids and launching new ones. Finally, we briefly discussed other advanced optimizations to improve load balance. Programmers can already find efficient parallel implementations of many graph algorithms in RAPIDS cuGraph [5]. The techniques and optimizations covered in the chapter equip programmers with the understanding to properly use such libraries, as well as the foundations for using GPUs to accelerate new classes of graph algorithms.
18.10 Exercises
\1. Consider the following directed unweighted graph:
a. Represent the graph using an adjacency matrix. b. Represent the graph in the CSR format. The neighbor list of each vertex must be sorted. c. Parallel BFS is executed on this graph starting from vertex 0 (i.e., vertex 0 is in level 0). For each iteration of the BFS traversal: – If a vertex-centric push implementation is used: A. How many threads are launched? B. How many threads iterate over their vertex’s neighbors? – If a vertex-centric pull implementation is used: A. How many threads are launched? B. How many threads iterate over their vertex’s neighbors? C. How many threads label their vertex? – If an edge-centric implementation is used: A. How many threads are launched? B. How many threads may label a vertex? – If a vertex-centric push frontier-based implementation is used: A. How many threads are launched? B. How many threads iterate over their vertex’s neighbors? 2. Implement the host code for the direction-optimized BFS implementation described in Section 18.3. 3. Modify the kernel in Fig. 18.17 to use only a single grid-wide barrier synchronization per level instead of three.
References
References [1] J. Kepner, J. Gilbert, Graph Algorithms in the Language of Linear Algebra, SIAM, 2011. [2] T.A. Davis, Algorithm 1000: Suitesparse: Graphblas: Graph algorithms in the language of sparse linear algebra, ACM Transactions on Mathematical Software 45 (4) (2019) 1–25. [3] L. Luo, M. Wong, W.-m. Hwu, An effective gpu implementation of breadthfirst search, in: Proceedings of the 47th Design Automation Conference, 2010, pp. 52–55. [4] D. Merrill, M. Garland, A. Grimshaw, Scalable gpu graph traversal, ACM SIGPLAN Notices 47 (8) (2012) 117–128. [5] A. Fender, B. Rees, J. Eaton, Rapids cugraph, in: Massive Graph Analytics, Chapman and Hall/CRC, 2022, pp. 483–493.
CHAPTER
Convolutional neural networks
With special contributions from Juan Gómez-Luna
computing systems that can effectively and timely learn model parameter values from these massive datasets. The readers may find the introduction to machine learning and neural networks in Appendix B helpful. This chapter presents the acceleration of the convolutional neural networks (CNNs) whose demonstrated efficacy in computer vision triggered the first wave of deep learning revolution in 2012. In particular, the convolutional layers of the CNNs have a high compute-to-memory-access ratio, and high levels of parallelism, which makes them a perfect candidate for GPU acceleration. We will present a basic CUDA implementation of the forward (inference) path in a convolutional layer and a few optimizations that improve the speed of this basic implementation. We will then show how one can formulate the convolutional layers into matrix multiplication, which can be systematically accelerated using highly optimized hardware and software in modern GPUs.
References
[1] J. Kepner, J. Gilbert, Graph Algorithms in the Language of Linear Algebra, SIAM, 2011.
[2] T.A. Davis, Algorithm 1000: Suitesparse: Graphblas: Graph algorithms in the language of sparse linear algebra, ACM Transactions on Mathematical Software 45 (4) (2019) 1–25.
[3] L. Luo, M. Wong, W.-m. Hwu, An effective gpu implementation of breadthfirst search, in: Proceedings of the 47th Design Automation Conference, 2010, pp. 52–55.
[4] D. Merrill, M. Garland, A. Grimshaw, Scalable gpu graph traversal, ACM SIGPLAN Notices 47 (8) (2012) 117–128.
[5] A. Fender, B. Rees, J. Eaton, Rapids cugraph, in: Massive Graph Analytics, Chapman and