Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Seg fault while using _mm256_i64gather_pd

I am trying to use the gather intrinsic provided by AVX2 but the code exists with a segmentation fault.

double src[100];

// src initialization here
int indices[10] = { 2, 10, 12, 13, 48, 60, 71, 79, 94, 97};
index = _mm256_loadu_si256(reinterpret_cast<__m256i const*>(indices));

elements = _mm256_i64gather_pd(reinterpret_cast<double const*>(src), index, 8); // Segmentation fault happens here

I am not sure what is causing the problem. The scale has to be 8 since the type here is double. What am I doing anything wrong? I am compiling with -mavx2 flag.

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

>Solution :

#include <immintrin.h> // Include the appropriate header for AVX intrinsics

double src[100];

// src initialization here

int64_t indices[10] = { 2, 10, 12, 13, 48, 60, 71, 79, 94, 97 }; // Use int64_t for 64-bit integers

__m256i index = _mm256_loadu_si256(reinterpret_cast<__m256i const*>(indices));

__m256d elements = _mm256_i64gather_pd(reinterpret_cast<double const*>(src), index, 8);

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading