How to use gather operations on MIC

How to use gather operations on MIC

Hi i want to gather a some elements from a array whose indices are specified in "index". Here is the code i have written.

#include<stdio.h>
#include<stdlib.h>
#include<immintrin.h>
int main()
{
float* arrA = (float*)_mm_malloc(sizeof(float)*500,64);
float* arrB = (float*)_mm_malloc(sizeof(float)*500,64);

for(int i=0; i <42; i++)
{
arrA[i] =(float )i;
arrB[i] = (float)1;

}
__m512i index = {0,1,2,3,4,5,6,7,8,9,10,11,12,16,19,21};
__m512 v1;
v1 = _mm512_i32gather_ps(index,(void*)arrA,sizeof(float));
_mm512_store_ps((void*)arrB,v1);

for(int i =0; i < 42; i++)
printf("%f ",arrB[i]);
printf("\n");
}

 

In the above code i want to i want gather elements from "arrA" whose indices are given in "index". and all gathered elements will be stored in "arrB".

But it is giving Error: Illegal instruction (core dumped). If I remove _mm512_store_ps it is executing. Can some one tell what is wrong with code.

 

Thanks

sivaramakrishna

 

3 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

You would compile with -mmic and run the executable on the coprocessor itself. It fails with the illegal instruction when compiled and executed on the host.

micnativeloadex is handy for a quick test like this one but if you prefer, transfer the executable to the coprocessor and then connect to the coprocessor to run it interactively.

$ icc -V
Intel(R) C Intel(R) 64 Compiler XE for applications running on Intel(R) 64, Version 14.0.2.144 Build 20140120

$ icc -mmic u508619.cpp

$ /usr/bin/micnativeloadex a.out
0.000000 1.000000 2.000000 3.000000 4.000000 5.000000 6.000000 7.000000 8.000000 9.000000 10.000000 11.000000 12.000000 16.000000 19.000000 21.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000 1.000000

 

Thanks Davis :)

Leave a Comment

Please sign in to add a comment. Not a member? Join today