Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

df64

f64-grade precision from f32 hardware — double-double arithmetic on two f32 words.

Crates.io License CI Platform

jesed.dev · df64.jesed.dev · GitHub


A vendor-agnostic Rust library that delivers double-precision-grade results (~48 bits) from hardware that only exposes fast single precision. Same binary, same numbers, on NVIDIA / AMD / Intel / Metal / DX12 / WebGPU / WASM.

Install

curl -sSf https://df64.jesed.dev/install.sh | sh

Or via cargo:

cargo install df64-cli --git https://github.com/jesedv/df64.git

Usage

df64 bench                    # throughput on this host
df64 verify --samples 2000    # vs 128-bit MPFR reference
use df64_core::Df64;

let a = Df64::from_f64(1.234567890123456);
let b = Df64::from_f64(9.876543210987654);
let c = a * b;  // ~48-bit accurate product
println!("{c}"); // 12.19326311248195

Web demo (WASM)

wasm-pack build crates/df64-wasm --target web --out-dir ../../ui/pkg
cd ui && npm install && npm run dev    # → http://localhost:5173

The demo shows word decomposition, harmonic-sum cancellation, CG solve, GEMM throughput, and the raw WGSL kernels — all running inside 36 KB of WASM.

Architecture

df64/
├── crates/
│   ├── df64-core       # Df64 scalar: 2Sum, 2ProdFast, FMA, field ops
│   ├── df64-linalg     # gemm, axpy, dot, SpMV, CG over Df64
│   ├── df64-shaders    # one WGSL source → any precision, validated by naga
│   ├── df64-verify     # 128-bit GMP/MPFR reference oracle
│   ├── df64-cli        # df64 bench / df64 verify
│   └── df64-wasm       # wasm-bindgen bridge (browser)
├── ui/                 # Vite + WASM interactive demo
├── docs/               # landing page (df64.jesed.dev)
├── docs/math.md        # the roundoff-aware mathematics
└── scripts/            # regression + benchmark scripts

Accuracy

A two-f32 double-double holds ~48 significant bits (2⁻⁴⁸ ≈ 3.6e-15/op). Verified across 10⁵ randomized inputs against a 128-bit MPFR oracle:

kernel measured worst gate
add / sub (operand-scaled) ≤ 2⁻⁴⁶ 2⁻⁴⁴
mul / div (result-scaled) ≤ 2⁻⁴⁸ 2⁻⁴⁶

See docs/math.md for the error-free transformations and running bounds.

Build & test

cargo test                                    # 17 tests + WGSL validation
cargo run -p df64-cli -- verify               # vs 128-bit MPFR
cargo run --release -p df64-cli -- bench      # throughput
./scripts/regress-ref.sh                      # full regression gate

License

MIT OR Apache-2.0, at your option.

About

f64-grade precision from f32 hardware — double-double arithmetic on two f32 pairs. ~48-bit precision on GPUs, WASM, and edge hardware without native f64.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages