From d052b7f8642ea4e536d9f1fe5c5d52b863db05d3 Mon Sep 17 00:00:00 2001 From: Charles Schlosser Date: Tue, 24 Sep 2024 21:08:22 +0000 Subject: [PATCH] add extra debugging info to float_pow_test_impl, clean up array_cwise tests --- test/array_cwise.cpp | 62 +++----------------------------------------- test/main.h | 62 ++++++++++++++++++++++++++++++++++++-------- 2 files changed, 55 insertions(+), 69 deletions(-) diff --git a/test/array_cwise.cpp b/test/array_cwise.cpp index d032e0b76..01f5a990f 100644 --- a/test/array_cwise.cpp +++ b/test/array_cwise.cpp @@ -65,7 +65,7 @@ std::vector special_values() { template void special_value_pairs(Array& x, Array& y) { std::vector vals = special_values(); - int num_cases = vals.size() * vals.size(); + std::size_t num_cases = vals.size() * vals.size(); // ensure both vectorized and non-vectorized paths taken const Index num_repeats = 2 * (Index)internal::packet_traits::size + 1; x.resize(num_repeats, num_cases); @@ -294,6 +294,7 @@ void float_pow_test_impl() { bool success = both_nan || (exact_or_approx && same_sign); all_pass &= success; if (!success) { + std::cout << "Base type: " << type_name(base) << ", Exponent type: " << type_name(exponent) << std::endl; std::cout << "pow(" << bases(j) << "," << exponent << ") = " << a << " != " << e << std::endl; } } @@ -1250,61 +1251,6 @@ void typed_logicals_test(const ArrayType& m) { typed_logicals_test_impl::run(m); } -// print non-mangled typenames -template -std::string printTypeInfo(const T&) { - return typeid(T).name(); -} -template <> -std::string printTypeInfo(const int8_t&) { - return "int8_t"; -} -template <> -std::string printTypeInfo(const int16_t&) { - return "int16_t"; -} -template <> -std::string printTypeInfo(const int32_t&) { - return "int32_t"; -} -template <> -std::string printTypeInfo(const int64_t&) { - return "int64_t"; -} -template <> -std::string printTypeInfo(const uint8_t&) { - return "uint8_t"; -} -template <> -std::string printTypeInfo(const uint16_t&) { - return "uint16_t"; -} -template <> -std::string printTypeInfo(const uint32_t&) { - return "uint32_t"; -} -template <> -std::string printTypeInfo(const uint64_t&) { - return "uint64_t"; -} -template <> -std::string printTypeInfo(const float&) { - return "float"; -} -template <> -std::string printTypeInfo(const double&) { - return "double"; -} -// template<> std::string printTypeInfo(const long double&) { return "long double"; } -template <> -std::string printTypeInfo(const half&) { - return "half"; -} -template <> -std::string printTypeInfo(const bfloat16&) { - return "bfloat16"; -} - template struct cast_test_impl { using SrcArray = Array; @@ -1340,8 +1286,8 @@ struct cast_test_impl { DstType dstVal = dst(i, j); bool isApprox = verifyIsApprox(dstVal, refVal); if (!isApprox) - std::cout << printTypeInfo(srcVal) << ": [" << +srcVal << "] to " << printTypeInfo(dstVal) << ": [" - << +dstVal << "] != [" << +refVal << "]\n"; + std::cout << type_name(srcVal) << ": [" << +srcVal << "] to " << type_name(dstVal) << ": [" << +dstVal + << "] != [" << +refVal << "]\n"; VERIFY(isApprox); } } diff --git a/test/main.h b/test/main.h index ca1748d23..c7cc531dc 100644 --- a/test/main.h +++ b/test/main.h @@ -742,41 +742,81 @@ struct GetDifferentType > { }; template -std::string type_name() { - return "other"; +std::string type_name(T) { + return typeid(T).name(); } template <> -std::string type_name() { +std::string type_name(float) { return "float"; } template <> -std::string type_name() { +std::string type_name(double) { return "double"; } template <> -std::string type_name() { +std::string type_name(long double) { return "long double"; } template <> -std::string type_name() { - return "int"; +std::string type_name(Eigen::half) { + return "half"; } template <> -std::string type_name >() { +std::string type_name(Eigen::bfloat16) { + return "bfloat16"; +} +template <> +std::string type_name(int8_t) { + return "int8_t"; +} +template <> +std::string type_name(int16_t) { + return "int16_t"; +} +template <> +std::string type_name(int32_t) { + return "int32_t"; +} +template <> +std::string type_name(int64_t) { + return "int64_t"; +} +template <> +std::string type_name(uint8_t) { + return "uint8_t"; +} +template <> +std::string type_name(uint16_t) { + return "uint16_t"; +} +template <> +std::string type_name(uint32_t) { + return "uint32_t"; +} +template <> +std::string type_name(uint64_t) { + return "uint64_t"; +} +template <> +std::string type_name >(std::complex) { return "complex"; } template <> -std::string type_name >() { +std::string type_name >(std::complex) { return "complex"; } template <> -std::string type_name >() { +std::string type_name >(std::complex) { return "complex"; } template <> -std::string type_name >() { +std::string type_name >(std::complex) { return "complex"; } +template +std::string type_name() { + return type_name(T()); +} using namespace Eigen;