Skip to content

Commit

Permalink
Move simd right out of for_each loop
Browse files Browse the repository at this point in the history
  • Loading branch information
viirya committed Jan 10, 2022
1 parent 719096b commit fc1e998
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions arrow/src/compute/kernels/arithmetic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -908,12 +908,13 @@ where
let mut result_chunks = unsafe { result.typed_data_mut().chunks_exact_mut(lanes) };
let mut array_chunks = array.values().chunks_exact(lanes);

let simd_right = T::init(modulo);

result_chunks
.borrow_mut()
.zip(array_chunks.borrow_mut())
.for_each(|(result_slice, array_slice)| {
let simd_left = T::load(array_slice);
let simd_right = T::init(modulo);

let simd_result = T::bin_op(simd_left, simd_right, |a, b| a % b);
T::write(simd_result, result_slice);
Expand Down Expand Up @@ -960,12 +961,13 @@ where
let mut result_chunks = unsafe { result.typed_data_mut().chunks_exact_mut(lanes) };
let mut array_chunks = array.values().chunks_exact(lanes);

let simd_right = T::init(divisor);

result_chunks
.borrow_mut()
.zip(array_chunks.borrow_mut())
.for_each(|(result_slice, array_slice)| {
let simd_left = T::load(array_slice);
let simd_right = T::init(divisor);

let simd_result = T::bin_op(simd_left, simd_right, |a, b| a / b);
T::write(simd_result, result_slice);
Expand Down

0 comments on commit fc1e998

Please sign in to comment.