Skip to content

Commit 3cc2c03

Browse files
committed
Port the most recent version of Musl's sqrt as a generic algorithm
Musl commit 97e9b73d59 ("math: new software sqrt") adds a new algorithm using Goldschmidt division. Port this algorithm to Rust and make it generic, which shows a notable performance improvement over the existing algorithm. This also allows adding square root routines for `f16` and `f128`.
1 parent 855e15a commit 3cc2c03

File tree

8 files changed

+450
-393
lines changed

8 files changed

+450
-393
lines changed

etc/function-definitions.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@
704704
"src/libm_helper.rs",
705705
"src/math/arch/i686.rs",
706706
"src/math/arch/wasm32.rs",
707+
"src/math/generic/sqrt.rs",
707708
"src/math/sqrt.rs"
708709
],
709710
"type": "f64"
@@ -712,6 +713,7 @@
712713
"sources": [
713714
"src/math/arch/i686.rs",
714715
"src/math/arch/wasm32.rs",
716+
"src/math/generic/sqrt.rs",
715717
"src/math/sqrtf.rs"
716718
],
717719
"type": "f32"

src/math/generic/mod.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,11 @@
11
mod copysign;
22
mod fabs;
33
mod fdim;
4+
mod sqrt;
45
mod trunc;
56

67
pub use copysign::copysign;
78
pub use fabs::fabs;
89
pub use fdim::fdim;
10+
pub use sqrt::sqrt;
911
pub use trunc::trunc;

0 commit comments

Comments
 (0)