Table of Contents
Fetching ...

Faster Positional-Population Counts for AVX2, AVX-512, and ASIMD

Robert Clausecker, Daniel Lemire, Florian Schintke

TL;DR

This paper tackles the problem of efficiently computing positional population counts (pospopcnt) for arrays of $w$-bit words using SIMD. It extends Klarqvist et al. by introducing a refined Harley-Seal–style approach with simplified CSA networks, head/tail handling, and a fully bit-parallel accumulation that scales down to $w_{ ext{max}}$ and supports short inputs. The authors implement the method across AVX-512, AVX2, and ASIMD, demonstrating memory-bound performance even for input sizes as small as $4~\text{KiB}$ and outperforming prior work on several benchmarks. The work provides open-source implementations and a practical framework for porting to new architectures, with potential impact on bioinformatics, databases, and other domains requiring fast histogram-like computations over bit planes.

Abstract

The positional population count operation pospopcnt() counts for an array of w-bit words how often each of the w bits was set. Various applications in bioinformatics, database engineering, and digital processing exist. Building on earlier work by Klarqvist et al., we show how positional population counts can be rapidly computed using SIMD techniques with good performance from the first byte, approaching memory-bound speeds for input arrays of as little as 4 KiB. Improvements include an improved algorithm structure, better handling of unaligned and very short arrays, as well as faster bit-parallel accumulation of intermediate results. We provide a generic algorithm description as well as implementations for various SIMD instruction set extensions, including Intel AVX2, AVX-512, and ARM ASIMD, and discuss the adaption of our algorithm to other platforms.

Faster Positional-Population Counts for AVX2, AVX-512, and ASIMD

TL;DR

This paper tackles the problem of efficiently computing positional population counts (pospopcnt) for arrays of -bit words using SIMD. It extends Klarqvist et al. by introducing a refined Harley-Seal–style approach with simplified CSA networks, head/tail handling, and a fully bit-parallel accumulation that scales down to and supports short inputs. The authors implement the method across AVX-512, AVX2, and ASIMD, demonstrating memory-bound performance even for input sizes as small as and outperforming prior work on several benchmarks. The work provides open-source implementations and a practical framework for porting to new architectures, with potential impact on bioinformatics, databases, and other domains requiring fast histogram-like computations over bit planes.

Abstract

The positional population count operation pospopcnt() counts for an array of w-bit words how often each of the w bits was set. Various applications in bioinformatics, database engineering, and digital processing exist. Building on earlier work by Klarqvist et al., we show how positional population counts can be rapidly computed using SIMD techniques with good performance from the first byte, approaching memory-bound speeds for input arrays of as little as 4 KiB. Improvements include an improved algorithm structure, better handling of unaligned and very short arrays, as well as faster bit-parallel accumulation of intermediate results. We provide a generic algorithm description as well as implementations for various SIMD instruction set extensions, including Intel AVX2, AVX-512, and ARM ASIMD, and discuss the adaption of our algorithm to other platforms.

Paper Structure

This paper contains 28 sections, 5 equations, 11 figures, 2 tables, 3 algorithms.

Figures (11)

  • Figure 1: Positional population count with $w=3$
  • Figure 2: Pseudo-C function to compute the width-$w$ positional population count
  • Figure 3: Bit-parallel carry-save adder (CSA) networks
  • Figure 4: Algorithm sketches with carry save adder (CSA) networks
  • Figure 5: Intermediate, vectorised accumulation procedure (see § \ref{['sec:intermedaccum']})
  • ...and 6 more figures