From: Matthias Kretz <m.kretz@gsi.de>
To: <gcc-patches@gcc.gnu.org>, <libstdc++@gcc.gnu.org>
Subject: [PATCH 13/16] Improve test codegen for interpreting assembly
Date: Wed, 27 Jan 2021 21:42:42 +0100 [thread overview]
Message-ID: <18217938.xuKvIAzr1H@excalibur> (raw)
In-Reply-To: <4667217.5jz8CO7rxU@excalibur>
From: Matthias Kretz <kretz@kde.org>
In many failure cases it is helpful to inspect the instructions leading
up to the test failure. After this change the location is easier to find
and the branch after failure is easier to find.
libstdc++-v3/ChangeLog:
* testsuite/experimental/simd/tests/bits/verify.h (verify): Add
instruction pointer data member. Ensure that the `if (m_failed)`
branch is always inlined into the calling code. The body of the
conditional can still be a function call. Move the get_ip call
into the verify ctor to simplify the ctor calls.
(COMPARE): Don't mention the use of all_of for reduction of a
simd_mask. It only distracts from the real issue.
---
.../experimental/simd/tests/bits/verify.h | 44 +++++++++----------
1 file changed, 22 insertions(+), 22 deletions(-)
diff --git a/libstdc++-v3/testsuite/experimental/simd/tests/bits/verify.h b/
libstdc++-v3/testsuite/experimental/simd/tests/bits/verify.h
index 5da47b35536..17bda71b77e 100644
--- a/libstdc++-v3/testsuite/experimental/simd/tests/bits/verify.h
+++ b/libstdc++-v3/testsuite/experimental/simd/tests/bits/verify.h
@@ -60,6 +60,7 @@ template <class T>
class verify
{
const bool m_failed = false;
+ size_t m_ip = 0;
template <typename T,
typename = decltype(std::declval<std::stringstream&>()
@@ -129,20 +130,21 @@ class verify
public:
template <typename... Ts>
- verify(bool ok, size_t ip, const char* file, const int line,
+ [[gnu::always_inline]]
+ verify(bool ok, const char* file, const int line,
const char* func, const char* cond, const Ts&... extra_info)
- : m_failed(!ok)
+ : m_failed(!ok), m_ip(get_ip())
{
if (m_failed)
- {
+ [&] {
__builtin_fprintf(stderr, "%s:%d: (%s):\nInstruction Pointer: %x\n"
"Assertion '%s' failed.\n",
- file, line, func, ip, cond);
+ file, line, func, m_ip, cond);
(print(extra_info, int()), ...);
- }
+ }();
}
- ~verify()
+ [[gnu::always_inline]] ~verify()
{
if (m_failed)
{
@@ -152,26 +154,27 @@ public:
}
template <typename T>
+ [[gnu::always_inline]]
const verify&
operator<<(const T& x) const
{
if (m_failed)
- {
- print(x, int());
- }
+ print(x, int());
return *this;
}
template <typename... Ts>
+ [[gnu::always_inline]]
const verify&
on_failure(const Ts&... xs) const
{
if (m_failed)
- (print(xs, int()), ...);
+ [&] { (print(xs, int()), ...); }();
return *this;
}
- [[gnu::always_inline]] static inline size_t
+ [[gnu::always_inline]] static inline
+ size_t
get_ip()
{
size_t _ip = 0;
@@ -220,24 +223,21 @@ template <typename T>
#define COMPARE(_a, _b)
\
[&](auto&& _aa, auto&& _bb) {
\
- return verify(std::experimental::all_of(_aa == _bb), verify::get_ip(),
\
- __FILE__, __LINE__, __PRETTY_FUNCTION__, \
- "all_of(" #_a " == " #_b ")", #_a " = ", _aa, \
+ return verify(std::experimental::all_of(_aa == _bb), __FILE__, __LINE__,
\
+ __PRETTY_FUNCTION__, #_a " == " #_b, #_a " = ", _aa, \
"\n" #_b " = ", _bb); \
}(force_fp_truncation(_a), force_fp_truncation(_b))
#else
#define COMPARE(_a, _b)
\
[&](auto&& _aa, auto&& _bb) {
\
- return verify(std::experimental::all_of(_aa == _bb), verify::get_ip(),
\
- __FILE__, __LINE__, __PRETTY_FUNCTION__, \
- "all_of(" #_a " == " #_b ")", #_a " = ", _aa, \
+ return verify(std::experimental::all_of(_aa == _bb), __FILE__, __LINE__,
\
+ __PRETTY_FUNCTION__, #_a " == " #_b, #_a " = ", _aa, \
"\n" #_b " = ", _bb); \
}((_a), (_b))
#endif
#define VERIFY(_test)
\
- verify(_test, verify::get_ip(), __FILE__, __LINE__, __PRETTY_FUNCTION__,
\
- #_test)
+ verify(_test, __FILE__, __LINE__, __PRETTY_FUNCTION__, #_test)
// ulp_distance_signed can raise FP exceptions and thus must be
conditionally
// executed
@@ -245,9 +245,9 @@ template <typename T>
[&](auto&& _aa, auto&& _bb) {
\
const bool success = std::experimental::all_of(
\
vir::test::ulp_distance(_aa, _bb) <= (_allowed_distance));
\
- return verify(success, verify::get_ip(), __FILE__, __LINE__,
\
- __PRETTY_FUNCTION__, "all_of(" #_a " ~~ " #_b ")", \
- #_a " = ", _aa, "\n" #_b " = ", _bb, "\ndistance = ", \
+ return verify(success, __FILE__, __LINE__, __PRETTY_FUNCTION__,
\
+ #_a " ~~ " #_b, #_a " = ", _aa, "\n" #_b " = ", _bb, \
+ "\ndistance = ", \
success ? 0 : vir::test::ulp_distance_signed(_aa, _bb)); \
}((_a), (_b))
--
──────────────────────────────────────────────────────────────────────────
Dr. Matthias Kretz https://mattkretz.github.io
GSI Helmholtz Centre for Heavy Ion Research https://gsi.de
std::experimental::simd https://github.com/VcDevel/std-simd
──────────────────────────────────────────────────────────────────────────
next prev parent reply other threads:[~2021-01-27 20:42 UTC|newest]
Thread overview: 19+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-01-27 20:36 [PATCH 00/16] stdx::simd fixes and testsuite improvements Matthias Kretz
2021-01-27 20:41 ` [PATCH 02/16] Fix NEON intrinsic types usage Matthias Kretz
2021-01-27 20:42 ` [PATCH 03/16] Support -mlong-double-64 on PPC Matthias Kretz
2021-01-27 20:42 ` [PATCH 04/16] Fix simd_mask<double> on POWER w/o POWER8 Matthias Kretz
2021-01-27 20:42 ` [PATCH 05/16] Fix several check-simd interaction issues Matthias Kretz
2021-01-27 20:42 ` [PATCH 06/16] Fix DRIVEROPTS and TESTFLAGS processing Matthias Kretz
2021-01-27 20:42 ` [PATCH 07/16] Fix incorrect display of old test summaries Matthias Kretz
2021-01-27 20:42 ` [PATCH 08/16] Immediate feedback with -v Matthias Kretz
2021-01-27 20:42 ` [PATCH 09/16] Fix mask reduction of simd_mask<double> on POWER7 Matthias Kretz
2021-01-27 20:42 ` [PATCH 10/16] Skip testing hypot3 for long double on PPC Matthias Kretz
2021-01-27 20:42 ` [PATCH 11/16] Abort test after 1000 lines of output Matthias Kretz
2021-01-27 20:42 ` [PATCH 12/16] Support timeout and timeout-factor options Matthias Kretz
2021-01-27 20:42 ` Matthias Kretz [this message]
2021-02-02 15:02 ` [PATCH 13/16] Improve test codegen for interpreting assembly Jonathan Wakely
2021-01-27 20:42 ` [PATCH 14/16] Implement hmin and hmax Matthias Kretz
2021-02-01 10:23 ` Matthias Kretz
2021-01-27 20:42 ` [PATCH 15/16] Work around test failures using -mno-tree-vrp Matthias Kretz
2021-01-27 20:42 ` [PATCH 16/16] Improve "find_first/last_set" for NEON Matthias Kretz
2021-02-03 15:52 ` [PATCH 00/16] stdx::simd fixes and testsuite improvements Jonathan Wakely
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=18217938.xuKvIAzr1H@excalibur \
--to=m.kretz@gsi.de \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).