_mm512_i32gather_epi32 segmentation fault

_mm512_i32gather_epi32 segmentation fault

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] = 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[i]);

_mm_free(in_array);
_mm_free(out_array);

 

3 Beiträge / 0 neu
Letzter Beitrag
Nähere Informationen zur Compiler-Optimierung finden Sie in unserem Optimierungshinweis.
Best Reply

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

 

Quote:

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!

Kommentar hinterlassen

Bitte anmelden, um einen Kommentar hinzuzufügen. Sie sind noch nicht Mitglied? Jetzt teilnehmen