0

I want to convert the bits stored in __m256i to int[] I've tried_mm256_storeu_si256 ((__m256i*)rd,rs) but it seems to fail.

So what's the reason behind it? And what is the correct way to convert __m256i to 8 integers?

Here is the context:

//a, b are two arrays(larger than 8)
__m256i rs1 = _mm256_loadu_si256 ((const __m256i*) (a + (i+k)*sizeof(int)));// load 256bits rs1
__m256i rs2 = _mm256_loadu_si256 ((const __m256i*) (b + i*sizeof(int)));// load 256bits to rs2
__m256i rd = _mm256_maddubs_epi16 (rs1, rs2);// computation (each entry in a/b is positive and smaller than 8 so I think it is valid)
_mm256_storeu_si256 ((__m256i*)result,rd);// store the result to the result[] (it crash)

it reports segmentation fault


Ive looked up Store __m256i to integer, but I guess we have different problem (what I am doing is same with it)


next, I try _mm256_extract_epi32--store integers one by one(it is stupid but I have no way), and it works?????GG

Cino
  • 83
  • 1
  • 7
  • 1
    why not `_mm256_store_si256((__m256i *)rd, rs)`? – João Paulo May 30 '20 at 16:48
  • cause I can't make sure whether the data is aligned – Cino May 30 '20 at 16:58
  • 1
    Could you give some more context here, I have no idea what `rd` and `rs` are or their types. – harold May 30 '20 at 17:01
  • 2
    @Cino `_mm256_storeu_si256` for unaligned – Artyer May 30 '20 at 17:02
  • Crashes how? Where is your `int result[8]` array? Don't think of it as *converting*, think of it as *storing* into a C++ array. What you do with that C++ array afterward is up to you. I added a few more duplicate links that show more complete examples of getting data out of a SIMD vector and using it. – Peter Cordes May 31 '20 at 01:38
  • @PeterCordes Sorry, I cannot follow. yes, it this function is storing 256 bits to int*. my result[8] is defined above, just `int result[8];` and what do you mean by `I added a few more duplicate links`? – Cino May 31 '20 at 01:53

0 Answers0