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.
This commit is contained in:
Antonio Sanchez
2021-01-07 09:39:05 -08:00
committed by Rasmus Munk Larsen
parent 8d9cfba799
commit f149e0ebc3
5 changed files with 84 additions and 47 deletions

View File

@@ -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
{