KXkonstantinos.xafis
Systems & PerformanceMaintained2022Featured

E-Calculator

CGMPpthreadsMakefile

Overview

Compute Euler’s constant e to as many digits as possible, as fast as possible. Eleven evolving implementations document a long performance journey: from a naive baseline to a fully parallel GMP engine.

What I built

The math: e is the sum of reciprocal factorials, computed with GMP arbitrary-precision integers so only integer multiply/add operations are needed. The algorithm: binary splitting — a divide-and-conquer factorial product (Q_F(a,b)) that splits the series into parallelizable chunks, with split lengths tuned between 2^15 and 2^18.

The parallelism evolved through four designs — multithreaded, semi-multithreaded, SM+ (v9), and full multithreading (v10+): a work-queue architecture (numQueue, bsfQueue, resQueue) with dynamically tuned thread counts over a recompiled GCC with a machine-optimized GMP build.

Verification is not an afterthought: a JavaScript digit-checker diffs the output against reference digits from numberworld.org, and an experimental JS FFT module (TypeScript + Jest) was explored along the way.

Technical highlights

Outcome

One billion digits of e, computed on a laptop, with the entire engineering trail committed to the repository.