diff options
author | Antonio Sanchez <cantonios@google.com> | 2021-01-07 09:39:05 -0800 |
---|---|---|
committer | Rasmus Munk Larsen <rmlarsen@google.com> | 2021-01-08 01:17:19 +0000 |
commit | f149e0ebc3d3d5ca63234e58ca72690caf07e3b5 (patch) | |
tree | 8c5431fd057c96b8231be84b2908d130b49d61ec /test/packetmath_test_shared.h | |
parent | 8d9cfba799ce3462c12568a36392e0abf36fc62d (diff) |
Fix MSVC complex sqrt and packetmath test.
MSVC incorrectly handles `inf` cases for `std::sqrt<std::complex<T>>`.
Here we replace it with a custom version (currently used on GPU).
Also fixed the `packetmath` test, which previously skipped several
corner cases since `CHECK_CWISE1` only tests the first `PacketSize`
elements.
Diffstat (limited to 'test/packetmath_test_shared.h')
-rw-r--r-- | test/packetmath_test_shared.h | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/test/packetmath_test_shared.h b/test/packetmath_test_shared.h index f8dc3711c..46a42604b 100644 --- a/test/packetmath_test_shared.h +++ b/test/packetmath_test_shared.h @@ -115,6 +115,17 @@ template<typename Scalar> bool areApprox(const Scalar* a, const Scalar* b, int s VERIFY(test::areApprox(ref, data2, PacketSize) && #POP); \ } +// Checks component-wise for input of size N. All of data1, data2, and ref +// should have size at least ceil(N/PacketSize)*PacketSize to avoid memory +// access errors. +#define CHECK_CWISE1_N(REFOP, POP, N) { \ + for (int i=0; i<N; ++i) \ + ref[i] = REFOP(data1[i]); \ + for (int j=0; j<N; j+=PacketSize) \ + internal::pstore(data2 + j, POP(internal::pload<Packet>(data1 + j))); \ + VERIFY(test::areApprox(ref, data2, N) && #POP); \ +} + template<bool Cond,typename Packet> struct packet_helper { |