arXiv:2610.29988cs.DCOct 2026

Manuscript Offprint

arXiv:2610.29988

Enumeration-based Triangle Counting on GPUs

Sayan Ghosh

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Sayan Ghosh, Pacific Northwest National Laboratory, Email: sg0@pnnl.gov

Abstract—Subgraph enumeration in partitioned graphs across distributed-memory systems is beset with challenges in balancing data movement with the local computation. Especially, counting the number of triangles induced by the closed wedges (i.e., length-3 cycles) is a measure of connectedness in a graph, but often limited by the significant search space caused by open wedges or length-2 paths (usually greater than the number of edges in a graph), which must be inspected to assess whether a particular wedge is closed. To mitigate triangle counting on massive graphs, distributed-memory partitioned-graph approaches are viable (i.e., assessing closed wedges independently within a partition), but load imbalance due to arbitrary communication can overshadow any gains from enhanced concurrency, owing to the inherent lack of structure in regular graphs.

In this paper, we discuss a distributed-memory exact graph triangle counting implementation, and assess its performance over billion-edge real-world graphs on contemporary scale-out and scale-up based NVIDIA ®^{\circledR} GPU platforms (considering NVIDIA “Ampere” and “Hopper” architectures), depicting a scalability spectrum of multiple orders of magnitude. Comparisons with existing state-of-the-art approaches demonstrates up to 10×10\times improvements relative to distributed-memory CPU baseline, 2−100×2-100\times over single-GPU vendor-optimized NVIDIA RAPIDS ®^{\circledR} CUGRAPH and 10–60% over multi-GPU G2G^{2}Miner, in terms of end-to-end execution times.

Index Terms—Graph Analytics, Distributed-memory, MPI, Triangle counting, GPU

I. INTRODUCTION

While a number of complex graph algorithms can be practically solved using approximation algorithms and heuristics (which trade-off computation costs with accuracy), the need for exact algorithms remains for fundamental discrete computations that shed light on the overall structure and stability of the graph or network. One of the simplest computation is calculating the number of triangles or paths of length-3 in a graph. The number of triangles augment several algorithms that quantitatively expresses the connectivity within a graph [1]. However, enumerating triangles at scale requires careful balancing of local computation with associated long-latency data movements, due to prevalence of distance-2 computations (i.e., involving neighbor of a neighbor), causing significant load imbalances. On the contrary, graph traversals such as Breadth-First Search (BFS) exhibit distance-1 computations (i.e., only involving a current neighbor) and fixed-size frontiers, keeping the intermediate memory and associated computations directly proportional to the size of the distributed graph.

For large graphs, the amount of concurrency can be increased via distributed-memory (within and across compute nodes), requiring careful reconciliation of the available concurrency with rising data movement and locality. Contemporary GPUs can indeed enhance the throughput of processing local subgraphs, but can worsen the load imbalance due to expanding the gap between processing and data access. Optimal GPU concurrency requires maximizing the #thread blocks that can be executed in parallel and assumes uniform execution duration of the thread blocks, often challenging to realize for partitioned-graph triangle counting workloads due to non-existent data reuse potential and difficulty in mapping general graphs on multidimensional GPU grid-blocks more suitable for dense or structured-sparse data, causing unavoidable stalls in the data pipeline.

Fig. 1 provides an intuitive representation of triangles induced by 3-length paths in an arbitrary graph, in terms of wedges (length-2 paths), and associated local and distributed-memory computations. Graphs are usually represented in Compressed Sparse Row (CSR) format to store the list of edges (in the form of arrays of indices and edges), and consecutive pairs of edges in CSR can be considered as wedges, considering sorted edge-list. A wedge is “open” if it is not part of a triangle (i.e., 3-length paths), whereas it is considered to be “closed” otherwise. To mitigate the substantial amount of concurrent distance-2 tasks in triangle counting (proportional to the number of open wedges), multithreaded CPUs/GPUs can be used, in conjunction with distributed-memory. Currently, prominent methodologies for triangle counting are

Figure

Local computation (CPU/GPU)

Remote computation (CPU/GPU)

Local vertex

  1. Filter local

wedges (all nodes

in path are owned

by my PE)

  1. Enumerate

closed wedges

Local subgraph in my PE

Remote vertex

  1. Filter remote wedges (one or all nodes in path are owned by another PE)

  2. Communicate/Access list of prospective edges that can close a wedge

  3. PE receives edge-lists, copies to GPU and enumerates

Fig. 1: The process of counting the triangles (i.e., 3-hop paths) in a graph require filtering out wedges (i.e., 2-hop paths) and subsequently enumerating if they are closed. Associated local/global tasks for a single subgraph for a partitioned graph is shown.

based on subgraph matching, set intersection and sparse-matrix multiplication [2]–[5]. Broadly, these methods have two distinct phases: filter and enumerate. In the filter phase, vertices not contributing to the final solution are pruned (e.g., LU matrix decomposition, advance-filter, etc.), optionally building a hash table out of the candidate edges for faster lookup, avoiding neighborhood scans [6]–[9]. Subsequently, the enumerate phase identifies triangles among batches of the filtered candidate edges through set intersections (often considering degree order for reducing redundant computations, e.g., forward methodology [10] and row-permutations [11]) among respective neighbor edge-lists (if {u,v}\{u, v\} is a candidate edge, then the number of triangles formed is N(u)∩N(v)\mathcal{N}(u) \cap \mathcal{N}(v)), where N(x)\mathcal{N}(x) represents neighbor edge-list of an arbitrary vertex xx) or element-wise product between permuted graph adjacency matrix and the corresponding LU factors (if AA is the adjacency matrix and A^\hat{A} represents degree-based row permutation, A^⊙(LU)\hat{A} \odot (LU) operation obtains the exact number of triangles, counted twice).

TriC [12], [13] provides another perspective to triangle counting by exploiting CSR — performing a search per wedge to determine if it is closed. If a graph has ∣V∣|V| vertices ∣E∣|E| edges (usually ∣E∣>>∣V∣|E| >> |V|), this scheme would require a maximum of ∣V∣C2|V|C_2 enumerations, but with filtering, substantial number of edge lists are eliminated. Our approach is derived from this idea, fusing aspects of the filter and enumerate phases applied to batches of edge-lists for devising GPU-based triangle counting. Since modern GPUs have hundreds of thousands of concurrent active threads, each thread can perform the requisite enumerations in parallel, providing better parallel efficiency than multithreaded CPU implementations since relative #enumerations/GPU thread is less than #enumerations/CPU thread (considering similar load imbalance and communication overheads).

Further, existing shared and distributed-memory exact triangle/motif counting approaches considers conditional computing (to facilitate “single” counting), edge replication (i.e., communication free), message aggregation/buffering, serialization, reordering and transparent caching to improve the performance at scale [2], [4], [6]–[9], [13], [14]. This work adopts some of the above strategies in devising GPU-enabled distributed-memory triangle counting, without making special adaptations to the core graph data structure or partitioning (i.e., no intermediate hash tables, probabilistic representations or node/edge replication in distributed context), performing extensive empirical evaluations and analysis. We empirically show that the proposed approach is performant across scaling domains and diverse inputs.

Our contributions are:

  1. Propose adaptations for single exact counting of triangles in undirected graphs on distributed-memory GPU-based systems, devising asynchronous buffered baseline CPU implementation using MPI nonblocking interface, adapting to GPU variants ( §\SII).

  2. Detailed performance assessments (baseline CPU/GPU performance, zero-copy IPC, hybrid CPU-GPU, distributed-memory GPU variants, etc.) on NERSC Perlmutter, ALCF Polaris and NVIDIA ®^{\circledR} DGX ®^{\circledR} dense-GPU systems (with NVIDIA ®^{\circledR} A100 ®^{\circledR} and H100 ®^{\circledR} GPUs) using diverse input graphs ( §\SIII).

  3. Extensive performance comparisons with state-of-art graph frameworks and implementations, considering distributed-memory CPU (TRIC [12], §III-B) and single/multi-GPU (NVIDIA Rapids CUGRAPH [15], TRUST [7] and G2G^{2}Miner [6], §IV).

References (26)