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 и baseline бенчмарка. Собирается без -mavx*, потолок автовекторизации — SSE2.

#include "sve/sve.hpp"

namespace sve::scalar {

std::size_t count_gt_i32(std::span<const std::int32_t> d, std::int32_t thr) {
    std::size_t c = 0;
    for (auto x : d) c += static_cast<std::size_t>(x > thr);
    return c;
}

std::size_t count_gt_f32(std::span<const float> d, float thr) {
    std::size_t c = 0;
    for (auto x : d) c += static_cast<std::size_t>(x > thr);
    return c;
}

std::int64_t sum_i32(std::span<const std::int32_t> d) {
    // Накопление в i64: 100M × i32 не влезет в 32 бита.
    std::int64_t acc = 0;
    for (auto x : d) acc += x;
    return acc;
}

std::optional<size_t> find_i32(std::span<const std::int32_t> d, std::int32_t needle) {
    for (std::size_t i = 0; i < d.size(); ++i)
        if (d[i] == needle) return i;
    return std::nullopt;
}

std::size_t filter_into_i32(std::span<const std::int32_t> d, std::int32_t thr,
                            std::span<std::int32_t> out) {
    std::size_t w = 0;
    for (auto x : d)
        if (x > thr) out[w++] = x;
    return w;
}

}  // namespace sve::scalar