Only flush comparison in test

This commit is contained in:
Caleb Zulawski 2023-07-27 01:02:26 -04:00
parent dbcbc3e4c5
commit cb461aceb3
2 changed files with 32 additions and 3 deletions

View File

@ -539,11 +539,11 @@ fn simd_clamp<const LANES: usize>() {
}
let mut result_scalar_flush = [Scalar::default(); LANES];
for i in 0..LANES {
let mut value = flush_in(value[i]);
if value < flush_in(min[i]) {
let mut value = value[i];
if flush_in(value) < flush_in(min[i]) {
value = min[i];
}
if value > flush_in(max[i]) {
if flush_in(value) > flush_in(max[i]) {
value = max[i];
}
result_scalar_flush[i] = value

View File

@ -336,6 +336,35 @@ pub fn test_binary_elementwise_flush_subnormals<
});
}
/// Test a unary vector function against a unary scalar function, applied elementwise.
#[inline(never)]
pub fn test_binary_mask_elementwise<Scalar1, Scalar2, Vector1, Vector2, Mask, const LANES: usize>(
fv: &dyn Fn(Vector1, Vector2) -> Mask,
fs: &dyn Fn(Scalar1, Scalar2) -> bool,
check: &dyn Fn([Scalar1; LANES], [Scalar2; LANES]) -> bool,
) where
Scalar1: Copy + core::fmt::Debug + DefaultStrategy,
Scalar2: Copy + core::fmt::Debug + DefaultStrategy,
Vector1: Into<[Scalar1; LANES]> + From<[Scalar1; LANES]> + Copy,
Vector2: Into<[Scalar2; LANES]> + From<[Scalar2; LANES]> + Copy,
Mask: Into<[bool; LANES]> + From<[bool; LANES]> + Copy,
{
test_2(&|x: [Scalar1; LANES], y: [Scalar2; LANES]| {
proptest::prop_assume!(check(x, y));
let result_v: [bool; LANES] = fv(x.into(), y.into()).into();
let result_s: [bool; LANES] = x
.iter()
.copied()
.zip(y.iter().copied())
.map(|(x, y)| fs(x, y))
.collect::<Vec<_>>()
.try_into()
.unwrap();
crate::prop_assert_biteq!(result_v, result_s);
Ok(())
});
}
/// Test a binary vector-scalar function against a binary scalar function, applied elementwise.
#[inline(never)]
pub fn test_binary_scalar_rhs_elementwise<