From 8badb7d0cb6b2af8a959c799cefcce4aea2bea59 Mon Sep 17 00:00:00 2001 From: "Jorge C. Leitao" Date: Mon, 10 Jan 2022 05:27:32 +0000 Subject: [PATCH] Fixed element-wise --- src/compute/aggregate/min_max.rs | 20 ++++++++++---------- src/compute/aggregate/simd/native.rs | 4 ++-- src/compute/aggregate/simd/packed.rs | 12 ++++++------ tests/it/compute/aggregate/min_max.rs | 16 ++++++++++++++++ 4 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/compute/aggregate/min_max.rs b/src/compute/aggregate/min_max.rs index 6d0638f92da..372694bf01a 100644 --- a/src/compute/aggregate/min_max.rs +++ b/src/compute/aggregate/min_max.rs @@ -21,9 +21,9 @@ pub trait SimdOrd { /// reduce itself to the maximum fn min_element(self) -> T; /// lane-wise maximum between two instances - fn max(self, x: Self) -> Self; + fn max_lane(self, x: Self) -> Self; /// lane-wise minimum between two instances - fn min(self, x: Self) -> Self; + fn min_lane(self, x: Self) -> Self; /// returns a new instance with all lanes equal to `MIN` fn new_min() -> Self; /// returns a new instance with all lanes equal to `MAX` @@ -112,11 +112,11 @@ where let chunk_reduced = chunks.fold(T::Simd::new_min(), |acc, chunk| { let chunk = T::Simd::from_chunk(chunk); - acc.min(chunk) + acc.min_lane(chunk) }); let remainder = T::Simd::from_incomplete_chunk(remainder, T::Simd::MAX); - let reduced = chunk_reduced.min(remainder); + let reduced = chunk_reduced.min_lane(remainder); reduced.min_element() } @@ -135,14 +135,14 @@ where let chunk = T::Simd::from_chunk(chunk); let mask = ::Mask::from_chunk(validity_chunk); let chunk = chunk.select(mask, T::Simd::new_min()); - acc.min(chunk) + acc.min_lane(chunk) }, ); let remainder = T::Simd::from_incomplete_chunk(chunks.remainder(), T::Simd::MAX); let mask = ::Mask::from_chunk(validity_masks.remainder()); let remainder = remainder.select(mask, T::Simd::new_min()); - let reduced = chunk_reduced.min(remainder); + let reduced = chunk_reduced.min_lane(remainder); reduced.min_element() } @@ -191,11 +191,11 @@ where let chunk_reduced = chunks.fold(T::Simd::new_max(), |acc, chunk| { let chunk = T::Simd::from_chunk(chunk); - acc.max(chunk) + acc.max_lane(chunk) }); let remainder = T::Simd::from_incomplete_chunk(remainder, T::Simd::MIN); - let reduced = chunk_reduced.max(remainder); + let reduced = chunk_reduced.max_lane(remainder); reduced.max_element() } @@ -214,14 +214,14 @@ where let chunk = T::Simd::from_chunk(chunk); let mask = ::Mask::from_chunk(validity_chunk); let chunk = chunk.select(mask, T::Simd::new_max()); - acc.max(chunk) + acc.max_lane(chunk) }, ); let remainder = T::Simd::from_incomplete_chunk(chunks.remainder(), T::Simd::MIN); let mask = ::Mask::from_chunk(validity_masks.remainder()); let remainder = remainder.select(mask, T::Simd::new_max()); - let reduced = chunk_reduced.max(remainder); + let reduced = chunk_reduced.max_lane(remainder); reduced.max_element() } diff --git a/src/compute/aggregate/simd/native.rs b/src/compute/aggregate/simd/native.rs index 9c573ca9e76..6a3e601f9a3 100644 --- a/src/compute/aggregate/simd/native.rs +++ b/src/compute/aggregate/simd/native.rs @@ -70,7 +70,7 @@ macro_rules! simd_ord_int { } #[inline] - fn max(self, x: Self) -> Self { + fn max_lane(self, x: Self) -> Self { let mut result = <$simd>::default(); result .0 @@ -82,7 +82,7 @@ macro_rules! simd_ord_int { } #[inline] - fn min(self, x: Self) -> Self { + fn min_lane(self, x: Self) -> Self { let mut result = <$simd>::default(); result .0 diff --git a/src/compute/aggregate/simd/packed.rs b/src/compute/aggregate/simd/packed.rs index 4e9336ac08c..7af9ac2a4e2 100644 --- a/src/compute/aggregate/simd/packed.rs +++ b/src/compute/aggregate/simd/packed.rs @@ -42,13 +42,13 @@ macro_rules! simd_ord_int { } #[inline] - fn max(self, x: Self) -> Self { - std::cmp::Ord::max(self, x) + fn max_lane(self, x: Self) -> Self { + self.max(x) } #[inline] - fn min(self, x: Self) -> Self { - std::cmp::Ord::min(self, x) + fn min_lane(self, x: Self) -> Self { + self.min(x) } #[inline] @@ -81,12 +81,12 @@ macro_rules! simd_ord_float { } #[inline] - fn max(self, x: Self) -> Self { + fn max_lane(self, x: Self) -> Self { self.max(x) } #[inline] - fn min(self, x: Self) -> Self { + fn min_lane(self, x: Self) -> Self { self.min(x) } diff --git a/tests/it/compute/aggregate/min_max.rs b/tests/it/compute/aggregate/min_max.rs index abeaf304596..bd0ac99e3a5 100644 --- a/tests/it/compute/aggregate/min_max.rs +++ b/tests/it/compute/aggregate/min_max.rs @@ -51,6 +51,22 @@ fn min_max_f64_large() { None, Some(5.0), Some(2.0), + None, + None, + Some(8.0), + Some(2.0), + None, + None, + Some(5.0), + Some(2.0), + None, + None, + Some(8.0), + Some(2.0), + None, + None, + Some(5.0), + Some(2.0), ]); assert_eq!(Some(2.0), min_primitive(&a)); assert_eq!(Some(8.0), max_primitive(&a));