konjac
konjac

Reputation: 787

Undefined reference when using intrinsic

I want to test the SIMD intrinsic of xeon phi. So I wrote following code:

#pragma offload target(mic) in(a:length(N))
#pragma omp parallel for
for(int i=0;i<16;++i){
    __m512i p ;
    p = _mm512_loadunpackhi_epi64(p, &a[i*10]);
}

When compiling, icpc gave me undefined reference error

/tmp/icpc3kLMRg.o: In function `main':
./src/test.cc:(.text+0x2e8): undefined reference to `_mm512_extloadunpackhi_epi64'
make: *** [test.cc] Error 1

Is there any other header files to be included besides immintrin.h

Upvotes: 1

Views: 755

Answers (1)

sssylvester
sssylvester

Reputation: 168

The compiler compiles for the host as well as for the xeon phi. The host doesn't support the function you are trying to call so you need to do this:

#ifdef __MIC__
#pragma offload target(mic) in(a:length(N))
#pragma omp parallel for
for(int i=0;i<16;++i){
    __m512i p ;
    p = _mm512_loadunpackhi_epi64(p, &a[i*10]);
}
#else
   <do something differnt on the host (or nothing)>
#endif

Upvotes: 2

Related Questions