Skip to content
This repository was archived by the owner on Oct 18, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions common/src/inputs/generators/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ pub fn generate_input_pairs<Storage: InputsMut, R: Rng, const ILP: usize>(

// Split the input in two halves
let target_len = target.len();
assert_eq!(target_len % 2, 0);
assert!(target_len.is_multiple_of(2));
let half_len = target_len / 2;
let (left_target, right_target) = target.split_at_mut(half_len);
assert_eq!(left_target.len(), right_target.len());
Expand Down Expand Up @@ -335,7 +335,7 @@ impl<'data, T> DataStream<'data, T> {
pub fn into_pair_iter(
self,
) -> impl DoubleEndedIterator<Item = [&'data mut T; 2]> + ExactSizeIterator {
assert_eq!(self.target.len() % 2, 0);
assert!(self.target.len().is_multiple_of(2));
debug_assert!(self.stream_idx < self.num_streams);

let half_len = self.target.len() / 2;
Expand Down Expand Up @@ -498,7 +498,7 @@ pub mod test_utils {
+ (stream_idx < (sequence_len % num_streams)) as usize
};
let stream_len = if pairwise {
assert_eq!(target_len % 2, 0);
assert!(target_len.is_multiple_of(2));
stream_len(target_len / 2) * 2
} else {
stream_len(target_len)
Expand Down Expand Up @@ -623,7 +623,7 @@ pub(crate) mod tests {
fn stream_pair_iter((num_streams, mut target) in num_streams_and_target::<u8>(true)) {
let initial = target.clone();
let target = &mut target[..];
debug_assert_eq!(target.len() % 2, 0);
debug_assert!(target.len().is_multiple_of(2));
let half_len = target.len() / 2;
let left_start = target.as_ptr();
let right_start = left_start.wrapping_add(half_len);
Expand Down Expand Up @@ -839,7 +839,7 @@ pub(crate) mod tests {
(num_streams, num_subnormals, target_len) in num_streams_and_subnormal_config(true),
) {
// Set up a mock of the expected element_generator usage context
debug_assert_eq!(target_len % 2, 0);
debug_assert!(target_len.is_multiple_of(2));
let half_len = target_len / 2;
let mut rng = rand::thread_rng();
if num_subnormals > target_len {
Expand Down Expand Up @@ -942,7 +942,7 @@ pub(crate) mod tests {
pairs: bool,
) -> impl Strategy<Value = ([f32; INPUT_REGISTERS], usize)> {
if pairs {
assert_eq!(INPUT_REGISTERS % 2, 0);
assert!(INPUT_REGISTERS.is_multiple_of(2));
}
(
[any::<f32>(); INPUT_REGISTERS],
Expand Down Expand Up @@ -1168,7 +1168,7 @@ pub(crate) mod tests {
prop_assert!(streams.len() >= expected_streams);

// Check that the stream generators performed the expected actions
debug_assert_eq!(target.len() % 2, 0);
debug_assert!(target.len().is_multiple_of(2));
let half_len = target.len() / 2;
let min_pairs_per_stream = half_len / expected_streams;
let mut actual_subnormals = 0;
Expand Down Expand Up @@ -1197,7 +1197,7 @@ pub(crate) mod tests {

// Check that the data element generation actions look correct
let mut expected_left_idx = stream_idx;
debug_assert_eq!(other_actions.len() % 2, 0);
debug_assert!(other_actions.len().is_multiple_of(2));
for action_pair in other_actions.chunks_exact(2) {
let expected_indices = [expected_left_idx, expected_left_idx + half_len];
for (action, expected_idx) in action_pair.iter().zip(expected_indices) {
Expand Down
14 changes: 9 additions & 5 deletions common/src/operations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub fn integrate_pairs<T: FloatLike, I: Inputs<Element = T>, const ILP: usize>(
) {
let inputs = inputs.as_ref();
let inputs_len = inputs.len();
assert_eq!(inputs_len % 2, 0);
assert!(inputs_len.is_multiple_of(2));
let (left, right) = inputs.split_at(inputs_len / 2);
if I::KIND.is_reused() {
for (&left_elem, &right_elem) in left.iter().zip(right) {
Expand Down Expand Up @@ -830,7 +830,11 @@ pub mod test_utils {

// Instantiate benchmark, checking for invalid input length
let input_len_granularity = 1 + (pairwise as usize);
if input_storage.as_ref().len() % input_len_granularity != 0 {
if !input_storage
.as_ref()
.len()
.is_multiple_of(input_len_granularity)
{
return assert_panics(AssertUnwindSafe(|| {
Op::make_benchmark::<_, ILP>(input_storage)
}));
Expand Down Expand Up @@ -860,7 +864,7 @@ pub mod test_utils {
let input_is_reused = Storage::KIND.is_reused();

// Set up a benchmark...
if pairwise && input_len % 2 != 0 {
if pairwise && !input_len.is_multiple_of(2) {
return assert_panics(AssertUnwindSafe(|| {
Op::make_benchmark::<_, ILP>(input_storage)
}));
Expand Down Expand Up @@ -902,7 +906,7 @@ pub mod test_utils {
std::array::from_fn(input_is_normal)
};
if pairwise {
debug_assert_eq!(input_len % 2, 0);
debug_assert!(input_len.is_multiple_of(2));
let first_right_input = input_len / 2;
if input_is_reused {
first_input_normal = std::array::from_fn(|acc_idx| {
Expand Down Expand Up @@ -1409,7 +1413,7 @@ mod tests {

// Test without reused input hiding
let integrate_pairs = super::integrate_pairs::<f32, I, ILP>;
if initial_inputs.len() % 2 != 0 {
if !initial_inputs.len().is_multiple_of(2) {
return assert_panics(AssertUnwindSafe(|| {
integrate_pairs(&mut accumulators, hide_accumulators, &inputs, iter)
}));
Expand Down
9 changes: 4 additions & 5 deletions fma_addend/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,8 @@ impl Operation for FmaAddend {
fn make_benchmark<Storage: InputsMut, const ILP: usize>(
input_storage: Storage,
) -> impl Benchmark<Float = Storage::Element> {
assert_eq!(
input_storage.as_ref().len() % 2,
0,
assert!(
input_storage.as_ref().len().is_multiple_of(2),
"Invalid test input length"
);
FmaAddendBenchmark::<_, ILP> {
Expand Down Expand Up @@ -384,7 +383,7 @@ mod tests {
prop_assert_eq!(&stream.state, &FmaAddendState::Unconstrained);

// Simulate the creation of a dataset, checking behavior
debug_assert_eq!(target.len() % 2, 0);
debug_assert!(target.len().is_multiple_of(2));
let half_len = target.len() / 2;
let stream_indices =
((0..half_len).skip(stream_idx).step_by(num_streams))
Expand Down Expand Up @@ -458,7 +457,7 @@ mod tests {
// Generate the inputs
let mut rng = rand::thread_rng();
let target_len = target.len();
if num_subnormals > target_len || target_len % 2 != 0 {
if num_subnormals > target_len || !target_len.is_multiple_of(2) {
return assert_panics(AssertUnwindSafe(|| {
generate_inputs::<_, ILP>(num_subnormals, &mut target, &mut rng, true, multiplier);
}));
Expand Down
9 changes: 4 additions & 5 deletions fma_full_max/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,8 @@ impl Operation for FmaFullMax {
fn make_benchmark<Storage: InputsMut, const ILP: usize>(
input_storage: Storage,
) -> impl Benchmark<Float = Storage::Element> {
assert_eq!(
input_storage.as_ref().len() % 2,
0,
assert!(
input_storage.as_ref().len().is_multiple_of(2),
"Invalid test input length"
);
FmaFullMaxBenchmark::<_, ILP> {
Expand Down Expand Up @@ -507,7 +506,7 @@ mod tests {
prop_assert_eq!(&stream.state, &FmaFullMaxState::Narrow);

// Simulate the creation of a dataset, checking behavior
debug_assert_eq!(target.len() % 2, 0);
debug_assert!(target.len().is_multiple_of(2));
let half_len = target.len() / 2;
let stream_indices =
((0..half_len).skip(stream_idx).step_by(num_streams))
Expand Down Expand Up @@ -690,7 +689,7 @@ mod tests {
// Generate the inputs
let mut rng = rand::thread_rng();
let target_len = target.len();
if num_subnormals > target_len || target_len % 2 != 0 {
if num_subnormals > target_len || !target_len.is_multiple_of(2) {
return assert_panics(AssertUnwindSafe(|| {
generate_inputs::<ILP>(num_subnormals, &mut target, &mut rng, true);
}));
Expand Down
2 changes: 1 addition & 1 deletion rust-toolchain
Original file line number Diff line number Diff line change
@@ -1 +1 @@
nightly-2024-12-06
nightly-2025-04-25
Loading