Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Highlighted
Student Ambassador
34 Views

Understanding Bitwise Intrinsics

Jump to solution

Hello, 

This is a very simple doubt, but I just started out with AVX512 ISA.

_mm512_xor_epi64 This intrinsic needs two _m512i data types, which i am let to believe are packed with 8 int64 values each.  And this command will return a _m512i data type containing 8 integers which are the result of the bitwise logical XOR operation between each of the 8 integers. 

For instance, if the _m512i A data type is packed with (2,1,4,5,2,2,3,1) int64 values, and _m512i is packed with (4,2,1,3,5,2,1,3).

Then running _mm512_xor_epi64(A, B) will return a pointer to a _m512i data type which contains (xor(2,4), xor(1,2), xor(4,1), xor(5,3), xor(2, 5), xor(2, 2), xor(3, 1), xor(1,3)). Where xor() is the bitwise XOR of the binary form of 2 and 4, isnt it?

Does extern __m512i __cdecl _mm512_load_epi64(void const* mt); Does this allow me to pack an allocated array of 8 int64 values into a _m512i data type, provided * mt is the pointer to such an array? 

Is there an intrinsic to unpack such values? Would really appreciate some help in the right direction.

0 Kudos

Accepted Solutions
Highlighted
New Contributor III
34 Views

Then running _mm512_xor_epi64(A, B) will return a pointer to a _m512i data type

No, it will return the vector by value.

which contains (xor(2,4), xor(1,2), xor(4,1), xor(5,3), xor(2, 5), xor(2, 2), xor(3, 1), xor(1,3)). Where xor() is the bitwise XOR of the binary form of 2 and 4, isnt it?

That's right.

Does extern __m512i __cdecl _mm512_load_epi64(void const* mt); Does this allow me to pack an allocated array of 8 int64 values into a _m512i data type, provided * mt is the pointer to such an array?

The _mm512_load_epi64 intrinsic loads a vector from aligned memory. "Packing" is not the right term because there are a number of pack/unpack intrinsics which operate differently.

Is there an intrinsic to unpack such values?

Assuming you want to extract elements of a vector, there are a number of extract intrinsics (https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=extract). Depending on the circumstances, there might be other ways, like storing the vector to memory first or shuffling the elements (https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=shuffle) and then extracting the lowest element (https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=cvt&expand=1810&techs=SSE,SSE2).

 

View solution in original post

0 Kudos
1 Reply
Highlighted
New Contributor III
35 Views

Then running _mm512_xor_epi64(A, B) will return a pointer to a _m512i data type

No, it will return the vector by value.

which contains (xor(2,4), xor(1,2), xor(4,1), xor(5,3), xor(2, 5), xor(2, 2), xor(3, 1), xor(1,3)). Where xor() is the bitwise XOR of the binary form of 2 and 4, isnt it?

That's right.

Does extern __m512i __cdecl _mm512_load_epi64(void const* mt); Does this allow me to pack an allocated array of 8 int64 values into a _m512i data type, provided * mt is the pointer to such an array?

The _mm512_load_epi64 intrinsic loads a vector from aligned memory. "Packing" is not the right term because there are a number of pack/unpack intrinsics which operate differently.

Is there an intrinsic to unpack such values?

Assuming you want to extract elements of a vector, there are a number of extract intrinsics (https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=extract). Depending on the circumstances, there might be other ways, like storing the vector to memory first or shuffling the elements (https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=shuffle) and then extracting the lowest element (https://software.intel.com/sites/landingpage/IntrinsicsGuide/#text=cvt&expand=1810&techs=SSE,SSE2).

 

View solution in original post

0 Kudos