a graphblas approach for subgraph counting · 2019. 3. 12. · a graphblas approach for subgraph...

12
A GraphBLAS Approach for Subgraph Counting Langshi Chen Indiana University [email protected] Jiayu Li Indiana University [email protected] Ariful Azad Indiana University [email protected] Lei Jiang Indiana University [email protected] Madhav Marathe University of Virginia [email protected] Anil Vullikanti University of Virginia [email protected] Andrey Nikolaev Intel Corporation [email protected] Egor Smirnov Intel Corporation [email protected] Ruslan Israfilov Intel Corporation ruslan.israfi[email protected] Judy Qiu Indiana University [email protected] ABSTRACT Subgraph counting aims to count the occurrences of a subgraph template T in a given network G. The basic problem of computing structural properties such as counting triangles and other subgraphs has found applications in diverse domains. Recent biological, social, cybersecurity and sensor network applications have motivated solv- ing such problems on massive networks with billions of vertices. The larger subgraph problem is known to be memory bounded and computationally challenging to scale; the complexity grows both as a function of T and G. In this paper, we study the non-induced tree subgraph counting problem, propose a novel layered software- hardware co-design approach, and implement a shared-memory multi-threaded algorithm: 1) reducing the complexity of the paral- lel color-coding algorithm by identifying and pruning redundant graph traversal; 2) achieving a fully-vectorized implementation upon linear algebra kernels inspired by GraphBLAS, which signifi- cantly improves cache usage and maximizes memory bandwidth utilization. Experiments show that our implementation improves the overall performance over the state-of-the-art work by orders of magnitude and up to 660x for subgraph templates with size over 12 on a dual-socket Intel(R) Xeon(R) Platinum 8160 server. We believe our approach using GraphBLAS with optimized sparse linear alge- bra can be applied to other massive subgraph counting problems and emerging high-memory bandwidth hardware architectures. KEYWORDS Subgraph Counting, Color coding, GraphBLAS, Vectorization Permission to make digital or hard copies of part or all of this work for personal or classroom use is granted without fee provided that copies are not made or distributed for profit or commercial advantage and that copies bear this notice and the full citation on the first page. Copyrights for third-party components of this work must be honored. For all other uses, contact the owner/author(s). HPDC’19, June 2019, Phoenix, Arizona, USA © 2019 Copyright held by the owner/author(s). ACM ISBN 978-x-xxxx-xxxx-x/YY/MM. https://doi.org/10.1145/nnnnnnn.nnnnnnn ACM Reference Format: Langshi Chen, Jiayu Li, Ariful Azad, Lei Jiang, Madhav Marathe, Anil Vul- likanti, Andrey Nikolaev, Egor Smirnov, Ruslan Israfilov, and Judy Qiu. 2019. A GraphBLAS Approach for Subgraph Counting. In Proceedings of International ACM Symposium on High-Performance Parallel and Distributed Computing (HPDC’19). ACM, New York, NY, USA, 12 pages. https://doi.org/ 10.1145/nnnnnnn.nnnnnnn 1 INTRODUCTION The naive algorithm of counting the exact number of subgraphs (including a triangle in its simplest form) of size k in a n-vertex network takes O ( k 2 n k ) time and is an NP-hard problem and compu- tationally challenging, even for moderate values of n and k . Never- theless, counting subgraphs from a large network is fundamental in numerous applications, and approximate algorithms are developed to estimate the exact count with statistical guarantees. In protein research, the physical contacts between proteins in the cell are represented as a network, and this protein-protein interaction net- work (PPIN) is crucial in understanding the cell physiology which helps develop new drugs. Large PPINs may contain hundreds of thousands of vertices (proteins) and millions of edges (interactions) while they usually contain repeated local structures (motifs). Find- ing and counting these motifs (subgraphs) is essential to compare different PPINs. Arvind et al.[5] counts bounded treewidth graphs but still has a time complexity super-polynomial to network size n. Alon et al. [2, 3] provide a practical algorithm to count trees and graphs of bounded treewidth (size less than 10) from PPINs of unicellular and multicellular organisms by using the color-coding technique developed in [4]. In online social network (OSN) analysis, the graph size could even reach a billion or trillion, where a motif may not be as simple as a vertex (user) with a high degree but a group of users sharing specific interests. Studying these groups im- proves the design of the OSN system and the searching algorithm. [16] enables an estimate of graphlet (size up to 5) counts in an OSN with 50 million of vertices and 200 million of edges. Although the color-coding algorithm in [2] has a time complexity linear in network size, it is exponential in the size of subgraph. Therefore, efficient parallel implementations are the only viable way to count arXiv:1903.04395v1 [cs.DC] 11 Mar 2019

Upload: others

Post on 08-Sep-2020

3 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: A GraphBLAS Approach for Subgraph Counting · 2019. 3. 12. · A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA Algorithm 1: The dynamic programming

A GraphBLAS Approach for Subgraph CountingLangshi ChenIndiana [email protected]

Jiayu LiIndiana University

[email protected]

Ariful AzadIndiana University

[email protected]

Lei JiangIndiana [email protected]

Madhav MaratheUniversity of [email protected]

Anil VullikantiUniversity of [email protected]

Andrey NikolaevIntel Corporation

[email protected]

Egor SmirnovIntel Corporation

[email protected]

Ruslan IsrafilovIntel Corporation

[email protected]

Judy QiuIndiana [email protected]

ABSTRACTSubgraph counting aims to count the occurrences of a subgraphtemplate T in a given network G. The basic problem of computingstructural properties such as counting triangles and other subgraphshas found applications in diverse domains. Recent biological, social,cybersecurity and sensor network applications have motivated solv-ing such problems on massive networks with billions of vertices.The larger subgraph problem is known to be memory bounded andcomputationally challenging to scale; the complexity grows bothas a function of T and G. In this paper, we study the non-inducedtree subgraph counting problem, propose a novel layered software-hardware co-design approach, and implement a shared-memorymulti-threaded algorithm: 1) reducing the complexity of the paral-lel color-coding algorithm by identifying and pruning redundantgraph traversal; 2) achieving a fully-vectorized implementationupon linear algebra kernels inspired by GraphBLAS, which signifi-cantly improves cache usage and maximizes memory bandwidthutilization. Experiments show that our implementation improvesthe overall performance over the state-of-the-art work by orders ofmagnitude and up to 660x for subgraph templates with size over 12on a dual-socket Intel(R) Xeon(R) Platinum 8160 server. We believeour approach using GraphBLAS with optimized sparse linear alge-bra can be applied to other massive subgraph counting problemsand emerging high-memory bandwidth hardware architectures.

KEYWORDSSubgraph Counting, Color coding, GraphBLAS, Vectorization

Permission to make digital or hard copies of part or all of this work for personal orclassroom use is granted without fee provided that copies are not made or distributedfor profit or commercial advantage and that copies bear this notice and the full citationon the first page. Copyrights for third-party components of this work must be honored.For all other uses, contact the owner/author(s).HPDC’19, June 2019, Phoenix, Arizona, USA© 2019 Copyright held by the owner/author(s).ACM ISBN 978-x-xxxx-xxxx-x/YY/MM.https://doi.org/10.1145/nnnnnnn.nnnnnnn

ACM Reference Format:Langshi Chen, Jiayu Li, Ariful Azad, Lei Jiang, Madhav Marathe, Anil Vul-likanti, Andrey Nikolaev, Egor Smirnov, Ruslan Israfilov, and Judy Qiu.2019. A GraphBLAS Approach for Subgraph Counting. In Proceedings ofInternational ACM Symposium on High-Performance Parallel and DistributedComputing (HPDC’19). ACM, New York, NY, USA, 12 pages. https://doi.org/10.1145/nnnnnnn.nnnnnnn

1 INTRODUCTIONThe naive algorithm of counting the exact number of subgraphs(including a triangle in its simplest form) of size k in a n-vertexnetwork takesO(k2nk ) time and is an NP-hard problem and compu-tationally challenging, even for moderate values of n and k . Never-theless, counting subgraphs from a large network is fundamental innumerous applications, and approximate algorithms are developedto estimate the exact count with statistical guarantees. In proteinresearch, the physical contacts between proteins in the cell arerepresented as a network, and this protein-protein interaction net-work (PPIN) is crucial in understanding the cell physiology whichhelps develop new drugs. Large PPINs may contain hundreds ofthousands of vertices (proteins) and millions of edges (interactions)while they usually contain repeated local structures (motifs). Find-ing and counting these motifs (subgraphs) is essential to comparedifferent PPINs. Arvind et al.[5] counts bounded treewidth graphsbut still has a time complexity super-polynomial to network sizen. Alon et al. [2, 3] provide a practical algorithm to count treesand graphs of bounded treewidth (size less than 10) from PPINs ofunicellular and multicellular organisms by using the color-codingtechnique developed in [4]. In online social network (OSN) analysis,the graph size could even reach a billion or trillion, where a motifmay not be as simple as a vertex (user) with a high degree but agroup of users sharing specific interests. Studying these groups im-proves the design of the OSN system and the searching algorithm.[16] enables an estimate of graphlet (size up to 5) counts in anOSN with 50 million of vertices and 200 million of edges. Althoughthe color-coding algorithm in [2] has a time complexity linear innetwork size, it is exponential in the size of subgraph. Therefore,efficient parallel implementations are the only viable way to count

arX

iv:1

903.

0439

5v1

[cs

.DC

] 1

1 M

ar 2

019

Page 2: A GraphBLAS Approach for Subgraph Counting · 2019. 3. 12. · A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA Algorithm 1: The dynamic programming

HPDC’19, June 2019, Phoenix, Arizona, USA Chen et al.

subgraphs from large-scale networks. To the best of our knowledge,a multi-threaded implementation named FASCIA [32] is consideredto be the state-of-the-art work in this area. Still, it takes FASCIAmore than 4 days (105 hours) to count a 17-vertex subgraph fromthe RMAT-1M network (1M vertices, 200M edges) on a 48-core Intel(R) Skylake processor. While our proposed shared memory multi-threaded algorithm named Pgbsc, which prunes the color-codingalgorithm as well as implements GraphBLAS inspired vectoriza-tion, takes only 9.5 minutes to complete the same task on the samehardware. The primary contributions of this paper are as follows:• Algorithmic optimization. We identify and reduce theredundant computation complexity of the sequential color-coding algorithm to improve the parallel performance by afactor of up to 86.• System design and optimization. We refactor the datastructure as well as the execution order to maximize thehardware efficiency in terms of vector register and mem-ory bandwidth usage. The new design replaces the vertex-programming model by using linear algebra kernels inspiredby the GraphBLAS approach.• Performance evaluation and comparison to priorwork.We characterize the improvement compared to state-of-the-art work Fascia from both of theoretical analysis and ex-periment results, and our solution attains the full hardwareefficiency according to a roofline model analysis.

2 BACKGROUND AND RELATEDWORK2.1 Subgraph Counting by Color codingA subgraph H (VH ,EH ) of a simple unweighted graph G(V ,E) is agraph H whose vertex set and edge set are subsets of those ofG . His an embedding of a template graph T (VT ,ET ) if T is isomorphicto H . The subgraph counting problem is to count the number of allembeddings of a given template T in a network G.

Figure 1: Illustration of the template partitioning within acolored input G = (V ,E)

Color coding [2] provides a fixed parameter tractable algorithmto address the subgraph counting problem whereT is a tree. It has atime complexity of O(ckpoly(n)), which is exponential to templatesize k but polynomial to vertex number n. The algorithm consistsof three main phases:

(1) Random coloring. Each vertex v ∈ G(V ,E) is given an in-teger value of color randomly selected between 0 and k − 1,where k ≥ |VT |. We consider k = |T | for simplicity, and

G(V ,E) is therefore converted to a labeled graph. We con-sider an embedding H as "colorful" if each of its vertices hasa distinct color value. In [4], Alon proves that the probabilityofH being colorful is k !

kk, and color coding approximates the

exact number of H by using the count of colorful H .(2) Template partitioning. When partitioning a template T ,

a single vertex is selected as the root ρ while Ts (ρ) refersto the s-th sub-template rooted at ρ. Secondly, one of theedges (ρ,τ ) adjacent to root ρ is cut, creating two child sub-templates. The child holding ρ as its root is named activechild and denoted as Ts,a (ρ). The child rooted at τ of thecutting edge is named passive child and denoted as Ts,p (τ ).This partitioning recursively applies until each sub-templatehas just one vertex. A dynamic programming process is thenapplied in a bottom-up way through all the sub-templatesTs to obtain the count of T .

(3) Counting by dynamic programming. For each vertexVi ∈ G(V ,E) at each sub-templateTs , we notateN (Vi ,Ts ,Cs )as the count of embeddings of Ts with its root mapped to Viusing a color set Cs drawn from k = |T | colors. Each Cs issplit into a color set Cs,a for Ts,a and another Cs,p for Ts,p .For bottom sub-template |Ts | = 1, N (Vi ,Ts ,Cs ) is 1 only ifCs equals the color randomly assigned to V0 and otherwiseit is 0. For non-bottom sub-template with |Ts | ≥ 1, we haveN (Vi ,Ts ,Cs ) =

∑Vj ∈N (Vi ) N (Vi ,Ts,a ,Cs,a )N (Vj ,Ts,p ,Cs,p ),

where N (Vi ,Ts,a ,Cs,a ) and N (Vj ,Ts,p ,Cs,p ) have been cal-culated in previous steps of the dynamic programming be-cause |Ts,a | ≤ |Ts |, |Ts,p | ≤ |Ts |.

A tree subgraph enumeration algorithm by combining colorcoding with a stream-based cover decomposition was developedin [40]. To process massive networks, [41] developed a distributedversion of color-coding based tree counting solution upon MapRe-duce framework in Hadoop, [33] implemented a MPI-based solu-tion, and [39] [15] pushed the limit of subgraph counting to processbillion-edged networks and trees up to 15 vertices.

Beyond counting trees, a sampling and random-walk based tech-nique has been applied to count graphlets, a small induced graphwith size up to 4 or 5, which include the work of [1] and [16]. Later,[13] extends color coding to count any graph with a treewidth of 2in a distributed system. Also, [31] provides a pruning method onlabeled networks and graphlets to reduce the vertex number byorders of magnitude prior to the actual counting.

Other subgraph topics include: 1) subgraph finding. As in [18],paths and trees with size up to 18 could be detected by using multi-linear detection; 2) Graphlet Frequency Distribution estimates rela-tive frequency among all subgraphs with the same size [11] [29];3) clustering networks by using the relative frequency of their sub-graphs [30].

2.2 GraphBLASA Graph can be represented as its adjacency matrix, and many keygraph algorithms are expressed in terms of linear algebra [21] [22].The GraphBLAS project1 was inspired by the Basic Linear Alge-bra Subprograms (BLAS) familiar to the HPC community withthe goal of building graph algorithms upon a small set of kernels1www.graphblas.org

Page 3: A GraphBLAS Approach for Subgraph Counting · 2019. 3. 12. · A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA Algorithm 1: The dynamic programming

A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA

Algorithm 1: The dynamic programming of color-coding1 forall sub-templates Ts created from partitioning T0, in reverse

order of their partitioning do2 if Ts consists of a single vertex then3 forall Vi ∈ V do4 Ms (i, index of color of Vi ) ← 15 else6 forall vertices Vi ∈ V do7 forall color sets Cs satisfying |C | = |Ts | do8 forall color sets Cs,a and Cs,p created by

splitting Cs satisfying |Cs,a | = |Ts,a | and|Cs,p | = |Ts,p | do

9 Ms (i, Is ) ←∑Vj ∈N (Vi )

Ms,a (i, Is,a )Ms,p (j, Is,p )

10 P ← probability that the template is colorful11 α ← number of automorphisms of T012 f inalCount ← 1

Pα∑i∑C M0(i, IC )

1

such as sparse matrix-vector multiplication (SpMV) and sparsematrix-matrix multiplication (SpGEMM). The GraphBLAS commu-nity standardizes [25] such kernel operations, and a GraphBLASC API has been provided [26]. Systems consistent with Graph-BLAS philosophy include: Combinatorial BLAS [12], GraphMat [34],Graphhulo [20], and GraphBLAS Template Library [37]. Recently,SuiteSparse GraphBLAS [17] provides a sequential implementationof the GraphBLAS C API. GraphBLAST [35] provides a group ofgraph primitives implemented on GPU.

GraphBLAS operations have been successfully employed to im-plement a suite of traditional graph algorithms including Breadth-first traversal (BFS) [34], Single-source shortest path (SSSP) [34],Triangle Counting [6], and so forth. More complex algorithms havealso been developed with GraphBLAS primitives. For example, thehigh-performance Markov clustering algorithm (HipMCL) [8] thatis used to cluster large-scale protein-similarity networks is centeredaround a distributed-memory SpGEMM algorithm.

3 COLOR CODING IN SHARED-MEMORYSYSTEM

Algorithm 1 introduces the implementation of a single iterationof a color-coding algorithm within a multi-threading and shared-memory system, which is adopted by state-of-the-art work likeFascia [32]. We refer to it as the Fascia color coding for the restof the paper, and we will address its performance issues from bothalgorithmic level and system implementation level.

A first for loop over Ts at line 1 implements the dynamic pro-gramming technique introduced in Section 2.1, a second for loopover all vi ∈ G = (V ,E) at line 6 is parallelized by threads. Hence,each thread processes the workload associated with one vertex at atime, and the workload of each thread includes another three forloops: 1) line 7 is a for loop over all the color combination occur-rences Cs , satisfying |Cs | = |Ts |; 2) line 8 describes a loop over allthe color set splits Cs,a and Cs,p , where |Cs,a |, |Cs,p | equals the

Figure 2: Illustrate Line 7 to 13 of Algorithm 1) by a five-vertexG = (V ,E) and a three-vertex templateT . The columnindices inMs,a andMs,p are calculated from their color com-binations by Equation 1.

sizes of partitioned active and passive children of template Ts inSection 2.1; 3) line 9 loops over all of the neighbor vertices of Vito multiply N (Vi ,Ts,a ,Cs,a ) by N (Vj ,Ts,p ,Cs,p ). The Fascia colorcoding uses data structures as follows: 1) using an adjacency listAdj[][] to hold the vertex IDs of each Vi ’s neighbors, i.e., Adj[i][]storesVj ∈ N (Vi ); 2) Using a map to record all the sub-templatesTspartitioned fromT in pairs (s,Ts ). 3) Using an array of dense matrixMs to hold the count data for each sub-template Ts . We have:• Row i of Ms stores count data for each Cs associated to acertain Vi• Column j in Ms stores count data of all Vi associated to acertain color combination Cs .• Ms has |V | rows and

( |T ||Ts |

)columns

We suppose that Ts has an active child Ts,a and a passive childTs,p . To generate an integer index for each color set Cs inMs , [32]proposes an index system that hashes an arbitrary color set C witharbitrary size at line 7 of Algorithm 1 into an unique 32-bit integerindex according to Equation 1.

Ic =

(c11

)+

(c22

)+ · · · +

(chh

)(1)

Here, we have h = |C | integers (color values) satisfying 0 ≤ c1 <c2 < · · · < ch ≤ k − 1, where h ≤ k . We illustrate the major stepsof Algorithm 1 in Figure 2, where a vertex V1 is updating its countvalue from three color combinations for Ts,a and Ts,p . Equation 1calculates the column index value for Ts,a to access the its data inMs,a and Ts,p to access the its data inMs,p , respectively. Since V1has two neighbors of V0,V3, for each Cs , it requiresMs,a (1, Is,a ) tomultiplyMs,p (0, Is,p ) andMs,p (2, Is,p ) accordingly.

Page 4: A GraphBLAS Approach for Subgraph Counting · 2019. 3. 12. · A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA Algorithm 1: The dynamic programming

HPDC’19, June 2019, Phoenix, Arizona, USA Chen et al.

Table 1: Definitions and Notations for Color coding

Notation DefinitionG(V ,E), T Network and template

n,k n = |V | is vertex number, k = |T | is template sizeAG Adjacency matrix of G(V ,E)

Ts , Ts,a , Ts,p The sth sub-template, active child of Ts , passive child of TsCs , Cs,a , Cs,p Color set for Ts , Ts,a , Ts,pN (Vi ,Ts ,Cs ) Count of Ts colored by Cs on Vi

Ms ,Ms,a ,Ms,p Dense matrix to store counts for Ts , Ts,a , Ts,pIs , Is,a , Is,p Column index of color set Cs , Cs,a , Cs,p inMs ,Ms,a ,Ms,p

3.1 Redundancy in Traversing NeighborVertices

The first performance issue we observed in Algorithm 1 exists atthe two-fold for loops from line 7 to line 9. When the sub-templatesize |Ts | ≤ |T |, it is probable to have multiple color combinations,where the passive children hold the same color set Cs,p (i.e., thesame column index) inMs,p while the active children have differentcolor setsCs,a1,Cs,a2, . . . ,Cs,al , where l =

( |T |− |Ts,p ||Ts |− |Ts,p |

). Except for

the last step of dynamic programming where |Ts | = |T | and l = 1,the repeated access toMs,p (:, Is,p ) is considered to be redundant.

Figure 3: Identify the redundancy of Fascia color coding ina two-vertex sub-template Ts , which is further split into anactive child and a passive child.

In Figure 3, we illustrate this redundancy by aTs with two colorstaken out of three. Supposing Ts has an active child Ts,a with onecolor and a passive child Ts,p with one color. The data access toCs,p2 is redundant with respect to that of Cs,p1 because they sharethe same color of green. This redundant data access on passivechildren is non-trivial because it loops over all neighbors of Vi ,where data locality is usually poor. Therefore, we develop a pruningtechnique in Section 4.1 to address this issue.

3.2 Lack of Vectorization and Data LocalityAlthoughMs stores its values in a dense matrix, the index system ofEquation 1 does not guarantee that the looping over Cs,a and Cs,pat line 8 of Algorithm 1 would have contiguous column indices atMs,a andMs,p . For instance, in Figure 2, Is,ca1 = 1, Is,ca1 = 0whileIs,ca3 = 2. Hence, the work by a thread on each row of Ms,a andMs,p cannot be vectorized because of this irregular access pattern.Also, this irregular access pattern compromises the data locality ofcache usage. For example, a cache line that prefetches a 64-Bytechunk from memory address starting at &Ms,a (1, 1) and endingat &Ms,a (1, 16) cannot serve the request to accessMs,a (1, 0). It iseven harder to cache data access to Ms,p because they belong to

different rows (neighbor vertices). We shall address this issue by re-designing data structure and thread execution order in Section 4.2to 4.4.

4 DESIGN AND IMPLEMENTATIONTo resolve the performance issues in Section 3.1 and 3.2, we firstidentify and prune the unnecessary computation and memory ac-cess in Algorithm 1. Secondly, we modify the underlying data struc-ture, the thread execution workflow, and provide a fully-vectorizedimplementation by using linear algebra kernels.

4.1 Pruning Color CombinationsTo remove the redundancy observed in Section 3.1, we first applythe transformation by Equation 2 using the distributive propertyof addition and multiplication,∑

Vj ∈N (i)Ms,a (i, Is,a )·Ms,p (j, Is,p ) = Ms,a (i, Is,a )

∑Vj ∈N (i)

Ms,p (j, Is,p )

(2)where it adds up all theMs,p (j, Is,p ) before multiplyingMs,a (i, Is,a )while keeping the same arithmetic result. The implementation willbe illustrated in detail in Figure 5.

Figure 4: Illustrate steps of pruning optimization from ver-tex 0 in G = (V ,E) with the three color combinations shownin Figure 3. 1) Re-order addition andmultiplication (grey ar-row); 2): prune the vertex neighbor summation.

Secondly, we check whether multiple color combinations sharethe same Cs,p and prune them by re-using the result from its firstoccurrence. In Figure 4, we examine a case with a sub-template Tschoosing two colors out of three. In this case,Ts is split into an activechild Ts,a with one vertex and a passive child Ts,p with one vertex.Obviously, the neighbor traversal of vertex V0 for Cs,a2,Cs,p2 ispruned by using the results from {Cs,a1,Cs,p1}.

Page 5: A GraphBLAS Approach for Subgraph Counting · 2019. 3. 12. · A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA Algorithm 1: The dynamic programming

A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA

Algorithm 1: Color-coding in shared-memory...

6 forall vertices Vi ∈ V do7 forall color sets Cs satisfying |Cs | = |Ts | do8 forall color sets Cs,a and Cs,p created by

splitting Cs satisfying |Cs,a | = |Ts,a | and|Cs,p | = |Ts,p | do

9 Ms (i, Is ) ←∑Vj ∈N (Vi )

Ms,a (i, Is,a )Ms,p (j, Is,p )

Algorithm 2: Pruned color-coding...

6 forall color sets Cs,p satisfying |Cs,p | = |Ts,p | do7 B ← 08 forall Vi ∈ V do9 B(i, Is,p ) ←

∑Vj ∈N (Vi )

Ms,p (j, Is,p )

10 forall vertices Vi ∈ V do11 forall color sets Cs satisfying |Cs | = |Ts | do12 forall color sets Cs,a and Cs,p created by

splitting Cs satisfying |Cs,a | = |Ts,a | and|Cs,p | = |Ts,p | do

13 Ms (i, Is ) ←Ms (i, Is ) +Ms,a (i, Is,a )B(i, Is,p )

1

...

...

Figure 5: Pre-compute the pruned vertex-neighbor traversal by: 1) stripping out the summation of count data Ms,p from itsmultiplication by count data from Ms,a ; 2) storing the summation value of Ms,p and looking it up before multiplying countdata fromMs,a

4.2 Pre-compute Neighbor TraversalFurthermore, the traversal of neighbors to sum upMs,p counts isstripped out from the for loop at line 2 of Algorithm 1 as a pre-computation module shown in Figure 4. We use an array buffer oflength |V | to temporarily hold the summation results for a certainCs,p across all Vi with SumBu f [i] = ∑

Vj ∈N (i)Ms,p (j, Is,p ). Afterthe pre-computation for Cs,p , we write the content of buffer backto Ms,p (Vi , Is,p ) and release SumBu f for the next Cs,p . We thenreplace the calculations of

∑Vj ∈N (i)Ms,p (j, Is,p ) by looking up

their values fromMs,p (i, Is,p ). Meanwhile, except for the |V |-sizedarray buffer, we do not increase the memory footprint for thispre-computation module.

It is worth noting that the pruning of vertex neighbor traversalshall also benefit the performance in a distributed memory system,where the data request to a vertex neighbor would be much ex-pensive than that in a shared-memory system because of explicitinterprocess communication.

4.3 Data Structure for Better LocalityWe replace the adjacency list adj[][] of network G(V ,E) by usingan adjacency matrix AG , where AG (i, j) = 1 if Vj is a neighborof Vi , and otherwise AG (i, j) = 0. The adjacency matrix has twoadvantages in our case:

(1) It enables us to represent the neighbor vertex traversal atline 9 of Algorithm 2 by using a matrix operation.

(2) It allows a pre-processing step upon the sparse matrix toimprove the data locality of the network if necessary.

The pre-processing step would be quite efficient in processing an ex-tremely large network with a high sparsity in a distributed-memorysystem. For example, the Reverse Cuthill-McKee Algorithm (RCM)reduces the communication overhead as well as improves the band-width utilization [7]. Because the sparse matrix would be re-used byeach vertexVi , this additional pre-processing overhead is amortizedand neglected in practice.

For count tables inM[], we keep the dense matrices but changethe data layout in physical memory from row-majored order inFigure 6(a) to column-majored order in Figure 6(b). The column-majored viewpoint reflects a vector form of count data, i.e., thecount data for a certain color combination C is stored in a |V |dimensional vector, which is essential to our next vectorizationeffort, because all of the count data for a certain color combinationC from all vertices Vi ∈ G(V ,E) are now stored in contiguousmemory space.

4.4 Vectorized Thread Execution and MemoryAccess

With the new locality-friendly data structure, we vectorize thecounting tasks and memory access by re-ordering the thread exe-cution workflow. Here the thread is created by users, e.g., we useOpenMP 4.0 to spawn threads.

To vectorize the pre-computation of∑Vj ∈N (i)Ms,p (j,w) for each

vertex Vi , we extend the buffer in Section 3.1 from an |V | dimen-sional array into a |V | × Z matrixMbuf , where Z is a pre-selectedbatch size and data is stored in a row-majored order. We have thefollowing procedure:

(1) For each vertexVi , load the first Z values from rowMs,p (i, :)intoMbuf (i, :).

(2) All rows (vertices) ofMbuf are processed by threads in par-allel.

(3) For each row, a thread sequentially loops over Vj ∈ N (i) tocalculateMs,p (i, z) ← Ms,p (i, z) +Mbuf (j, z).

The batch size value Z shall be a multiple of the SIMD unit lengthor the cache line size, which ensures full utilization of the vectorregister length and the prefetched data in a cache line.

To vectorize the execution of count task at line 9 of Algorithm 1,we change the thread workflow from Figure 6(a) to Figure 6(b). InFigure 6(a), the Fascia color coding has each thread process count-ing work belonging to a vertex at a time. Conversely, in Figure 6(b),we characterize the thread workflow as:

Page 6: A GraphBLAS Approach for Subgraph Counting · 2019. 3. 12. · A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA Algorithm 1: The dynamic programming

HPDC’19, June 2019, Phoenix, Arizona, USA Chen et al.

Figure 6: Comparing the thread execution order, where (a) Fascia color coding (baseline Model) has count data stored inmemorywith a row-majored layout, and (b)Pgbsc (VectorizedModel) has count data stored inmemorywith a column-majoredlayout.

(1) Tasks belong to one color combination but for all vertices inG(V ,E), is dispatched altogether to all threads at a time. Allthreads collaboratively finish these tasks before moving totasks for the next color combination.

(2) For the tasks from the same color combination, each thread isassigned an equal portion of element tasks with consecutiverow numbers inMs,a andMs,p .

(3) For each thread, within its portion of element tasks, thecalculation is vectorized due to the consecutive row numberand the column-majored data storage layout.

Typically |V | has more than one million vertices in the networkand is much larger than the total thread number. Each thread gets aportion of tasks much larger than the SIMD unit length and ensuresfull utilization of its SIMD resource. Furthermore, regular stride 1memory access of each thread onMs,a andMs,p enables an efficientdata prefetching from memory into cache lines.

4.5 Exploit Linear Algebra Kernels

Algorithm 3: SpMV and eMA kernels in Pgbsc1 AG is the adjacency matrix of G(V ,E)2 for s = 0, 1, . . . , S − 1 do3 forall color sets Cs,p satisfying |Cs,p | = |Ts,p | do4 Ms,p (:, Is,p ) ← AGMs,p (:, Is,p )5 forall color sets Cs satisfying |Cs | = |Ts | do6 Ms (:, Is ) ← 07 forall color sets Cs,a and Cs,p , created by splitting Cs

satisfying |Cs,a | = |Ts,a | and |Cs,p | = |Ts,p | do8 Ms (:, Is ) ← Ms (:, Is ) +Ms,a (:, Is,a ) ◦Ms,p (:, Is,p )

1

According to the GraphBLAS philosophy, the looping over avertex’s neighbors is represented as a multiplication of a vectorby the adjacency matrix. Therefore, the looping of neighbors foreach Vi ∈ V for pre-computing Ms,p at line 8,9 of Algorithm 2 iswritten as AGMs,p (:, Is,p ) at line 4 of Algorithm 3, where AG is

the adjacency matrix notated in Section 4.3 and Is,p is the columnindex for a color set Cs,p inMs,p . Such multiplication is identifiedas Sparse Matrix-Vector multiplication (SpMV). To save memoryspace, we store the multiplication result back toMs,p (:, Is,p ) withthe help of a buffer. In practice, our Pgbsc adopts a CompressedSparse Column (CSC) format onAG and the looping over color setsCs,p to do SpMV at line 3,4 in Algorithm 3 is combined with a sparsematrix dense matrix (SpMM) kernel to apply the vectorization inAlgorithm 4.

Algorithm 4: SpMM and eMA kernels in Pgbsc1 AG is the adjacency matrix of G(V ,E)2 for s = 0, 1, . . . , S − 1 do3 Ms,p ← AGMs,p4 forall color sets Cs satisfying |Cs | = |Ts | do5 Ms (:, Is ) ← 06 forall color sets Cs,a and Cs,p , created by splitting Cs

satisfying |Cs,a | = |Ts,a | and |Cs,p | = |Ts,p | do7 Ms (:, Is ) ← Ms (:, Is ) +Ms,a (:, Is,a ) ◦Ms,p (:, Is,p )

1

The vectorized counting task is implemented by an element-wisevector-vector multiplication and addition (named as eMA) kernel atline 7 of Algorithm 4, where vectorMs (:, Ic ),Ms,a (:, Is,a ), andMs,p (:, Is,p ) are retrieved fromMs ,Ms,a , andMs,p , respectively. We codethis kernel by using Intel (R) AVX intrinsics, where multiplicationand addition are implemented by using fused multiply-add (FMA)instruction set that leverages the 256/512-bit vector registers.

5 COMPLEXITY ANALYSISIn this section, we will first analyze the time complexity of thePgbsc algorithm to show a significant reduction. Then, we will givethe formula to estimate the improvement of Pgbsc versus Fascia.

Page 7: A GraphBLAS Approach for Subgraph Counting · 2019. 3. 12. · A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA Algorithm 1: The dynamic programming

A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA

5.1 Time ComplexityWe assume that the size of the sub-templates is uniformly dis-tributed between 1 and n. We will use two matrix/vector operations,sparse matrix dense matrix multiplication (SpMM) and element-wise multiplication and addition (eMA). The time complexity ofSpMV is considered as |E |, and the time complexity of eMA is |V |.

Lemma 5.1. For a template or a sub-templateTs , if the counting ofthe sub-templates of Ts has been completed, then the time complexityof counting Ts is:

O(|E |( |T ||Ts,p |

)+ |V |

( |T ||Ts |

) ( |Ts ||Ts,p |

)). (3)

Proof. Since Ts,p has( |T ||Ts,p |

)color combinations, which re-

quires( |T ||Ts,p |

)times SpMV operations. The total time consumption

of this step is O(|E | ( |T ||Ts,p |)). In the next step, Ts has a total of

( |T ||Ts |

)different color combinations, and its sub-templates have a total of( |Ts ||Ts,p |

)color combinations, a two-layer loop is needed here. The

total time consumption of this step is O(|V | ( |T ||Ts |) ( |Ts ||Ts,p |)). □

Lemma 5.2. For integers l ≤ m ≤ n, and l0 ≤ 0, l1 ≤ 1, . . . , ln ≤n, the following equations hold:

(1) maxm(nm)= O(n−1/22n )

(2) max{m,l }(nm) (m

l)= O(n−13n )

(3) max{l0,l1, ...,ln }∑nm=0

(nm) (mlm

)= O(n−1/23n )

Lemma 5.3. In the worst case, the total time complexity of countinga k-node template using Pgbsc is

O((ek log ( 1δ) 1ϵ2)(|E |2k + |V |k−1/23k )). (4)

Proof. A templatewithk nodes generates up toO(k) sub-templates.And O(ek log ( 1δ ) 1ϵ 2 ) iterations are performed in order to get the(ϵ,δ )-approximation. The conclusion is proved by combining Lemma 5.2.

Table 2: Comparison with Original Subgraph Counting

Timecomplexity One sub-template One iteration

Fascia O(|E | ( |T ||Ts |) ( |Ts ||Ts,p |)) O(|E | · k−1/23k )

PfasciaO(|E | ( |T ||Ts,p |

)+

|V |(( |T ||Ts |) ( |Ts ||Ts,p |)+( |T ||Ts,p |

))) O(|E |2k + |V |k−1/23k )

PgbscO(|E | ( |T ||Ts,p |

)+

|V | ( |T ||Ts |) ( |Ts ||Ts,p |)) O(|E |2k + |V |k−1/23k )

5.2 Estimation of Performance ImprovementIn this section, we present a model to estimate the run time ofPgbsc and its improvement over the original algorithm.

Run time. From the previous analysis, we know that the exe-cution time of Pgbsc on a single sub-template is O(|E | ( |T ||Ts,p |

)+

|V | ( |T ||Ts |) ( |Ts ||Ts,p |)). By supplementing the constant term, we get

runtimePGBSC = α |E |( |T ||Ts,p |

)+ β |V |

( |T ||Ts |

) ( |Ts ||Ts,p |

), (5)

where α and β are constants, and wewill calculate them by applyingthe data fitting. Similarly, we set:

runtimeFASCIA = γ |E |( |T ||Ts |

) ( |Ts ||Ts,p |

). (6)

Through the previous researchwe obtained that the time complexityof the original color-coding algorithm and Pgbsc areO(|E |k−1/23k )and O(|E |2k + |V |k−1/23k ) respectively. Since the |E |2k term isvery close to the actual value, and the k−1/23k term may be over-estimated, to be more rigorous, we assume that the actual run-ning time of the two programs is |E | f (T ) and |E |2k + |V | f (T ) re-spectively. Here T is the input template, and f is a function for T .According to previous analysis, we obtain an upper bound of f :O(f (T )) ≤ O(k−1/23k ). The lower bound of f (T ) is estimated inthis form:

f (T ) =∑Ts

( |T ||Ts |

) ( |Ts ||Ts |

)≥∑Ts

( |T ||Ts |

)|Ts | ≈

∑ii

(k

i

)= n · 2k−1 (7)

Thus, O(k · 2k ) ≤ O(f (T )) ≤ O(k−1/23k ). Comparing the complex-ity of the two algorithmswe obtain: Improvement ≈ γ |E |f (T )

α |E |2k+β |V |f (T ) =γ

α 2kf (T )+β |V |/ |E |

α 2kf (T )+βd

−1.

Since the influence of the constant term is not considered in thecomplexity analysis, we need to fill in the necessary constant terms:

γ (α ·2·k−1+β ·d−1)−1 ≤ Improvement ≤ γ (α ·(23 )k+β ·d−1)−1, (8)

where d is the average degree of the network, α , β ,and γ are con-stants.

For a given graph, the following implications are obtained fromthis formula:

(1) The improvement grows with increasing template size, butno more than an upper bound, which is γ β−1d .

(2) For a relatively small average degree d , the improvement isproportional to d , and the ratio is γ β−1.

(3) For a relatively large average degree d , improvement willapproach an upper bound between γα−1k and γα−1( 32 )k .

6 EXPERIMENTAL SETUP6.1 SoftwareWe use the following three implementations. All of the binariesare compiled by the Intel(R) C++ compiler for Intel(R) 64 targetplatform from Intel(R) Parallel Studio XE 2019, with compilationflags of “-O3“, “-xCore-AVX2", “-xCore-AVX512", and the Intel(R)OpenMP.• Fascia implements the FASCIA algorithm in [32], whichserves as a performance baseline.

Page 8: A GraphBLAS Approach for Subgraph Counting · 2019. 3. 12. · A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA Algorithm 1: The dynamic programming

HPDC’19, June 2019, Phoenix, Arizona, USA Chen et al.

Table 3: Datasets used in the experiments (K=103, M=106)

Data Vertices Edges Avg Deg Max Deg Abbreviation Source

Graph500 Scale=20 600K 31M 48 67K GS20 Graph500 [19]Graph500 Scale=21 1M 63M 51 107K GS21 Graph500 [19]Graph500 Scale=22 2M 128M 53 170K GS22 Graph500 [19]Miami 2.1M 200M 49 10K MI Social network [9]Orkut 3M 230M 76 33K OR Social network [24]NYC 18M 960M 54 429 NY Social network [36]RMAT-1M 1M 200M 201 47K RT1M Synthetic data [14]RMAT(k=3) 4M 200M 52 26K RTK3 Synthetic data [14]RMAT(k=5) 4M 200M 73 144K RTK5 Synthetic data [14]RMAT(k=8) 4M 200M 127 252K RTK8 Synthetic data [14]

• PFascia implements the data structure of Fascia but apply-ing a pruning optimization on the graph traversal.• Pgbsc implements both of pruning optimization and theGraphBLAS inspired vectorization.

6.2 Datasets and Templates

Figure 7: Templates used in experiments

The datasets in our experiments are listed in Table 3, whereGraph500 Scale=20, 21, 22 are collected from [19]; Miami, Orkut,and NYC are from [9] [24] [36]; RMAT are widely used syntheticdatasets generated by the RMAT model [14]. The templates inFigure 7 are from the tests in [32] or created by us. The templatesize increases from 10 to 17 while some templates have two differentshapes.

6.3 HardwareIn the experiments, we use: 1) a single node of a dual-socket Intel(R)Xeon(R) CPU E5-2670 v3 (architecture Haswell), and 2) a single nodeof a dual-socket Intel(R) Xeon(R) Platinum 8160 CPU (architectureSkylake-SP) processors.

Table 4: Node Specification of Testbed

Arch Sockets Cores Threads CPUFreq

PeakPerformance

Haswell 2 24 48 2.3GHz 1500 GFLOPSSkylake 2 48 96 2.1GHz 4128 GFLOPS

Arch L1(i/d) L2 L3 MemorySize

MemoryBandwidth

Haswell 32KB 256KB 30MB 125GB 95GB/sSkylake 32KB 1024KB 33MB 250GB 140GB/s

The Operating System is RedHat Enterprise Linux Server version7.6 for both of the nodes, whose specifications are shown in Table 4.We use Haswell and Skylake to refer to the Intel(R) Xeon(R) CPU E5-2670 v3 and Intel(R) Xeon(R) Platinum 8160 CPU respectively in therest of the paper. The memory bandwidth is measured by STREAMEBenchmark [27] while the peak performance is measured by usingthe Intel(R) Optimized LINPACK Benchmark for Linux. We use,by default, the number of threads equal to the number of physicalcores, i.e., 48 threads on Skylake node and 24 threads on Haswellnode. The threads are bound to cores with a spread affinity. As theSkylake node has twice the memory size and physical cores as theHaswell node, we use it as our primary testbed in the experiments.

7 PERFORMANCE AND HARDWAREUTILIZATION

In Figure 8(a)(b)(c), we scale the template size up to the memorylimitation of our testbed for each dataset, and the reduction of exe-cution time is significant particularly for template sizes larger than14. For instance, Fascia spends four days to process a million-vertexdataset RMAT-1M with template u17 while Pgbsc only spends 9.5minutes. For relatively smaller templates such as u12, Pgbsc stillachieves 10x to 100x the reduction of execution time on datasetsMiami, Orkut, and RMAT-1M. As discussed in Section 5.2, the im-provement is proportional to its average degree. This is observedwhen comparing datasets Miami (average degree of 49) and Orkut(average degree of 76), where Pgbsc achieve 10x and 20x improve-ment on u12 respectively. In Figure 8(d)(e)(f), we scale up the size ofGraph500 datasets in Table 3. Note that all of the Graph500 datasetshave similar average degrees and get similar improvement by Pgbscfor the same template. This implies that Pgbsc delivers the sameperformance boost to datasets with a comparable average degreebut different scales. Finally, in Figure 8(g)(h)(i), we compare RMATdatasets with increasing skewness, which causes the imbalance ofvertex degree distribution. The results show that Pgbsc has compa-rable execution time regardless of the growing degree distributionskewness. In contrast, Fascia spends significantly (2x to 3x) moretime on skewed datasets. To validate the performance gained byusing Pgbsc, we investigate the performance improvement con-tributed by pruning and vectorization, accordingly to Section 7.1and 7.2.

Page 9: A GraphBLAS Approach for Subgraph Counting · 2019. 3. 12. · A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA Algorithm 1: The dynamic programming

A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA

u12 u13 u14 u15-1 u15-20

1

2

163400

944

2,6632,435

152 267 151313

478

18 38 55 160 150

Exe

cutio

nTim

e (s

)

·103

·103

(a) Miamiu12 u13 u14 u15-1 u15-2

0

5

10

15

6422,006

4,374

14,759

12,063

449 920 382 8601,517

30 67 80 238 230

·103

·103

·103

(b) Orkutu12 u13 u14 u15-1 u15-2 u16 u17

0

1

2

3

4

34,089 32,205110,238

379,060

1,535 5,378 11,579

83116 32 34 97

1,592 2,655 4,403350 224 573

452 987

97

·105

·105

·105

·105

(c) RMAT-1M

u12 u13 u14 u15-1 u15-20

1

2

3

132

452923

3,379

2,679

45 85 40 89 1417 14 21 63 56

Exe

cutio

nTim

e (s

)

·103

·103

·103

(d) Graph500 Scale=20u12 u13 u14 u15-1 u15-2

0

2

4

6

8

2891,044

2,036

7,535

5,914

95 178 89 185 31912 26 36 105 102

·103

·103

·103

·103

(e) Graph500 Scale=21u12 u13 u14 u15-1 u15-2

0

5

10

15

20

7642,814

5,477

19,165

15,756

260 533 221 507 91126 53 74 220 194

·103

·103

·103

·103

(f) Graph500 Scale=22

u12 u13 u14 u15-1 u15-20

1

2

3

1,191

4,8909,711

30,08232,084

831 1,618 632 1,653 3,07339 110 170 377 262

Exe

cutio

nTim

e (s

) ·104

·104

·104

(g) RMAT K=3u12 u13 u14 u15-1 u15-2

0

2

4

6

8

2,860 9,906 20,379

89,797

54,429

751 1,445 545 1,374 2,19429 60 82 233 240

·104

·104

·104

·104

(h) RMAT K=5u12 u13 u14 u15-1 u15-2

0

2

4

6

8

5,62019,540

32,951

94,11285,622

831 1,694 581 1,178 2,07325 51 67 217 234

·104

·104

·104

·104

(i) RMAT K=8020406080

100

Util

izat

ion

(%)

FASCIA PFASCIA PGBSC-SPMM PGBSC-EMA

Figure 8: Execution time of Fascia versus PFascia versus Pgbscwith increasing template sizes, from U12 to U17. Tests run ona Skylake node.

7.1 Pruning OptimizationIn Figure 9, we compare six datasets with each starting from thetemplate u12 and up to the largest templates whose count data theSkylake node can hold. Three observations are made: 1) PFasciaachieves a performance improvement of 10x by average and upto 86x. 2) PFascia obtains higher relative performance on largetemplates. For instance, it gets 17.2x improvement for u15-1 whileonly 2.2x for u13 for dataset Orkut. 3) PFascia works better atdatasets with high skewness of degree distribution. Datasets likeMiami and Orkut that have a power law distribution only get 8.5xand 17.2x improvement at u15-1, while the RMAT-1M obtains 41ximprovement.

u12 u13 u14 u15-10

20

40

Templates

Rel

ativ

ePe

rform

ance Miami

Orkut

GS20

GS21

GS22

RT1M

Figure 9: Relative performance of PFascia versus Fasciawith increasing template sizes. Tests are done on a Skylakenode.

7.2 Vectorization OptimizationWe decompose Pgbsc into the two linear algebra kernels SpMMand eMA as described in Section 4.5.

7.2.1 CPU and VPU Utilization. Figure 10(a) first compares theCPU utilization defined as the average number of concurrentlyrunning physical cores. For Miami, PFascia and Fascia achieve60% and 75% of CPU utilization. However, the CPU utilization dropsbelow 50% on Orkut and NYC who have more vertices and edgesthan Miami. Conversely, SpMM kernel keeps a high ratio of 65% to78% for all three of the datasets, and the eMA kernel has a growingCPU utilization fromMiami (46%) to NYC (88%). We have two expla-nations: 1) the SpMM kernel splits and regroups the nonzero entriesby their row IDs, which mitigates the imbalance of nonzero entriesamong rows; 2) the eMA kernel has its computation workload foreach column ofMs,a ,Ms,p evenly dispatched to threads.

Secondly, we examine the code vectorization in Figure 10. VPU ina Skylake node is a group of 512-bit registers. The scalar instructionalso utilizes the VPU but it cannot fully exploit its 512-bit length.Figure 10 refers to the portion of instructions vectorized with fullvector capacity. For all of the three datasets, PFascia and Fasciaonly have 6.7% and 12.5% VPU utilization implying that the codesmay not be vectorized, while for SpMM and eMA kernels of Pgbsc,the VPU utilization is 100%. A further metric of packed float pointinstruction ratio (Packed FP) justifies the implication that PFasciaand Fascia have zero vectorized instructions but Pgbsc has all ofits float point operations vectorized.

Page 10: A GraphBLAS Approach for Subgraph Counting · 2019. 3. 12. · A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA Algorithm 1: The dynamic programming

HPDC’19, June 2019, Phoenix, Arizona, USA Chen et al.

Miami Orkut NYC0

20406080

100

Util

izat

ion

(%)

(a) CPU Utilization

Miami Orkut NYC0

20406080

100

Util

izat

ion

(%)

(b) VPU Utilization

Miami Orkut NYC0

20406080

100

Util

izat

ion

(%)

(c) Packed FP0

20406080

100

Util

izat

ion

(%)

FASCIA PFASCIA PGBSC-SPMM PGBSC-EMA

Figure 10: Thehardware utilization on Skylake node for tem-plate u12.

7.2.2 Memory Bandwidth and Cache. Because of the sparsity,subgraph counting is memory-bounded in a shared memory system.Therefore, the utilization of memory and cache resources are criticalto the overall performance. In Table 5, we compare SpMM and eMAof to PFascia and Fascia. It shows that the eMA kernel has thehighest bandwidth value around 110 GB/s for the three datasets,which is due to the highly vectorized codes and regular memoryaccess pattern. Therefore, the data is prefetched into cache lines,which controls the cache miss rate as low as 0.1%.

The SpMM kernel also enjoys a decent bandwidth usage around70 to 80 GB/s by average when compared to PFascia and Fascia.Although SpMM has an L3 miss rate as high as 74% in dataset NYCbecause the dense matrix is larger than the L3 cache capacity. Theoptimized thread level and instruction level vectorization ensures aconcurrent data loading from memory leveraging the high memorybandwidth utilization. Fascia has the lowest memory bandwidthusage because of the thread imbalance and the irregular memoryaccess.

7.2.3 Roofline Model. The roofline model in Figure 11 reflectsthe hardware efficiency. The horizontal axis is the operational in-tensity (FLOP/byte) and the vertical axis refers to the measuredthroughput performance (FLOP/second). The solid roofline is themaximal performance the hardware can deliver under a certainoperational intensity. From Fascia to PFascia, the performancegap to the roofline grows, implying that the pruning optimizationitself does not improve the hardware utilization although it removesredundant computation. From PFascia to Pgbsc, the performancegap to the roofline is reduced significantly, resulting in a perfor-mance point hit by the roofline. This near-full hardware efficiencyis contributed by the vectorization optimization, which exploits thememory bandwidth usage.

Table 5: Memory and Cache Usage on Skylake Node

Miami Bandwidth L1 Miss Rate L2 Miss Rate L3 Miss RateFASCIA 6 GB/s 4.1% 1.8% 85%PFASCIA 48.8 GB/s 9.5% 86.5% 50%PGBSC-SpMM 86.95 GB/s 8.3% 51.2% 36.8%PGBSC-eMA 106 GB/s 0.3% 20.6% 9.9%Orkut Bandwidth L1 Miss Rate L2 Miss Rate L3 Miss RateFASCIA 8 GB/s 9.6% 5.3% 46%PFASCIA 30 GB/s 8.4% 76.2% 46%PGBSC-SpMM 59.5 GB/s 6.7% 42.8% 45%PGBSC-eMA 116 GB/s 0.32% 22.2% 9.0%NYC Bandwidth L1 Miss Rate L2 Miss Rate L3 Miss RateFASCIA 7 GB/s 2.4% 8.1% 87%PFASCIA 38 GB/s 10% 90% 81%PGBSC-SpMM 96 GB/s 7.7% 76% 74%PGBSC-eMA 122 GB/s 0.1% 99% 14.8%

1/324

16

64

PGBSC-MiamiPGBSC-Orkut

Baseline-Miami

Baseline-OrkutPruned-Miami

Pruned-Orkut

Operational Intensity (FLOPS/byte)

Thro

ughp

ut(G

FLO

PS

)

Memory Bound Roofline

1/16 1/8 1/4 1/2

Figure 11: Apply roofline model to Fascia, PFascia,and Pg-bsc. DatasetMiami, Orkut for template u15-1. Tests are doneon a Skylake node.

Figure 12 compares the performance of Pgbsc between the Sky-lake node and the Haswell node. For both test beds, we set upthreads numbered equal to their physical cores, and Skylake nodein has a 1.7x improvement over Haswell node. Although the Sky-lake node doubles the CPU cores compared to the Haswell node,it increases the peak memory bandwidth by only 47% in Table 4.As Pgbsc is bounded by the memory roofline in Figure 11, the esti-mated improvement shall be a value between 1.47x and 2x, and the1.7x improvement by Pgbsc is reasonable.

u12 u13GS20u14 u15-1u15-2 u12 u13

GS21u14 u15-1u15-2 u12 u13

GS22u14 u15-1 u15-2

0

5

10

15

Thro

ughp

ut(G

FLO

P/s

ec)

1.81.71.81.71.71.71.81.81.81.8

1.31.51.61.71.7

Relative Performance(Skylake/Haswell)Haswell Skylake

Figure 12: The performance throughput of Pgbsc onHaswell node versus. Skylake node.

Page 11: A GraphBLAS Approach for Subgraph Counting · 2019. 3. 12. · A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA Algorithm 1: The dynamic programming

A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA

7.3 Load Balance and Thread Scaling

1 2 4 8 12 24 4802468

Threads Number

Spe

edup

(T(1

)/T(p

)) PFASCIA-RTK3

PGBSC-RTK3

PFASCIA-RTK5

PGBSC-RTK5

PFASCIA-RTK8

PGBSC-RTK8

Figure 13: Thread scaling for RMATdatasets with increasingskewness on a Skylake node.

We perform a strong scaling test using up to 48 threads onSkylake node in Figure 13. We choose RMAT generated datasetswith increasing skewness parameters of K = 3, 5, 8. When K =3, Pgbsc has a better thread scaling than PFascia from 1 to 12threads; after 12 threads, the thread scaling of Pgbsc slows down.As the performance is bounded by memory, which has 6 memorychannels per socket, we have a total of 12 memory channels ona Skylake node that bounds the thread scaling. To the contrary,PFascia is not bounded by the memory bandwidth, which explainswhy it keeps an increasing thread scaling from 12 to 48 threads.Eventually, both of Pgbsc and PFascia obtain a 7.5x speedup at 48threads. When increasing the skewness of datasets to K = 5, 8, thethread scalability of PFascia and Pgbsc both drop down becausethe skewed data distribution brings workload imbalance whenlooping vertex neighbors. However, Pgbsc has a better scalabilitythan PFascia at 48 threads because of the SpMM kernel.

7.4 Error DiscussionPgbsc with its pruning and vectorization optimization only differsfrom the Fascia due to the restructuring of the computation fromAlgorithm 1 to Algorithm 4, and so should give identical resultswith exact arithmetic in Equation 2. However,the range of valuesneeded when processing large templates. As a consequence, bothFascia and our Pgbsc use floating point numbers to avoid overflow.Hence, slightly different results are observed between Fascia andPgbsc due to the rounding error consequent from floating pointarithmetic operations. Figure 14 reports such relative error in therange of 10−6 across all the tests on a Graph500 GS20 dataset withincreasing template sizes, which is negligible.

u3 u5 u7 u10 u12 u13 u14 u15-20

2 · 10-64 · 10-66 · 10-68 · 10-61 · 10-5

Templates

Rel

ativ

eE

rror

Figure 14: Relative error on dataset Graph500 Scale=20. Testsare done on a Skylake node.

7.5 Overall Performance ImprovementFigure 15 shows significant performance improvement of Pgbscover Fascia for a variety of networks and subtemplates; the relativeperformance grows with template sizes.

u12 u13 u14 u15-1101

102

103

Templates

Rel

ativ

ePe

rform

ance

Miami

Orkut

GS20

GS21

GS22

RT1M

RTK3

RTK5

RTK8

Figure 15: Performance improvement of Pgbsc vs. Fasciawith increasing template sizes. Tests are done on a Skylakenode.

For small dataset Miami and template u12, they still achieve 9ximprovement, and for datasets like Graph500 (scale:20) and tem-plates with size starting from u14, Pgbsc achieves around 50x im-provement by average and up to 660x improvement for syntheticdataset RT1M at large template u17.

8 CONCLUSIONAs the single machine with big shared memory and many cores isbecoming an attractive solution to graph analysis problems [28], theirregularity of memory access remains a roadblock to improve hard-ware utilization. For fundamental algorithms, such as PageRank, thefixed data structure and predictable execution order are explored toimprove data locality either in graph traversal approach [23][38] orin linear algebra approach [10]. Subgraph counting, with randomaccess to vast memory region and dynamic programming workflow,requires much more effort to exploit the cache efficiency and hard-ware vectorization. To the best of our knowledge, we are the firstto fully vectorize a sophisticated algorithm of subgraph analysis,and the novelty is a co-design approach to combine algorithmicimprovement with pattern identification of linear algebra kernelsthat leverage hardware vectorization.

The overall performance achieves a promising improvement overthe state-of-the-art work by orders of magnitude by average andup to 660x (RMAT1M with u17) within a shared-memory multi-threaded system, and we are confident to generalize this Graph-BLAS inspired approach in our future work: 1) enabling counting oftree subgraph with size larger than 30 and subgraph beyond trees;2) extending the shared-memory implementation to distributedsystem upon our prior work [15] [33] [39] [41]; 3) exploring othergraph and machine learning problems by this GraphBLAS inspiredco-design approach; 4) adding support to more hardware architec-tures (e.g, NEC SX-Aurora and NVIDIA GPU). The codebase of ourwork on Pgbsc is made public in our open-sourced repository2.

2https://github.com/DSC-SPIDAL/harp/tree/pgbsc

Page 12: A GraphBLAS Approach for Subgraph Counting · 2019. 3. 12. · A GraphBLAS Approach for Subgraph Counting HPDC’19, June 2019, Phoenix, Arizona, USA Algorithm 1: The dynamic programming

HPDC’19, June 2019, Phoenix, Arizona, USA Chen et al.

9 ACKNOWLEDGMENTSWe gratefully acknowledge generous support from the Intel ParallelComputing Center (IPCC), the NSF CIF-DIBBS 1443054: Middle-ware and High-Performance Analytics Libraries for Scalable DataScience, and NSF BIGDATA 1838083: Enabling Large-Scale, Privacy-Preserving Genomic Computing with a Hardware-Assisted SecureBig-Data Analytics Framework. We appreciate the support fromthe IU PHI grand challenge, the FutureSystems team, and the ISEModelling and Simulation Lab.

REFERENCES[1] Nesreen K Ahmed, Jennifer Neville, Ryan A Rossi, and Nick Duffield. 2015. Effi-

cient graphlet counting for large networks. In Data Mining (ICDM), 2015 IEEEInternational Conference on. IEEE, 1–10.

[2] Noga Alon, PhuongDao, ImanHajirasouliha, FereydounHormozdiari, and S CenkSahinalp. 2008. Biomolecular network motif counting and discovery by colorcoding. Bioinformatics 24, 13 (2008), i241–i249.

[3] Noga Alon and Shai Gutner. 2007. Balanced families of perfect hash functionsand their applications. In International Colloquium on Automata, Languages, andProgramming. Springer, 435–446.

[4] Noga Alon, Raphael Yuster, and Uri Zwick. 1995. Color-coding. Journal of theACM (JACM) 42, 4 (1995), 844–856.

[5] Vikraman Arvind and Venkatesh Raman. 2002. Approximation algorithms forsome parameterized counting problems. In International Symposium on Algo-rithms and Computation. Springer, 453–464.

[6] A. Azad, A. BuluÃğ, and J. Gilbert. 2015. Parallel Triangle Counting and Enumer-ation Using Matrix Algebra. In 2015 IEEE International Parallel and DistributedProcessing Symposium Workshop (2015-05). 804–811. https://doi.org/10.1109/IPDPSW.2015.75

[7] Ariful Azad, Mathias Jacquelin, Aydin Buluç, and Esmond G Ng. 2017. The re-verse Cuthill-McKee algorithm in distributed-memory. In Parallel and DistributedProcessing Symposium (IPDPS), 2017 IEEE International. IEEE, 22–31.

[8] Ariful Azad, Georgios A Pavlopoulos, Christos A Ouzounis, Nikos C Kyrpides,and Aydin Buluç. 2018. HipMCL: a high-performance parallel implementation ofthe Markov clustering algorithm for large-scale networks. Nucleic acids research46, 6 (2018), e33–e33.

[9] Christopher L Barrett, Richard J Beckman, Maleq Khan, VS Anil Kumar, Mad-hav V Marathe, Paula E Stretz, Tridib Dutta, and Bryan Lewis. 2009. Generationand analysis of large synthetic social contact networks. In Winter SimulationConference. Winter Simulation Conference, 1003–1014.

[10] Scott Beamer, Krste Asanović, and David Patterson. 2017. Reducing PageRankcommunication via propagation blocking. In Parallel and Distributed ProcessingSymposium (IPDPS), 2017 IEEE International. IEEE, 820–831.

[11] Marco Bressan, Flavio Chierichetti, Ravi Kumar, Stefano Leucci, and AlessandroPanconesi. 2017. Counting graphlets: Space vs time. In Proceedings of the TenthACM International Conference on Web Search and Data Mining. ACM, 557–566.

[12] Aydın Buluç and John R Gilbert. 2011. The Combinatorial BLAS: Design, im-plementation, and applications. The International Journal of High PerformanceComputing Applications 25, 4 (2011), 496–509.

[13] Venkatesan T Chakaravarthy, Michael Kapralov, Prakash Murali, Fabrizio Petrini,Xinyu Que, Yogish Sabharwal, and Baruch Schieber. 2016. Subgraph counting:Color coding beyond trees. In Parallel and Distributed Processing Symposium, 2016IEEE International. Ieee, 2–11.

[14] Deepayan Chakrabarti, Yiping Zhan, and Christos Faloutsos. 2004. R-MAT: Arecursive model for graph mining. In Proceedings of the 2004 SIAM InternationalConference on Data Mining. SIAM, 442–446.

[15] Langshi Chen, Bo Peng, Sabra Ossen, Anil Vullikanti, Madhav Marathe, LeiJiang, and Judy Qiu. 2018. High-Performance Massive Subgraph Counting UsingPipelined Adaptive-Group Communication. Big Data and HPC: Ecosystem andConvergence 33 (2018), 173.

[16] Xiaowei Chen and John Lui. 2018. Mining graphlet counts in online socialnetworks. ACM Transactions on Knowledge Discovery from Data (TKDD) 12, 4(2018), 41.

[17] Timothy A Davis. 2018. Graph algorithms via SuiteSparse: GraphBLAS: trian-gle counting and K-truss. In 2018 IEEE High Performance extreme ComputingConference (HPEC). IEEE, 1–6.

[18] Saliya Ekanayake, Jose Cadena, Udayanga Wickramasinghe, and Anil Vullikanti.2018. MIDAS: Multilinear Detection at Scale. In 2018 IEEE International Paralleland Distributed Processing Symposium (IPDPS). IEEE, 2–11.

[19] GraphChallenge. 2019. Graph Challenge MIT. https://graphchallenge.mit.edu/data-sets

[20] Dylan Hutchison, Jeremy Kepner, Vijay Gadepally, and Bill Howe. 2016. FromNoSQL Accumulo to NewSQL Graphulo: Design and utility of graph algorithms

inside a BigTable database. In High Performance Extreme Computing Conference(HPEC), 2016 IEEE. IEEE, 1–9.

[21] Jeremy Kepner, Peter Aaltonen, David Bader, Aydın Buluç, Franz Franchetti,John Gilbert, Dylan Hutchison, Manoj Kumar, Andrew Lumsdaine, HenningMeyerhenke, et al. 2016. Mathematical foundations of the GraphBLAS. arXivpreprint arXiv:1606.05790 (2016).

[22] Jeremy Kepner, David Bade, Aydın Buluç, John Gilbert, Timothy Mattson, andHenning Meyerhenke. 2015. Graphs, matrices, and the GraphBLAS: Seven goodreasons. arXiv preprint arXiv:1504.01039 (2015).

[23] Kartik Lakhotia, Rajgopal Kannan, and Viktor Prasanna. 2017. AcceleratingPageRank using Partition-Centric Processing. (2017).

[24] Jure Leskovec and Andrej Krevl. 2014. SNAP Datasets: Stanford Large NetworkDataset Collection. http://snap.stanford.edu/data.

[25] Tim Mattson, David Bader, Jon Berry, Aydin Buluc, Jack Dongarra, ChristosFaloutsos, John Feo, John Gilbert, Joseph Gonzalez, Bruce Hendrickson, et al.2013. Standards for graph algorithm primitives. In 2013 IEEE High PerformanceExtreme Computing Conference (HPEC). IEEE, 1–2.

[26] Timothy G Mattson, Carl Yang, Scott McMillan, Aydin Buluç, and José E Moreira.2017. GraphBLAS C API: Ideas for future versions of the specification. In HighPerformance Extreme Computing Conference (HPEC), 2017 IEEE. IEEE, 1–6.

[27] John D McCalpin et al. 1995. Memory bandwidth and machine balance in currenthigh performance computers. IEEE computer society technical committee oncomputer architecture (TCCA) newsletter 1995 (1995), 19–25.

[28] Yonathan Perez, Rok Sosič, Arijit Banerjee, Rohan Puttagunta, Martin Raison,Pararth Shah, and Jure Leskovec. 2015. Ringo: Interactive graph analytics onbig-memory machines. In Proceedings of the 2015 ACM SIGMOD InternationalConference on Management of Data. ACM, 1105–1110.

[29] Nataša Pržulj. 2007. Biological network comparison using graphlet degree distri-bution. Bioinformatics 23, 2 (2007), e177–e183.

[30] Mahmudur Rahman, Mansurul Alam Bhuiyan, and Mohammad Al Hasan. 2014.Graft: An efficient graphlet counting method for large graph analysis. IEEETransactions on Knowledge and Data Engineering 26, 10 (2014), 2466–2478.

[31] Tahsin Reza, Matei Ripeanu, Nicolas Tripoul, Geoffrey Sanders, and Roger Pearce.2018. PruneJuice: pruning trillion-edge graphs to a precise pattern-matchingsolution. In Proceedings of the International Conference for High PerformanceComputing, Networking, Storage, and Analysis. IEEE Press, 21.

[32] George M Slota and Kamesh Madduri. 2013. Fast approximate subgraph countingand enumeration. In Parallel Processing (ICPP), 2013 42nd International Conferenceon. IEEE, 210–219.

[33] George M Slota and Kamesh Madduri. 2014. Complex network analysis us-ing parallel approximate motif counting. In Parallel and Distributed ProcessingSymposium, 2014 IEEE 28th International. IEEE, 405–414.

[34] Narayanan Sundaram, Nadathur Satish, Md Mostofa Ali Patwary, Subramanya R.Dulloor, Michael J. Anderson, Satya Gautam Vadlamudi, Dipankar Das, andPradeep Dubey. 2015. GraphMat: High Performance Graph Analytics MadeProductive. Proceedings of the VLDB Endowment 8, 11 (2015), 1214–1225. https://doi.org/10.14778/2809974.2809983

[35] Carl Yang, Aydin Buluc, and John D. Owens. 2018. Design Principles for SparseMatrix Multiplication on the GPU. (2018).

[36] Jaewon Yang and Jure Leskovec. 2012. Defining and evaluating network com-munities based on ground-truth. Knowledge & Information Systems 42, 1 (2012),181–213.

[37] P. Zhang, M. Zalewski, A. Lumsdaine, S. Misurda, and S. McMillan. 2016. GBTL-CUDA: Graph Algorithms and Primitives for GPUs. In 2016 IEEE InternationalParallel and Distributed Processing Symposium Workshops (IPDPSW) (2016-05).912–920. https://doi.org/10.1109/IPDPSW.2016.185

[38] Yunming Zhang, Vladimir Kiriansky, Charith Mendis, Saman Amarasinghe, andMatei Zaharia. 2017. Making caches work for graph analytics. In Big Data (BigData), 2017 IEEE International Conference on. IEEE, 293–302.

[39] Zhao Zhao, Langshi Chen, Mihai Avram, Meng Li, Guanying Wang, Ali Butt,Maleq Khan, Madhav Marathe, Judy Qiu, and Anil Vullikanti. 2018. Finding andcounting tree-like subgraphs using MapReduce. IEEE Transactions on Multi-ScaleComputing Systems 4, 3 (2018), 217–230.

[40] Zhao Zhao, Maleq Khan, VS Anil Kumar, and Madhav V Marathe. 2010. Subgraphenumeration in large social contact networks using parallel color coding andstreaming. In Parallel Processing (ICPP), 2010 39th International Conference on.IEEE, 594–603.

[41] Zhao Zhao, Guanying Wang, Ali R. Butt, Maleq Khan, V. S. Anil Kumar, andMadhav V. Marathe. 2012. SAHAD: Subgraph Analysis in Massive NetworksUsing Hadoop. In IEEE International Parallel & Distributed Processing Symposium.