Dynamic Sparse-Matrix Allocation on GPUs

James King, Thomas Gilray, Robert M. Kirby, Matthew MightISC 2016

TL;DR

This paper introduces Dynamic Compressed Sparse Row (DCSR), a novel sparse matrix format designed for efficient dynamic updates on GPUs. DCSR allows for fast insertion of new entries while maintaining SpMV performance comparable to traditional CSR, addressing a critical limitation in existing sparse matrix formats for applications requiring frequent matrix modifications.

What Problem Does This Paper Address?

Many scientific simulations and graph algorithms rely heavily on sparse matrix operations, particularly Sparse Matrix-Vector Multiplication (SpMV). While GPUs offer significant computational power and memory bandwidth, their effectiveness is often hampered by the static nature of common sparse matrix formats like Compressed Sparse Row (CSR). CSR requires a complete matrix rebuild for even a single new entry, which is prohibitively expensive. Other formats like Ellpack (ELL) and Hybrid (HYB) offer some dynamic update capabilities but suffer from memory inefficiency or slow SpMV performance, respectively. This creates a bottleneck for applications that dynamically grow or modify their sparse matrices, such as control-flow analysis or iterative graph algorithms.

Methods

The core contribution of this paper is the Dynamic Compressed Sparse Row (DCSR) format. Unlike CSR, which uses a single contiguous block for each row's data, DCSR segments each row into multiple smaller blocks. This segmentation allows for dynamic allocation of new space within these segments, avoiding the need for a full matrix rebuild.

Key aspects of the DCSR method include:

  • Segmented Rows: Each row is divided into a fixed number of segments, each with its own start and end offset. This provides "slack space" for new entries.
  • Bump-Pointer Allocation: New segments are allocated using a bump-pointer mechanism, which is efficient for dynamic memory management.
  • Defragmentation: Periodically, or when a row reaches its segment limit, a defragmentation process compacts all segments for a row into a single contiguous block. This operation is designed to be efficient, avoiding a full sort.
  • Adaptive Binning (ADCSR): The authors also incorporate an adaptive binning optimization, which groups rows by size and uses specialized kernels for each bin, further improving SpMV performance.

Datasets

The authors evaluated their approach using a suite of sparse-graph benchmarks from the University of Florida sparse-matrix database. These matrices vary in size, number of non-zeros, and row entry distributions, including those exhibiting power-law distributions. Specific matrices mentioned include AMA, CNR, DBL, ENR, EU2, FLI, HOL, IN2, IND, INT, KRO, LJO, RAL, SOC, WEB, and WIK.

Key Insights and Ideas

  • Dynamic Updates are Crucial: Many important applications, especially in graph analytics and static analysis, inherently require dynamic updates to sparse matrices, a capability poorly supported by traditional formats.
  • Segmentation is Key: The DCSR's segmented row approach effectively decouples the need for contiguous storage from the requirement for dynamic updates, offering a sweet spot between memory efficiency and update flexibility.
  • Defragmentation Balances Updates and SpMV: While dynamic updates can slightly degrade SpMV performance, the defragmentation step efficiently restores SpMV performance to near-CSR levels without the overhead of full matrix rebuilds or complex sorting.
  • GPU-Friendly Design: DCSR's structure, particularly with adaptive binning, is well-suited for GPU architectures, leveraging their parallel processing capabilities.

Key Results

  • Update Performance: DCSR showed significant speedups over HYB for streaming updates (average 4.8x) and iterative updates (average 2.5x). For the IND matrix, only DCSR could complete the update operation within memory constraints.
  • SpMV Performance: Fragmented DCSR was 8% slower than defragmented DCSR on average. Defragmented DCSR achieved SpMV times competitive with CSR (1% slower on average). ADCSR (DCSR with adaptive binning) outperformed HYB by an average of 9%.
  • Memory Consumption: DCSR demonstrated significantly smaller memory footprints compared to HYB across most test cases, using up to 20% less memory on average when configured with 4 segments.
  • Conversion Overhead: Conversion to and from CSR was minimal, making DCSR easily adoptable into existing CSR-based workflows.

Limitations and Future Work

  • Defragmentation Overhead: While efficient, defragmentation still incurs some overhead. The frequency of this operation is a tunable parameter.
  • Matrix Size: For very small matrices, kernel launch overhead can dominate, leading to reduced scaling. The authors suggest moving iterations into the kernel itself to mitigate this.
  • Multi-GPU Scaling: While DCSR maps well to multiple GPUs, performance scaling can be affected by the matrix's row distribution strategy.
  • Future Work: The authors suggest applying DCSR to specific applications like control-flow analysis (CFA) and exploring other optimizations like tiling and blocking. They also highlight the potential for improving existing algorithms that currently rebuild matrices between iterations.

Summary updated

BibTeX
@inproceedings{king2016dynamic,
  author = {James King and Thomas Gilray and Robert M. Kirby and Matthew Might},
  title = {{Dynamic Sparse-Matrix Allocation on GPUs}},
  booktitle = {ISC},
  year = {2016},
  doi = {10.1007/978-3-319-41321-1\_4},
}
Figure