#numbers #float #floating-point #eft

safeeft

Safe and branchless error-free transformation algorithms for floating point numbers

4 releases

Uses old Rust 2015

0.0.5 Dec 13, 2017
0.0.4 Dec 2, 2017
0.0.3 Nov 30, 2017
0.0.2 Nov 23, 2017

#1577 in Math

MIT license

20KB
354 lines

safeeft

Safe and branchless error-free transformation algorithms for floating point numbers.

Now supports types which impl num_traits::Float and size of bits of its significand is odd (Because Float does not offer its size).

Documents

Benchmark

With nightly compiler, execute

$ cargo +nightly bench

If your CPU has fma target-feature,

$ RUSTFLAGS='-C target-cpu=native' cargo +nightly bench --features use-fma

If your CPU does not have fma and compile and run with this command, ***_fma will work very slowly due to software emulation of fma.

Sample result

  • compiler: rustc 1.23.0-nightly
  • CPU: Intel Core i5-4570(Haswell)@3.20GHz

twosum

algorithm time (ns) / operation
twosum(not safe) 1.7530
safetwosum_branch 4.4827
safetwosum_straight 4.6438
safetwosum_fma 2.4749

split

algorithm time (ns) / operation
split(not safe) 0.8915
safesplit_branch(not safe) 1.1918
safesplit_straight 3.3454

twoproduct

algorithm time (ns) / operation
twoproduct(not safe) 2.9322
safetwoproduct_branch 3.7826
safetwoproduct_straight 12.9883
safetwoproduct_fma 0.7125

Dependencies

~215KB