diff options
author | Rasmus Munk Larsen <rmlarsen@google.com> | 2020-11-24 20:53:07 +0000 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2020-11-24 20:53:07 +0000 |
commit | c770746d709686ef2b8b652616d9232f9b028e78 (patch) | |
tree | 624821fa175d8f40cc13886d7483ffd35e9da1e3 /test/packetmath.cpp | |
parent | 22f67b59585805fedf86759f7013b2b670f83386 (diff) |
Fix Half NaN definition and test.
The `half_float` test was failing with `-mcpu=cortex-a55` (native `__fp16`) due
to a bad NaN bit-pattern comparison (in the case of casting a float to `__fp16`,
the signaling `NaN` is quieted). There was also an inconsistency between
`numeric_limits<half>::quiet_NaN()` and `NumTraits::quiet_NaN()`. Here we
correct the inconsistency and compare NaNs according to the IEEE 754
definition.
Also modified the `bfloat16_float` test to match.
Tested with `cortex-a53` and `cortex-a55`.
Diffstat (limited to 'test/packetmath.cpp')
-rw-r--r-- | test/packetmath.cpp | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/test/packetmath.cpp b/test/packetmath.cpp index d52f997dc..40129075f 100644 --- a/test/packetmath.cpp +++ b/test/packetmath.cpp @@ -473,8 +473,6 @@ void packetmath() { CHECK_CWISE3_IF(true, internal::pselect, internal::pselect); } - CHECK_CWISE1_IF(PacketTraits::HasSqrt, numext::sqrt, internal::psqrt); - for (int i = 0; i < size; ++i) { data1[i] = internal::random<Scalar>(); } @@ -486,6 +484,11 @@ void packetmath() { packetmath_boolean_mask_ops<Scalar, Packet>(); packetmath_pcast_ops_runner<Scalar, Packet>::run(); packetmath_minus_zero_add<Scalar, Packet>(); + + for (int i = 0; i < size; ++i) { + data1[i] = numext::abs(internal::random<Scalar>()); + } + CHECK_CWISE1_IF(PacketTraits::HasSqrt, numext::sqrt, internal::psqrt); } template <typename Scalar, typename Packet> @@ -966,6 +969,8 @@ void test_conj_helper(Scalar* data1, Scalar* data2, Scalar* ref, Scalar* pval) { template <typename Scalar, typename Packet> void packetmath_complex() { + typedef internal::packet_traits<Scalar> PacketTraits; + typedef typename Scalar::value_type RealScalar; const int PacketSize = internal::unpacket_traits<Packet>::size; const int size = PacketSize * 4; @@ -984,11 +989,17 @@ void packetmath_complex() { test_conj_helper<Scalar, Packet, true, false>(data1, data2, ref, pval); test_conj_helper<Scalar, Packet, true, true>(data1, data2, ref, pval); + // Test pcplxflip. { for (int i = 0; i < PacketSize; ++i) ref[i] = Scalar(std::imag(data1[i]), std::real(data1[i])); internal::pstore(pval, internal::pcplxflip(internal::pload<Packet>(data1))); VERIFY(test::areApprox(ref, pval, PacketSize) && "pcplxflip"); } + + for (int i = 0; i < size; ++i) { + data1[i] = Scalar(internal::random<RealScalar>(), internal::random<RealScalar>()); + } + CHECK_CWISE1_IF(PacketTraits::HasSqrt, numext::sqrt, internal::psqrt); } template <typename Scalar, typename Packet> |