aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/packetmath.cpp
diff options
context:
space:
mode:
authorGravatar Rasmus Munk Larsen <rmlarsen@google.com>2019-08-12 13:53:28 -0700
committerGravatar Rasmus Munk Larsen <rmlarsen@google.com>2019-08-12 13:53:28 -0700
commita3298b22ecd19a80a2fc03df3d463fdb04907c87 (patch)
treed6d9788ebd3a55539649240aa59a22479160a20a /test/packetmath.cpp
parentd55d392e7b1136655b4223bea8e99cb2fe0a8afd (diff)
Implement vectorized versions of log1p and expm1 in Eigen using Kahan's formulas, and change the scalar implementations to properly handle infinite arguments.
Depending on instruction set, significant speedups are observed for the vectorized path: log1p wall time is reduced 60-93% (2.5x - 15x speedup) expm1 wall time is reduced 0-85% (1x - 7x speedup) The scalar path is slower by 20-30% due to the extra branch needed to handle +infinity correctly. Full benchmarks measured on Intel(R) Xeon(R) Gold 6154 here: https://bitbucket.org/snippets/rmlarsen/MXBkpM
Diffstat (limited to 'test/packetmath.cpp')
-rw-r--r--test/packetmath.cpp6
1 files changed, 4 insertions, 2 deletions
diff --git a/test/packetmath.cpp b/test/packetmath.cpp
index f1448f335..41000a842 100644
--- a/test/packetmath.cpp
+++ b/test/packetmath.cpp
@@ -604,11 +604,13 @@ template<typename Scalar,typename Packet> void packetmath_real()
CHECK_CWISE1_IF(PacketTraits::HasSqrt, Scalar(1)/std::sqrt, internal::prsqrt);
CHECK_CWISE1_IF(PacketTraits::HasLog, std::log, internal::plog);
#if EIGEN_HAS_C99_MATH && (__cplusplus > 199711L)
- CHECK_CWISE1_IF(PacketTraits::HasExpm1, std::expm1, internal::pexpm1);
- CHECK_CWISE1_IF(PacketTraits::HasLog1p, std::log1p, internal::plog1p);
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasLGamma, std::lgamma, internal::plgamma);
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasErf, std::erf, internal::perf);
CHECK_CWISE1_IF(internal::packet_traits<Scalar>::HasErfc, std::erfc, internal::perfc);
+ data1[0] = std::numeric_limits<Scalar>::infinity();
+ data1[1] = std::numeric_limits<Scalar>::denorm_min();
+ CHECK_CWISE1_IF(PacketTraits::HasExpm1, std::expm1, internal::pexpm1);
+ CHECK_CWISE1_IF(PacketTraits::HasLog1p, std::log1p, internal::plog1p);
#endif
if(PacketSize>=2)