#include <stdio.h>
#include <immintrin.h>
#pragma offload_attribute(push,target(mic))
class mic_f{
public:
union{
__m512 v;
float f[16];
};
__forceinline operator __m512 () const { return v; };
__forceinline float& operator[](const size_t index) { return f[index]; };
__forceinline mic_f& operator=(const mic_f& f) { v = f.v; return *this; };
__forceinline mic_f(const __m512& t) { v = t; };
__forceinline mic_f() {};
};
#pragma offload_attribute(pop)
class mic_m{
public:
__mmask16 v;
#pragma offload_attribute(push,target(mic))
__forceinline operator __mmask () const { return v; };
__forceinline mic_m(int t ) { v = (__mmask16)t; };
__forceinline mic_m(unsigned int t ) { v = (__mmask16)t; };
#pragma offload_attribute(pop)
};
#pragma offload_attribute(push,target(mic))
__forceinline size_t bitscan64(const ssize_t index,const size_t v) {
return _mm_tzcnti_64(index,v);
};
#pragma offload_attribute(pop)
void main(){
mic_f data[3];
for(int i=0;i<16;i++){
data[0][i]=i%4+1;
data[1][i]=4;
data[2][i]=0;
}
float* indata = (float*)data;
#pragma offload target(mic)inout(indata:length(48))
{
mic_f* ineedyou = (mic_f*)indata;
const unsigned long hiti = 0x8888;
const unsigned long pos_first = 4;
const unsigned long pos_second = bitscan64(pos_first,hiti);
}
}
when I compile the code with "icc -o test includetest.cpp" I got the error "In function `bitscan64(long, unsigned long)':
includetest.cpp:(.text._Z9bitscan64lm[_Z9bitscan64lm]+0xb): undefined reference to `_mm_tzcnti_64",and when I change the intrincs "_mm_tzcnti_64" into "_mm_tzcnt_64" everything is OK.
How can I solve this problem? I think may be there need some Compiler Options?