From 90323f1751ca170490b5a7590410ef5d05d62ac5 Mon Sep 17 00:00:00 2001 From: Gael Guennebaud Date: Wed, 4 Nov 2015 22:15:57 +0100 Subject: [PATCH] Fix AVX round/ceil/floor, and fix respective unit test --- Eigen/src/Core/arch/AVX/PacketMath.h | 12 ++++++------ test/packetmath.cpp | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/Eigen/src/Core/arch/AVX/PacketMath.h b/Eigen/src/Core/arch/AVX/PacketMath.h index b313fb09a..717ae67c5 100644 --- a/Eigen/src/Core/arch/AVX/PacketMath.h +++ b/Eigen/src/Core/arch/AVX/PacketMath.h @@ -182,14 +182,14 @@ template<> EIGEN_STRONG_INLINE Packet4d pmin(const Packet4d& a, const template<> EIGEN_STRONG_INLINE Packet8f pmax(const Packet8f& a, const Packet8f& b) { return _mm256_max_ps(a,b); } template<> EIGEN_STRONG_INLINE Packet4d pmax(const Packet4d& a, const Packet4d& b) { return _mm256_max_pd(a,b); } -template<> EIGEN_STRONG_INLINE Packet4f pround(const Packet8f& a) { return _mm256_round_ps(a, 0); } -template<> EIGEN_STRONG_INLINE Packet2d pround(const Packet4d& a) { return _mm256_round_pd(a, 0); } +template<> EIGEN_STRONG_INLINE Packet8f pround(const Packet8f& a) { return _mm256_round_ps(a, _MM_FROUND_CUR_DIRECTION); } +template<> EIGEN_STRONG_INLINE Packet4d pround(const Packet4d& a) { return _mm256_round_pd(a, _MM_FROUND_CUR_DIRECTION); } -template<> EIGEN_STRONG_INLINE Packet4f pceil(const Packet8f& a) { return _mm256_ceil_ps(a); } -template<> EIGEN_STRONG_INLINE Packet2d pceil(const Packet4d& a) { return _mm256_ceil_pd(a); } +template<> EIGEN_STRONG_INLINE Packet8f pceil(const Packet8f& a) { return _mm256_ceil_ps(a); } +template<> EIGEN_STRONG_INLINE Packet4d pceil(const Packet4d& a) { return _mm256_ceil_pd(a); } -template<> EIGEN_STRONG_INLINE Packet4f pfloor(const Packet8f& a) { return _mm256_floor_ps(a); } -template<> EIGEN_STRONG_INLINE Packet2d pfloor(const Packet4d& a) { return _mm256_floor_pd(a); } +template<> EIGEN_STRONG_INLINE Packet8f pfloor(const Packet8f& a) { return _mm256_floor_ps(a); } +template<> EIGEN_STRONG_INLINE Packet4d pfloor(const Packet4d& a) { return _mm256_floor_pd(a); } template<> EIGEN_STRONG_INLINE Packet8f pand(const Packet8f& a, const Packet8f& b) { return _mm256_and_ps(a,b); } template<> EIGEN_STRONG_INLINE Packet4d pand(const Packet4d& a, const Packet4d& b) { return _mm256_and_pd(a,b); } diff --git a/test/packetmath.cpp b/test/packetmath.cpp index dea648002..b6616ac5e 100644 --- a/test/packetmath.cpp +++ b/test/packetmath.cpp @@ -29,7 +29,7 @@ template bool areApproxAbs(const Scalar* a, const Scalar* b, in { if (!isApproxAbs(a[i],b[i],refvalue)) { - std::cout << "[" << Map >(a,size) << "]" << " != " << Map >(b,size) << "\n"; + std::cout << "ref: [" << Map >(a,size) << "]" << " != vec: [" << Map >(b,size) << "]\n"; return false; } } @@ -42,7 +42,7 @@ template bool areApprox(const Scalar* a, const Scalar* b, int s { if (a[i]!=b[i] && !internal::isApprox(a[i],b[i])) { - std::cout << "[" << Map >(a,size) << "]" << " != " << Map >(b,size) << "\n"; + std::cout << "ref: [" << Map >(a,size) << "]" << " != vec: [" << Map >(b,size) << "]\n"; return false; } } @@ -296,10 +296,6 @@ template void packetmath_real() EIGEN_ALIGN_MAX Scalar data2[PacketTraits::size*4]; EIGEN_ALIGN_MAX Scalar ref[PacketTraits::size*4]; - CHECK_CWISE1_IF(PacketTraits::HasRound, std::round, internal::pround); - CHECK_CWISE1_IF(PacketTraits::HasCeil, std::ceil, internal::pceil); - CHECK_CWISE1_IF(PacketTraits::HasFloor, std::floor, internal::pfloor); - for (int i=0; i(-1,1) * std::pow(Scalar(10), internal::random(-3,3)); @@ -308,6 +304,10 @@ template void packetmath_real() CHECK_CWISE1_IF(PacketTraits::HasSin, std::sin, internal::psin); CHECK_CWISE1_IF(PacketTraits::HasCos, std::cos, internal::pcos); CHECK_CWISE1_IF(PacketTraits::HasTan, std::tan, internal::ptan); + + CHECK_CWISE1_IF(PacketTraits::HasRound, numext::round, internal::pround); + CHECK_CWISE1_IF(PacketTraits::HasCeil, numext::ceil, internal::pceil); + CHECK_CWISE1_IF(PacketTraits::HasFloor, numext::floor, internal::pfloor); for (int i=0; i