Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

vector of __mm128 won't push_back()

This simple SSE code:

#include <vector>
#include <emmintrin.h>

int main() {
    std::vector<__m128> blah;
    blah.push_back(__m128());
}

Crashes on MSVC 10 with a segfault at 0xffffffff.

What could be going wrong ?

like image 421
slaphappy Avatar asked Jul 27 '12 00:07

slaphappy


1 Answers

A std::vector does not allocate specially aligned memory, which __m128 needs to store it's data. You will have to either swap out the allocator, or replace it with an array of 4 floats and then perform an unaligned load or copy out to an aligned location every time you access the vector.

like image 103
Puppy Avatar answered Nov 16 '22 00:11

Puppy