simd-vector-engine 0.1.0

Runtime-dispatched SIMD kernels for scanning i32/f32 slices: count, sum, find and stream compaction on AVX-512, AVX2, NEON with a scalar fallback
Documentation
// Fallback и эталон для тестов.

#[inline]
pub fn count_gt_i32(data: &[i32], threshold: i32) -> usize {
    let mut count = 0usize;
    for &x in data {
        count += (x > threshold) as usize;
    }
    count
}

#[inline]
pub fn count_gt_f32(data: &[f32], threshold: f32) -> usize {
    let mut count = 0usize;
    for &x in data {
        count += (x > threshold) as usize;
    }
    count
}

#[inline]
pub fn sum_i32(data: &[i32]) -> i64 {
    let mut acc = 0i64;
    for &x in data {
        acc += x as i64;
    }
    acc
}

#[inline]
pub fn find_i32(data: &[i32], needle: i32) -> Option<usize> {
    for (i, &x) in data.iter().enumerate() {
        if x == needle {
            return Some(i);
        }
    }
    None
}

/// Размер `out` обеспечивает вызывающий.
#[inline]
pub fn filter_into_i32(data: &[i32], threshold: i32, out: &mut [i32]) -> usize {
    debug_assert!(data.is_empty() || !out.is_empty());
    let mut w = 0usize;
    for &x in data {
        if x > threshold {
            out[w] = x;
            w += 1;
        }
    }
    w
}