TGViewer
C++ - Reddit C++ - Reddit @r_cpp · 230 subscribers
Post #25118 19
I built a C++ integer-to-string library based on a new AVX-512 paper

I built a small C++ integer-to-string conversion library based on a new paper by Jael Champagne Gareau and Daniel Lemire, "Converting an Integer to a Decimal String in Under Two Nanoseconds":

- Project: https://github.com/simditoa/simditoa
- Paper: https://arxiv.org/abs/2604.26019

The paper looks at decimal formatting for integers, which shows up in logging, JSON/CSV/XML serialization, database output, and other places where numbers eventually become text. The interesting part, and the part I wanted to experiment with, is that it uses AVX-512 IFMA instructions to extract multiple decimal digits in parallel, avoiding the usual repeated division/modulo loop and avoiding large lookup tables.

The library exposes a small to_chars-style API:

#include "simditoa.h"

char buf[simditoa::MAX_DIGITS + 1];
size_t len = simditoa::to_chars(12345, buf);
buf[len] = '\0';


Current project shape:

- C++17
- int64_t and uint64_t support
- AVX-512 IFMA + VBMI path for supported x86-64 CPUs
- portable scalar fallback
- CMake package/install support
- tests for edge cases, digit lengths, and randomized values
- a simple benchmark against std::to_chars

The README benchmark currently shows simditoa::to_chars at about 15.82 ns/int versus 36.35 ns/int for std::to_chars on the tested setup, roughly 2.3x faster in that run. The paper reports stronger results for its full algorithm and benchmark suite, including single-core performance ahead of other tested methods, but my repo should be treated as a compact implementation based on the paper rather than a full reproduction of every variant in it.

The core trick is neat: for 8-digit chunks, it uses AVX-512 IFMA with precomputed constants based on floor(2^52 / 10^k) to compute digit positions in parallel, then gathers the digit bytes with AVX-512 byte permutation. Larger values are split into chunks.


https://redd.it/1t2ny62
@r_cpp
GitHub GitHub - simditoa/simditoa: SIMD-accelerated integer-to-string conversion SIMD-accelerated integer-to-string conversion. Contribute to simditoa/simditoa development by creating an account on GitHub.
More from @r_cpp
  1. Oct 4, 2026About alignment, struct layout and the cache... https://meetingcpp.com/blog/items/About-al…
  2. Oct 4, 20260x40: Intro, NB and C++ news, the 10 year anniversary , and the Quiz https://youtu.be/cEjc…
  3. Oct 4, 2026Packing Binary Is Fun, Actually https://hereticpleb.vercel.app/blog/packing-binary-is-fun-…
  4. Oct 3, 2026I've tried "Token Sequence Injection & Modern Macros" and here are my thoughts We had this…
  5. Oct 3, 2026Compile Your First C++26 Program with GCC 16.2 https://techfortalk.co.uk/2026/05/04/compil…
  6. Oct 3, 2026Delegating Constructors Delegating constructors allow the default constructor of a class t…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →