aboutsummaryrefslogtreecommitdiffhomepage
path: root/Eigen/src/Core/arch/NEON/PacketMath.h
diff options
context:
space:
mode:
authorGravatar Antonio Sanchez <cantonios@google.com>2021-02-23 19:48:46 -0800
committerGravatar Antonio Sanchez <cantonios@google.com>2021-02-23 19:52:55 -0800
commit6cf0ab5e99c27cb7b128e55991fbad5a7d234c8e (patch)
treec79c33c314474daa7aac485d1044dffc713c0d63 /Eigen/src/Core/arch/NEON/PacketMath.h
parentaba39982786c8aa2b1486ebdf2d9b51a43e0bcee (diff)
Disable fast psqrt for NEON.
Accuracy is too poor - requires at least two Newton iterations, but then it is no longer significantly faster than `vsqrt`. Fixes #2094.
Diffstat (limited to 'Eigen/src/Core/arch/NEON/PacketMath.h')
-rw-r--r--Eigen/src/Core/arch/NEON/PacketMath.h34
1 files changed, 0 insertions, 34 deletions
diff --git a/Eigen/src/Core/arch/NEON/PacketMath.h b/Eigen/src/Core/arch/NEON/PacketMath.h
index 2e06befc2..b2170e9f7 100644
--- a/Eigen/src/Core/arch/NEON/PacketMath.h
+++ b/Eigen/src/Core/arch/NEON/PacketMath.h
@@ -3297,42 +3297,8 @@ template<> EIGEN_STRONG_INLINE Packet4ui psqrt(const Packet4ui& a) {
return res;
}
-#if EIGEN_FAST_MATH
-
-/* Functions for sqrt support packet2f/packet4f.*/
-// The EIGEN_FAST_MATH version uses the vrsqrte_f32 approximation and one step
-// of Newton's method, at a cost of 1-2 bits of precision as opposed to the
-// exact solution. It does not handle +inf, or denormalized numbers correctly.
-// The main advantage of this approach is not just speed, but also the fact that
-// it can be inlined and pipelined with other computations, further reducing its
-// effective latency. This is similar to Quake3's fast inverse square root.
-// For more details see: http://www.beyond3d.com/content/articles/8/
-template<> EIGEN_STRONG_INLINE Packet4f psqrt(const Packet4f& _x){
- Packet4ui denormal_mask = vandq_u32(vcgeq_f32(_x, vdupq_n_f32(0.0f)),
- vcltq_f32(_x, pset1<Packet4f>((std::numeric_limits<float>::min)())));
- // Compute approximate reciprocal sqrt.
- Packet4f x = vrsqrteq_f32(_x);
- // Do one Newton's iteration for 1/sqrt(x).
- x = vmulq_f32(vrsqrtsq_f32(vmulq_f32(_x, x), x), x);
- // Flush results for denormals to zero.
- return vreinterpretq_f32_u32(vbicq_u32(vreinterpretq_u32_f32(pmul(_x, x)), denormal_mask));
-}
-
-template<> EIGEN_STRONG_INLINE Packet2f psqrt(const Packet2f& _x) {
- Packet2ui denormal_mask = vand_u32(vcge_f32(_x, vdup_n_f32(0.0f)),
- vclt_f32(_x, pset1<Packet2f>((std::numeric_limits<float>::min)())));
- // Compute approximate reciprocal sqrt.
- Packet2f x = vrsqrte_f32(_x);
- // Do one Newton's iteration for 1/sqrt(x).
- x = vmul_f32(vrsqrts_f32(vmul_f32(_x, x), x), x);
- // Flush results for denormals to zero.
- return vreinterpret_f32_u32(vbic_u32(vreinterpret_u32_f32(pmul(_x, x)), denormal_mask));
-}
-
-#else
template<> EIGEN_STRONG_INLINE Packet4f psqrt(const Packet4f& _x){return vsqrtq_f32(_x);}
template<> EIGEN_STRONG_INLINE Packet2f psqrt(const Packet2f& _x){return vsqrt_f32(_x); }
-#endif
//---------- bfloat16 ----------
// TODO: Add support for native armv8.6-a bfloat16_t