Skip to content

Commit

Permalink
Updated multiversion and support wider registers (jorgecarleitao#1440)
Browse files Browse the repository at this point in the history
  • Loading branch information
ritchie46 committed Apr 5, 2023
1 parent 775c112 commit bb22728
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ serde_json = { version = "^1.0", features = ["preserve_order"], optional = true
strength_reduce = { version = "0.2", optional = true }

# For instruction multiversioning
multiversion = { version = "0.6.1", optional = true }
multiversion = { version = "0.7.1", optional = true }

# For support for odbc
odbc-api = { version = "0.36", optional = true }
Expand Down
5 changes: 5 additions & 0 deletions src/compute/aggregate/min_max.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ use crate::{
array::{Array, BinaryArray, BooleanArray, PrimitiveArray, Utf8Array},
bitmap::Bitmap,
};
use multiversion::multiversion;

/// Trait describing a type describing multiple lanes with an order relationship
/// consistent with the same order of `T`.
Expand All @@ -31,6 +32,7 @@ pub trait SimdOrd<T> {
fn new_max() -> Self;
}

#[multiversion(targets = "simd")]
fn nonnull_min_primitive<T>(values: &[T]) -> T
where
T: NativeType + Simd,
Expand All @@ -50,6 +52,7 @@ where
reduced.min_element()
}

#[multiversion(targets = "simd")]
fn null_min_primitive_impl<T, I>(values: &[T], mut validity_masks: I) -> T
where
T: NativeType + Simd,
Expand Down Expand Up @@ -110,6 +113,7 @@ where
}
}

#[multiversion(targets = "simd")]
fn nonnull_max_primitive<T>(values: &[T]) -> T
where
T: NativeType + Simd,
Expand All @@ -129,6 +133,7 @@ where
reduced.max_element()
}

#[multiversion(targets = "simd")]
fn null_max_primitive_impl<T, I>(values: &[T], mut validity_masks: I) -> T
where
T: NativeType + Simd,
Expand Down
6 changes: 2 additions & 4 deletions src/compute/aggregate/sum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ pub trait Sum<T> {
fn simd_sum(self) -> T;
}

#[multiversion]
#[clone(target = "x86_64+avx")]
#[multiversion(targets = "simd")]
fn nonnull_sum<T>(values: &[T]) -> T
where
T: NativeType + Simd + Add<Output = T> + std::iter::Sum<T>,
Expand All @@ -39,8 +38,7 @@ where

/// # Panics
/// iff `values.len() != bitmap.len()` or the operation overflows.
#[multiversion]
#[clone(target = "x86_64+avx")]
#[multiversion(targets = "simd")]
fn null_sum_impl<T, I>(values: &[T], mut validity_masks: I) -> T
where
T: NativeType + Simd,
Expand Down
9 changes: 3 additions & 6 deletions src/compute/hash.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,15 @@ use crate::{

use super::arity::unary;

#[multiversion]
#[clone(target = "x86_64+aes+sse3+ssse3+avx+avx2")]
#[multiversion(targets("x86_64+aes+sse3+ssse3+avx+avx2"))]
/// Element-wise hash of a [`PrimitiveArray`]. Validity is preserved.
pub fn hash_primitive<T: NativeType + Hash>(array: &PrimitiveArray<T>) -> PrimitiveArray<u64> {
let state = new_state!();

unary(array, |x| state.hash_one(x), DataType::UInt64)
}

#[multiversion]
#[clone(target = "x86_64+aes+sse3+ssse3+avx+avx2")]
#[multiversion(targets("x86_64+aes+sse3+ssse3+avx+avx2"))]
/// Element-wise hash of a [`BooleanArray`]. Validity is preserved.
pub fn hash_boolean(array: &BooleanArray) -> PrimitiveArray<u64> {
let state = new_state!();
Expand All @@ -45,8 +43,7 @@ pub fn hash_boolean(array: &BooleanArray) -> PrimitiveArray<u64> {
PrimitiveArray::<u64>::new(DataType::UInt64, values, array.validity().cloned())
}

#[multiversion]
#[clone(target = "x86_64+aes+sse3+ssse3+avx+avx2")]
#[multiversion(targets("x86_64+aes+sse3+ssse3+avx+avx2"))]
/// Element-wise hash of a [`Utf8Array`]. Validity is preserved.
pub fn hash_utf8<O: Offset>(array: &Utf8Array<O>) -> PrimitiveArray<u64> {
let state = new_state!();
Expand Down

0 comments on commit bb22728

Please sign in to comment.