Skip to content

Commit

Permalink
Force fallback to slow round on wasm32
Browse files Browse the repository at this point in the history
  • Loading branch information
shssoichiro committed Oct 27, 2022
1 parent fc05722 commit 1ba208b
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 30 deletions.
15 changes: 8 additions & 7 deletions src/f32x4_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -628,13 +628,14 @@ impl f32x4 {
mask.blend(self, f)
} else if #[cfg(target_feature="simd128")] {
Self { simd: f32x4_nearest(self.simd) }
} else if #[cfg(feature="std")] {
Self { arr: [
self.arr[0].round(),
self.arr[1].round(),
self.arr[2].round(),
self.arr[3].round(),
]}
} else if #[cfg(all(feature="std", not(target_arch="wasm32")))] {
let data = self.to_array();
Self::new([
data[0].round(),
data[1].round(),
data[2].round(),
data[3].round(),
])
} else {
// Note(Lokathor): This software fallback is probably very slow compared
// to having a hardware option available, even just the sse2 version is
Expand Down
23 changes: 12 additions & 11 deletions src/f32x8_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -750,17 +750,18 @@ impl f32x8 {
Self { sse0: round_m128::<{round_op!(Nearest)}>(self.sse0), sse1: round_m128::<{round_op!(Nearest)}>(self.sse1) }
} else if #[cfg(target_feature="simd128")] {
Self { simd0: f32x4_nearest(self.simd0), simd1: f32x4_nearest(self.simd1) }
} else if #[cfg(feature="std")] {
Self { arr: [
self.arr[0].round(),
self.arr[1].round(),
self.arr[2].round(),
self.arr[3].round(),
self.arr[4].round(),
self.arr[5].round(),
self.arr[6].round(),
self.arr[7].round(),
]}
} else if #[cfg(all(feature="std", not(target_arch="wasm32")))] {
let data = self.to_array();
Self::new([
data[0].round(),
data[1].round(),
data[2].round(),
data[3].round(),
data[4].round(),
data[5].round(),
data[6].round(),
data[7].round(),
])
} else {
// Note(Lokathor): This software fallback is probably very slow compared
// to having a hardware option available, even just the sse2 version is
Expand Down
11 changes: 6 additions & 5 deletions src/f64x2_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -588,11 +588,12 @@ impl f64x2 {
Self { sse: round_m128d::<{round_op!(Nearest)}>(self.sse) }
} else if #[cfg(target_feature="simd128")] {
Self { simd: f64x2_nearest(self.simd) }
} else if #[cfg(feature="std")] {
Self { arr: [
self.arr[0].round(),
self.arr[1].round(),
]}
} else if #[cfg(all(feature="std", not(target_arch="wasm32")))] {
let data = self.to_array();
Self::new([
data[0].round(),
data[1].round(),
])
} else {
let sign_mask = f64x2::from(-0.0);
let magic = f64x2::from(f64::from_bits(0x43300000_00000000));
Expand Down
15 changes: 8 additions & 7 deletions src/f64x4_.rs
Original file line number Diff line number Diff line change
Expand Up @@ -682,13 +682,14 @@ impl f64x4 {
Self { sse0: round_m128d::<{round_op!(Nearest)}>(self.sse0), sse1: round_m128d::<{round_op!(Nearest)}>(self.sse1) }
} else if #[cfg(target_feature="simd128")] {
Self { simd0: f64x2_nearest(self.simd0), simd1: f64x2_nearest(self.simd1) }
} else if #[cfg(feature="std")] {
Self { arr: [
self.arr[0].round(),
self.arr[1].round(),
self.arr[2].round(),
self.arr[3].round(),
]}
} else if #[cfg(all(feature="std", not(target_arch="wasm32")))] {
let data = self.to_array();
Self::new([
data[0].round(),
data[1].round(),
data[2].round(),
data[3].round(),
])
} else {
let sign_mask = f64x4::from(-0.0);
let magic = f64x4::from(f64::from_bits(0x43300000_00000000));
Expand Down

0 comments on commit 1ba208b

Please sign in to comment.