Skip to content

Commit

Permalink
do not use fused mul_add
Browse files Browse the repository at this point in the history
as it appears to have issues as evinced by our failing CI on macOS

rust-lang/rust-clippy#10003
  • Loading branch information
jqnatividad committed Dec 4, 2022
1 parent 545974e commit 12d7c0a
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions src/online.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,17 @@ impl Commute for OnlineStats {
let meandiffsq = (self.mean - v.mean) * (self.mean - v.mean);

self.size += v.size;
// self.mean = ((s1 * self.mean) + (s2 * v.mean)) / (s1 + s2);
self.mean = s1.mul_add(self.mean, s2 * v.mean) / (s1 + s2);

self.mean = ((s1 * self.mean) + (s2 * v.mean)) / (s1 + s2);
/*
below is the fused multiply add version of the statement above
its more performant as we're taking advantage of a CPU instruction
but it appears to have issues on macOS per the CI tests
and it appears that clippy::suboptimal_flops lint that suggested
this made a false-positive recommendation
https://github.com/rust-lang/rust-clippy/issues/10003 */
//self.mean = s1.mul_add(self.mean, s2 * v.mean) / (s1 + s2);

self.q += v.q + meandiffsq * s1 * s2 / (s1 + s2);
}
}
Expand Down

0 comments on commit 12d7c0a

Please sign in to comment.