-
Notifications
You must be signed in to change notification settings - Fork 101
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
simplify exp resolve warnings update update
- Loading branch information
Showing
18 changed files
with
202 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -53,6 +53,7 @@ floorf128 | |
floorf16 | ||
fma | ||
fmaf | ||
fmaf16 | ||
fmax | ||
fmaxf | ||
fmaxf128 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
#[cfg_attr(all(test, assert_no_panic), no_panic::no_panic)] | ||
pub fn fmaf16(x: f16, y: f16, z: f16) -> f16 { | ||
super::generic::fma_big::<f16, f32>(x, y, z) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
use super::super::fenv::{FE_TONEAREST, fegetround}; | ||
use super::super::{CastFrom, CastInto, DFloat, Float, HFloat, IntTy, MinInt}; | ||
|
||
/// FMA implementation when a hardware-backed larger float type is available. | ||
pub fn fma_big<F, B>(x: F, y: F, z: F) -> F | ||
where | ||
F: Float + HFloat<D = B>, | ||
B: Float + DFloat<H = F>, | ||
B::Int: CastInto<i32>, | ||
i32: CastFrom<i32>, | ||
{ | ||
let one = IntTy::<B>::ONE; | ||
|
||
let xy: B = x.widen() * y.widen(); | ||
let result: B = xy + z.widen(); | ||
let mut ui: B::Int = result.to_bits(); | ||
let re = result.exp(); | ||
let zb: B = z.widen(); | ||
|
||
let prec_diff = B::SIG_BITS - F::SIG_BITS; | ||
let excess_prec = ui & ((one << prec_diff) - one); | ||
let halfway = one << (prec_diff - 1); | ||
|
||
// Common case: the larger precision is fine if... | ||
// This is not a halfway case | ||
if excess_prec != halfway | ||
// Or the result is NaN | ||
|| re == B::EXP_MAX | ||
// Or the result is exact | ||
|| (result - xy == zb && result - zb == xy) | ||
// Or the mode is something other than round to nearest | ||
|| fegetround() != FE_TONEAREST | ||
{ | ||
// TODO: feclearexcept | ||
|
||
return result.narrow(); | ||
} | ||
|
||
let neg = ui & B::SIGN_MASK > IntTy::<B>::ZERO; | ||
let err = if neg == (zb > xy) { xy - result + zb } else { zb - result + xy }; | ||
if neg == (err < B::ZERO) { | ||
ui += one; | ||
} else { | ||
ui -= one; | ||
} | ||
|
||
B::from_bits(ui).narrow() | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters