c++ - Which is the reason for avx floating point bitwise logical operations? -
AVX bitwise allows logical operations such as and / or floating point data-type __m256 and __m256d.
However, C ++ does not allow for bitwise operation on floats and doubles, reasonably. If I am right then there is no guarantee of the internal representation of floats, whether compiler will use IEEE 754 or not, so a programmer can not ensure that what a float's bits will look like.
#include & lt; Immintrin.h & gt; # Include & lt; Iostream & gt; #include & lt; Limits & gt; # Include & lt; Cassert & gt; Int main () {float x [8] = {1,2,3,4,5,6,7,8}; Float mask [8] = {-1,0,0, -1,0, -1,0,0}; Float x_mascade [8]; Emphasis (std :: numeric_limits & lt; float & gt; :: is_iec559); __M 256 x_ = _mm256_load_ps (x); __ meter 256 mask_ = _mm256_ load_s (mask); __ meter 256 x_masked_ = _mm256_and_ps (x_, mask_); _mm256_store_ps (x_masked, x_masked_); (Int i = 0; i & lt; 8; i ++) for std :: cout & lt; & Lt; X_masked [i] & lt; & Lt; ""; Return 0; } assuming that IEEE754 is used because -1 is represented by 0xffffffff, I expect that output should be
1,0 , 0, 4,0,6,0,0 instead of
1 0 0 1.17549e-38 0 1.17549e-38 0 0 So my belief about internal representation was probably wrong (or I have made some silly mistake).
So the question is: Is there a way in which I think the floating point is logical and safe to the fact that the result will mean?
If you are using AVX internal, then you know that you can use IEEE 754 floats Because this is what AVX does the same.
Some bits of floats which you choose
- , Jane's answer, though we have
blendvps and its relatives as SSE 4.1 In one instruction - Full value (signature mask away)
- Rejected (X-0.0F)
- Signature transfer
- Extra Lean exponent (rare)
Mostly it is meant to tamper or select entire floats to zero, It is not so much to blink about the individual or bit of personal bit of suponent - you can do this, but it is rarely useful.
Comments
Post a Comment