c++ - Segfault while creating a vector of avx vectors -


for current project need create vector of 256bit avx vectors. used

myvector = vector<__m256d>(nrvars(), _mm256_set1_pd(1.0)); 

which worked fine once after executing line twice gives me segmentation fault. able come following piece of code

vector<__m256d> temp; __m256d entry = _mm256_set1_pd(1.0); temp = vector<__m256d>(10, entry); temp = vector<__m256d>(10, entry); 

that produces segmentation fault. explain me why case , how can avoid issue in future?

thank much!

p.s. not work:

myvector.clear(); myvector.reserve(nrvars()); (size_t i=0; i<nrvars(); ++i) {     myvector[i] = _mm256_set1_pd(1.0); } 

and answer comments. complete example produces segfault:

#include <vector> #include "immintrin.h"  using namespace std; int main(int argc, char **argv) {     vector<__m256d> temp;     __m256d entry = _mm256_set1_pd(1.0);     temp = vector<__m256d>(10, entry);     temp = vector<__m256d>(10, entry);     return 0; } 

and read on m256d , functions i'm using please take @ intel intrinsic website (https://software.intel.com/sites/landingpage/intrinsicsguide/)

avx requires aligned data. vector not guarantee elements aligned properly. see question (how vector's data aligned?) discussion of allocation alignment, regards simd execution.


Comments

Popular posts from this blog

javascript - Bootstrap Popover: iOS Safari strange behaviour -

Magento/PHP - Get phones on all members in a customer group -

session - Logging Out Using PHP -