Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is the difference between these 128bit SIMD xor operations

Intel provides several SIMD commands, which seems all performing bitwise XOR on 128-bit data:

_mm_xor_pd(__m128d, __m128d)
_mm_xor_ps(__m128, __m128)
_mm_xor_si128(__m128i, __m128i)

Isn't bitwise operations only operate on bit streams? Why there are three operations that have different type but same data size?

like image 880
jiandingzhe Avatar asked Mar 18 '15 13:03

jiandingzhe


People also ask

How to return 1 when two bits are equal in XOR?

XOR returns 1 only if exactly one bit is set to 1 out of the two bits in comparison ( Exclusive OR) The only way you can totally understand how the above solution is working is by trying it out for different binary numbers on a piece of paper. The biggest hint you have is you can do it using ( ^ ) operator.

What is an XOR bit pattern?

If both bits in the compared position of the bit patterns are 0 or 1, the bit in the resulting bit pattern is 0, otherwise 1. In short, it means that it returns 1 only if exactly one bit is set to 1 out of the two bits in comparison ( Exclusive OR ). That was the basic stuff about XOR.

What is the difference between SIMD and MIMD?

Where, SIMD stands for Single Instruction Multiple Data. MIMD stands for Multiple Instruction Multiple Data. In SIMD design, one instruction is applied to a bunch of information or distinct data at constant time. SIMD is less efficient in terms of performance than MIMD.

How much data can a 128-bit processor store?

128-bit processors could be used for addressing directly up to 2 128 (over 3.40 × 1038) bytes, which would greatly exceed the total data captured, created, or replicated on Earth as of 2018, which has been estimated to be around 33 zettabytes (over 2 74 bytes). [1] A 128-bit register can store 2 128 (over 3.40 × 10 38) different values.


2 Answers

_mm_xor_pd(__m128d, __m128d) operates on two 64 bit double precision floats

[https://msdn.microsoft.com/en-us/library/w87cdc33%28v=vs.90%29.aspx1

_mm_xor_ps(__m128d, __m128d) operates on four 32 bit single precision floats

https://msdn.microsoft.com/en-us/library/ss6k3wk8(v=vs.90).aspx

_mm_xor_si128(__m128d, __m128d) operates on one 128 bit value

https://msdn.microsoft.com/en-us/library/fzt08www%28v=vs.90%29.aspx

An XOR can be used between any two binary numbers regardless of their format. Why three? Because it's a balance to support common data types (float, double and 128 bits) and not have two many instructions.

The balance is the amount of silicon used, as each set of operations may occur in a separate functional units (integer, float, double). If they use different silicon all the different types of operation could execute in parallel.

like image 144
Tim Child Avatar answered Oct 29 '22 16:10

Tim Child


From a strict C point of view, they are all different because of the types.

They might also be hints for the CPUs about which kind of data you are intending to manage. At least this is the best interpretation the experts come with. As they said, this needs to be checked on hardware though.

like image 29
AntoineL Avatar answered Oct 29 '22 17:10

AntoineL