- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Dear all,
I want to use _mm512_i32gather_epi32 to gather some integers from memory to a 512-bit vector. However, there is a segmentation fault. Would you please give some suggestions? The code is attached. Thanks.
The expected result should be 0, 1, 2, 3, .., 15
// _mm512_i32gather_epi32 test
// Allocate some 64-byte aligned memory
unsigned int * out_array = (unsigned int *) _mm_malloc(sizeof(unsigned int) * 16, 64);
unsigned int * in_array = (unsigned int *) _mm_malloc(sizeof(unsigned int) * 16, 64);
// Initialize the input array that the elements will be gathered from
for(int i=0; i<16; i++){
in_array = i;
}
// Initialize the int32 vector containing the indices
__m512i index = _mm512_set_epi32(15, 14, 13, 12, 11, 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 0);
// Gather elements from the array
__m512i result = _mm512_i32gather_epi32(index, in_array, 1);
// Store the result vector back into an array
_mm512_store_epi32(out_array, result);
for(int i=0; i<16; i++)
printf("result[%u] = %u\n", i, out_array);
_mm_free(in_array);
_mm_free(out_array);
1 Solution
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
line 16 has to be
__m512i result = _mm512_i32gather_epi32(index, in_array, sizeof(unsigned int));
Yes, I agree this parameter was also confusing for me...
Link Copied
2 Replies
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
line 16 has to be
__m512i result = _mm512_i32gather_epi32(index, in_array, sizeof(unsigned int));
Yes, I agree this parameter was also confusing for me...
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Patrick S. wrote:
line 16 has to be
__m512i result = _mm512_i32gather_epi32(index, in_array, sizeof(unsigned int));Yes, I agree this parameter was also confusion for me...
Patrick, thanks very much. It solves the problem!
Reply
Topic Options
- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page