From 76f5291131608062f715b5457430c122ad10aa61 Mon Sep 17 00:00:00 2001 From: Magnus Ulimoen Date: Thu, 25 Mar 2021 17:23:01 +0100 Subject: [PATCH] Elide bounds check in diffxi array_windows.skip did not elide bounds checks as it should. If the slice is instead offset by the skipped amount, we have the same behavour, but aids the compiler enough. The two changed lines allows SIMD optimisations, giving an impressive reduction in instructions by two thirds in the benchmark. --- sbp/src/operators/algos.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/sbp/src/operators/algos.rs b/sbp/src/operators/algos.rs index 5d0896e..d9c5870 100644 --- a/sbp/src/operators/algos.rs +++ b/sbp/src/operators/algos.rs @@ -142,9 +142,8 @@ pub(crate) fn diff_op_1d_slice( // based on the block size let window_elems_to_skip = M - ((D - 1) / 2); - for (window, f) in prev + for (window, f) in prev[window_elems_to_skip..] .array_windows::() - .skip(window_elems_to_skip) .zip(fut.array_chunks_mut::<1>()) { let fut = ColVector::<_, 1>::map_to_col_mut(f);