_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 post / 0 nuovi
Ultimo contenuto
Per informazioni complete sulle ottimizzazioni del compilatore, consultare l'Avviso sull'ottimizzazione
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...

 

Citazione:

Patrick S. ha scritto:

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!

Lascia un commento

Eseguire l'accesso per aggiungere un commento. Non siete membri? Iscriviti oggi