diff --git a/benches/bench_f16.rs b/benches/bench_f16.rs index b6fcabd..16a7172 100644 --- a/benches/bench_f16.rs +++ b/benches/bench_f16.rs @@ -18,9 +18,15 @@ fn get_random_f16_array(n: usize) -> Array1 { // Replace NaNs and Infs with 0 let data: Vec = data .iter() - .map(|&x| if x.is_nan() || x.is_infinite() { f16::from_bits(0) } else { x }) + .map(|&x| { + if x.is_nan() || x.is_infinite() { + f16::from_bits(0) + } else { + x + } + }) .collect(); - let arr:Array1 = Array1::from(data); + let arr: Array1 = Array1::from(data); arr } diff --git a/src/lib.rs b/src/lib.rs index 268bf35..5ec16ea 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -1,8 +1,8 @@ +mod scalar_f16; +mod scalar_generic; mod simd; mod task; mod utils; -mod scalar_generic; -mod scalar_f16; pub use scalar_generic::*; pub use simd::{simd_f32, simd_f64, simd_i16, simd_i32, simd_i64}; diff --git a/src/scalar_f16.rs b/src/scalar_f16.rs index 3af8cfb..ec506c6 100644 --- a/src/scalar_f16.rs +++ b/src/scalar_f16.rs @@ -1,6 +1,6 @@ -use ndarray::ArrayView1; #[cfg(feature = "half")] use half::f16; +use ndarray::ArrayView1; // ------ On ArrayView1 diff --git a/src/simd/simd_f16.rs b/src/simd/simd_f16.rs index ac45aef..9bec83d 100644 --- a/src/simd/simd_f16.rs +++ b/src/simd/simd_f16.rs @@ -1,5 +1,5 @@ -use crate::utils::{max_index_value, min_index_value}; use crate::task::argminmax_generic; +use crate::utils::{max_index_value, min_index_value}; use ndarray::ArrayView1; use std::arch::x86_64::*; @@ -66,7 +66,7 @@ unsafe fn core_argminmax_256(sim_arr: ArrayView1, offset: usize) -> (f16, u .skip(1) .for_each(|step| { new_index = _mm256_add_epi16(new_index, increment); - + let new_values = _mm256_loadu_si256(step.as_ptr() as *const __m256i); let new_values = f16_as_m256i_to_ord_i16(new_values); let gt_mask = _mm256_cmpgt_epi16(new_values, values_high); @@ -92,7 +92,12 @@ unsafe fn core_argminmax_256(sim_arr: ArrayView1, offset: usize) -> (f16, u let index_array = reg_to_i16_arr(index_low); let (index_min, value_min) = min_index_value(&index_array, &value_array); - (ord_i16_to_f16(value_min), index_min as usize, ord_i16_to_f16(value_max), index_max as usize) + ( + ord_i16_to_f16(value_min), + index_min as usize, + ord_i16_to_f16(value_max), + index_max as usize, + ) } //----- TESTS ----- diff --git a/src/simd/simd_f32.rs b/src/simd/simd_f32.rs index 68b5c84..ceb1dac 100644 --- a/src/simd/simd_f32.rs +++ b/src/simd/simd_f32.rs @@ -1,5 +1,5 @@ -use crate::utils::{max_index_value, min_index_value}; use crate::task::argminmax_generic; +use crate::utils::{max_index_value, min_index_value}; use ndarray::ArrayView1; use std::arch::x86_64::*; diff --git a/src/simd/simd_f64.rs b/src/simd/simd_f64.rs index f2a4a78..427c17b 100644 --- a/src/simd/simd_f64.rs +++ b/src/simd/simd_f64.rs @@ -1,5 +1,5 @@ -use crate::utils::{max_index_value, min_index_value}; use crate::task::argminmax_generic; +use crate::utils::{max_index_value, min_index_value}; use ndarray::ArrayView1; use std::arch::x86_64::*; diff --git a/src/simd/simd_i16.rs b/src/simd/simd_i16.rs index e5cd550..f4ea34e 100644 --- a/src/simd/simd_i16.rs +++ b/src/simd/simd_i16.rs @@ -1,5 +1,5 @@ -use crate::utils::{max_index_value, min_index_value}; use crate::task::argminmax_generic; +use crate::utils::{max_index_value, min_index_value}; use ndarray::ArrayView1; use std::arch::x86_64::*; diff --git a/src/simd/simd_i32.rs b/src/simd/simd_i32.rs index 5b3ca8d..31c7ccf 100644 --- a/src/simd/simd_i32.rs +++ b/src/simd/simd_i32.rs @@ -1,5 +1,5 @@ -use crate::utils::{max_index_value, min_index_value}; use crate::task::argminmax_generic; +use crate::utils::{max_index_value, min_index_value}; use ndarray::ArrayView1; use std::arch::x86_64::*; diff --git a/src/simd/simd_i64.rs b/src/simd/simd_i64.rs index 41fc10f..edee939 100644 --- a/src/simd/simd_i64.rs +++ b/src/simd/simd_i64.rs @@ -1,5 +1,5 @@ -use crate::utils::{max_index_value, min_index_value}; use crate::task::argminmax_generic; +use crate::utils::{max_index_value, min_index_value}; use ndarray::ArrayView1; use std::arch::x86_64::*; diff --git a/src/task.rs b/src/task.rs index 75cde73..573e280 100644 --- a/src/task.rs +++ b/src/task.rs @@ -1,4 +1,4 @@ -use crate::scalar_generic::scalar_argminmax; // TODO: dit in macro doorgeven +use crate::scalar_generic::scalar_argminmax; // TODO: dit in macro doorgeven use ndarray::{ArrayView1, Axis}; use std::cmp::Ordering;