xtensor-stack/xsimd

load_unaligned seems to segfault

Closed this issue · 2 comments

code:

constexpr std::size_t simd_size = xsimd::simd_type<double>::size;

void vec_abs(double* a, int n) {
    std::size_t size = n - n % simd_size;

    for (std::size_t i = 0; i < size; i += simd_size) {
        auto va = xsimd::load_unaligned(&a[i]);  // Segfault in here, at vec_abs+0x3a
        auto res = xsimd::abs(va);
        xsimd::store_unaligned(&a[i], res);
    }

    for (std::size_t i = size; i < n; ++i) {
        a[i] = std::abs(a[i]);
    }
}

Works for me. It would help the xsimd devs if you created a complete minimal example. Currently you don't show how you call this function. You might be calling your function with an invalid array a.

+1 for @WarrenWeckesser question: we need the allocation site for a to understand what could be your issue here.