Skip to content

Commit 15dc0e7

Browse files
bors[bot]frewsxcv
andcommitted
Merge #70
70: Clarify in the docs that `mul_add` is not always faster. r=cuviper a=frewsxcv More info: - rust-lang/rust#49842 - rust-lang/rust#50572 Co-authored-by: Corey Farwell <[email protected]>
2 parents f412562 + 4775dee commit 15dc0e7

File tree

3 files changed

+13
-8
lines changed

3 files changed

+13
-8
lines changed

src/float.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1237,8 +1237,10 @@ pub trait Float
12371237
fn is_sign_negative(self) -> bool;
12381238

12391239
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
1240-
/// error. This produces a more accurate result with better performance than
1241-
/// a separate multiplication operation followed by an add.
1240+
/// error, yielding a more accurate result than an unfused multiply-add.
1241+
///
1242+
/// Using `mul_add` can be more performant than an unfused multiply-add if
1243+
/// the target architecture has a dedicated `fma` CPU instruction.
12421244
///
12431245
/// ```
12441246
/// use num_traits::Float;

src/ops/mul_add.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,8 @@
1-
/// The fused multiply-add operation.
2-
/// Computes (self * a) + b with only one rounding error.
3-
/// This produces a more accurate result with better performance
4-
/// than a separate multiplication operation followed by an add.
1+
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
2+
/// error, yielding a more accurate result than an unfused multiply-add.
3+
///
4+
/// Using `mul_add` can be more performant than an unfused multiply-add if
5+
/// the target architecture has a dedicated `fma` CPU instruction.
56
///
67
/// Note that `A` and `B` are `Self` by default, but this is not mandatory.
78
///

src/real.rs

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -215,8 +215,10 @@ pub trait Real
215215
fn is_sign_negative(self) -> bool;
216216

217217
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding
218-
/// error. This produces a more accurate result with better performance than
219-
/// a separate multiplication operation followed by an add.
218+
/// error, yielding a more accurate result than an unfused multiply-add.
219+
///
220+
/// Using `mul_add` can be more performant than an unfused multiply-add if
221+
/// the target architecture has a dedicated `fma` CPU instruction.
220222
///
221223
/// ```
222224
/// use num_traits::real::Real;

0 commit comments

Comments
 (0)