Software Archive
Read-only legacy content
Announcements
Welcome to the Intel Community. If you get an answer you like, please mark it as an Accepted Solution to help others. Thank you!
For the latest information on Intel’s response to the Log4j/Log4Shell vulnerability, please see Intel-SA-00646
17065 Discussions

_mm512_i32gather_epi32 segmentation fault

Cheng_C_
Beginner
237 Views

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);

 

0 Kudos
1 Solution
Patrick_S_
New Contributor I
237 Views

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...

 

View solution in original post

2 Replies
Patrick_S_
New Contributor I
238 Views

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...

 

View solution in original post

Cheng_C_
Beginner
237 Views

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