Skip to content

Commit cb461ac

Browse files
committed
Only flush comparison in test
1 parent dbcbc3e commit cb461ac

File tree

2 files changed

+32
-3
lines changed

2 files changed

+32
-3
lines changed

crates/core_simd/tests/ops_macros.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -539,11 +539,11 @@ macro_rules! impl_float_tests {
539539
}
540540
let mut result_scalar_flush = [Scalar::default(); LANES];
541541
for i in 0..LANES {
542-
let mut value = flush_in(value[i]);
543-
if value < flush_in(min[i]) {
542+
let mut value = value[i];
543+
if flush_in(value) < flush_in(min[i]) {
544544
value = min[i];
545545
}
546-
if value > flush_in(max[i]) {
546+
if flush_in(value) > flush_in(max[i]) {
547547
value = max[i];
548548
}
549549
result_scalar_flush[i] = value

crates/test_helpers/src/lib.rs

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -336,6 +336,35 @@ pub fn test_binary_elementwise_flush_subnormals<
336336
});
337337
}
338338

339+
/// Test a unary vector function against a unary scalar function, applied elementwise.
340+
#[inline(never)]
341+
pub fn test_binary_mask_elementwise<Scalar1, Scalar2, Vector1, Vector2, Mask, const LANES: usize>(
342+
fv: &dyn Fn(Vector1, Vector2) -> Mask,
343+
fs: &dyn Fn(Scalar1, Scalar2) -> bool,
344+
check: &dyn Fn([Scalar1; LANES], [Scalar2; LANES]) -> bool,
345+
) where
346+
Scalar1: Copy + core::fmt::Debug + DefaultStrategy,
347+
Scalar2: Copy + core::fmt::Debug + DefaultStrategy,
348+
Vector1: Into<[Scalar1; LANES]> + From<[Scalar1; LANES]> + Copy,
349+
Vector2: Into<[Scalar2; LANES]> + From<[Scalar2; LANES]> + Copy,
350+
Mask: Into<[bool; LANES]> + From<[bool; LANES]> + Copy,
351+
{
352+
test_2(&|x: [Scalar1; LANES], y: [Scalar2; LANES]| {
353+
proptest::prop_assume!(check(x, y));
354+
let result_v: [bool; LANES] = fv(x.into(), y.into()).into();
355+
let result_s: [bool; LANES] = x
356+
.iter()
357+
.copied()
358+
.zip(y.iter().copied())
359+
.map(|(x, y)| fs(x, y))
360+
.collect::<Vec<_>>()
361+
.try_into()
362+
.unwrap();
363+
crate::prop_assert_biteq!(result_v, result_s);
364+
Ok(())
365+
});
366+
}
367+
339368
/// Test a binary vector-scalar function against a binary scalar function, applied elementwise.
340369
#[inline(never)]
341370
pub fn test_binary_scalar_rhs_elementwise<

0 commit comments

Comments
 (0)