NeurIPS 2026Coming to NeurIPS?Explore papers, orals & directions

Triangle Counting Accelerations: From Algorithm to In-Memory Computing Architecture

Xueyan Wang, Jianlei Yang, Yinglin Zhao, Xiaotao Jia, Rong Yin, Xuhang Chen, Gang Qu, Weisheng ZhaoIEEE Trans. Computers 2021 · DOI

Abstract

Triangle counting (TC) is a cornerstone of graph analytics, yet its performance is severely limited by the "memory wall" in conventional architectures. This paper presents TCIM, an in-memory accelerator that leverages Spin-Transfer Torque Magnetic RAM (STT-MRAM) to perform TC through bitwise logic. By co-optimizing the TC algorithm and hardware, TCIM achieves significant improvements in speed and energy efficiency over state-of-the-art GPUs and FPGAs.

Introduction

Triangle counting is vital for analyzing network structures in social, biological, and communication domains. However, the sparse and random nature of graph data leads to inefficient memory access patterns in Von-Neumann architectures, where data shuffling between memory and processor consumes the majority of time and energy. Processing-In-Memory (PIM) offers a solution, but traditional TC algorithms are often too complex for simple memory-side logic.

Algorithmic Reformulation

To bridge the gap between complex graph tasks and simple memory circuits, the researchers reformulated triangle counting into a series of bitwise operations. For any edge $(i, j)$ in a graph, a triangle exists for every common neighbor of vertices $i$ and $j$. This can be efficiently computed by performing a bitwise AND between row $i$ and column $j$ of the adjacency matrix, followed by a BitCount operation on the result.

Algorithmic flow of TCIM showing the step-by-step bitwise AND and BitCount operations to identify triangles in a graph.

STT-MRAM Computational Fabric

The core of the TCIM architecture is its use of STT-MRAM as a computational fabric. By activating two word-lines simultaneously, the memory array can sum the currents flowing through the selected cells. The combined current is then compared against a reference current ($I_{ref}$) to perform a bitwise AND operation across an entire row in a single cycle. This approach turns the memory array into a logic specialist, bypassing the need for area-hungry arithmetic units.

Hardware implementation of the bitwise AND operation using STT-MRAM cells and current-based sensing logic.

Optimization Strategies

Beyond the core logic, TCIM employs two key optimizations to handle the unique challenges of graph data:

  1. Sparsity-Aware Slicing: Since real-world graphs are highly sparse, the system only processes "valid" slice pairs where both the row and column contain at least one non-zero element. For the largest graphs, this method reduced the required computation by over 99.99%.
  2. Priority Data Replacement: Leveraging the predictable nature of graph traversal, the authors implemented a look-ahead replacement policy. This policy prioritizes keeping data that will be needed soonest, reducing costly memory write operations by 60.5% compared to standard Least Recently Used (LRU) policies.

Results and Discussion

Evaluated against nine real-world datasets from the SNAP collection (ranging from social networks to road maps), TCIM demonstrated remarkable performance gains:

  • Speedup: TCIM achieved a 12.2× speedup over GPUs and a 31.8× speedup over FPGAs.
  • Energy Efficiency: The architecture is 34× more energy-efficient than FPGA-based solutions, thanks to the non-volatile nature of STT-MRAM and minimized off-chip data movement.

While STT-MRAM is still an emerging technology, these results highlight the potential of hardware-algorithm co-design in overcoming the memory wall for specialized graph computing tasks. Future work may explore scaling this architecture to distributed systems for web-scale graph analysis.

Summary updated

BibTeX
@article{wang2021triangle,
  author = {Xueyan Wang and Jianlei Yang and Yinglin Zhao and Xiaotao Jia and Rong Yin and Xuhang Chen and Gang Qu and Weisheng Zhao},
  title = {{Triangle Counting Accelerations: From Algorithm to In-Memory Computing Architecture}},
  journal = {IEEE Trans. Computers},
  year = {2021},
  doi = {10.1109/tc.2021.3131049},
}
Figure