Intel® C++ Compiler
Community support and assistance for creating C++ code that runs on platforms based on Intel® processors.
7839 Discussions

Intel compiler vector intrinsics for MIC architecture


To whom it may concern,

I'm trying to program the Intel Xeon Phi coprocessor with Intel compiler vector intrinsics. I barely find the code samples. There's one in "Intel Xeon Phi Coprocessor Vector Microarchitecture" in which the author used the C++ class interface to MIC processor intrinsics defined in the header file "micvec.h". But in this class interface there is only a limit set of intrinsics which have been abstracted. For example, _mm512_mask_load_pd is not defined in this interface. Should I mix the use of this interface with the intrinsics or just simply forget the interface?

One more question about a specific problem. 

Considering the following code:

 __declspec(align(64)) __m512i vec; vec = _mm512_mask_load_epi32(vec, writemask, int_array_ptr);

The compiler gives a warning: variable "vec" is used before its value is set"

If I change the code to:

 __declspec(align(64)) Is32vec16 vec; vec = _mm512_mask_load_epi32(vec, writemask, int_array_ptr);

Then I get the error: more than one operator "=" matches these operands: function "Is32vec16::operator=(const M512 &)" fuction "Is32vec16::operator=(const Is32vec16 &)" operand types are: Is32vec16 = __m512i

I'm really confusing about the correct usage of _mm512_mask_load_epi32. 

Thanks for your comment. 

0 Kudos
3 Replies

I recommend re-posting your question into the MIC forum:

The return type of the intrinsic is __m512i, so use that type.

The first parameter of the intrinsic is an input value, that's why the compiler produces the warning (you didn't give vec an initial value)

The purpose of micvec.h is so you can use the mic vector operations at a higher level i.e. not using the intrinsics such as _mm512_mask_load_epi32 directly.

0 Kudos
Valued Contributor II
>>__declspec(align(64)) __m512i vec; >>vec = _mm512_mask_load_epi32(vec, writemask, int_array_ptr); >> >>The compiler gives a warning: variable "vec" is used before its value is set" Could you try to initialize vec variable, something like: ... __declspec(align(64)) __m512i vec = { 0x0 }; vec = _mm512_mask_load_epi32(vec, writemask, int_array_ptr); ...
0 Kudos

That's actually correct.  The way mask version of of the intrinsics works is that it will do operations on vector elements that is enabled by the mask.  Whatever is NOT enabled by the mask come from the first parameter -- vec in your case.  Hence if it is not previously initialized, you will have the compiler error -- which is the correct behavior.

0 Kudos