From: Jonathan Wakely <jwakely@redhat.com>
To: Matthias Kretz <m.kretz@gsi.de>
Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org
Subject: Re: [PATCH] Add simd testsuite
Date: Thu, 17 Dec 2020 13:10:51 +0000 [thread overview]
Message-ID: <20201217131051.GX2309743@redhat.com> (raw)
In-Reply-To: <8364569.lWL0Ik8vYZ@excalibur>
On 16/12/20 12:58 +0100, Matthias Kretz wrote:
>--- /dev/null
>+++ b/libstdc++-v3/scripts/check_simd
>@@ -0,0 +1,76 @@
>+#!/bin/sh
>+
>+# check_simd <srcdir> <builddir> <CXXFLAGS>
>+# Read config from $CHECK_SIMD_CONFIG file or $target_list
>+
>+scriptdir="$(cd "${0%/*}" && pwd)"
The ${0%/*} substitution is required by POSIX sh since at least 2001,
but it looks like autoconf uses dirname for this instead. I think this
is OK, we can change to dirname if somebody reports a problem.
+# per a/b/c block extract flags and simulator, then make check-simd
>+while [ ${#list} -gt 0 ]; do
>+ a="${list%% *}"
>+ if [ "$a" = "$list" ]; then
>+ list=""
>+ else
>+ list="${list#${a} }"
>+ fi
>+ b="${a%%/*}"
>+ eval "eval \"\$$b\""
>+ flags="${flags}$(echo "${a#${b}}"|sed 's#/# #g')"
>+ subdir="simd/$(echo "$flags" | sed 's#[= /-]##g')"
>+ rm -f "${subdir}/Makefile"
>+ $srcdir/testsuite/experimental/simd/generate_makefile.sh \
>+ --destination="$testdir/$subdir" $CXX $INCLUDES $CXXFLAGS -static
Is the -static here to avoid needing LD_LIBRARY_PATH to find
libstdc++.so?
If you don't have libc.a installed it won't work. How about
using -static-libgcc -static-libstdc++ instead?
>diff --git a/libstdc++-v3/testsuite/experimental/simd/tests/abs.cc b/libstdc++-v3/testsuite/experimental/simd/tests/abs.cc
>new file mode 100644
>index 00000000000..3f81bf03a40
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/experimental/simd/tests/abs.cc
>@@ -0,0 +1,24 @@
>+#include "bits/verify.h"
>+#include "bits/metahelpers.h"
We'd usually put these testsuite helper files in testsuite/util, maybe
in a testsuite/util/simd sub-dir, but I suppose keeping them local to
the tests is OK too.
>+#include <cmath> // abs & sqrt
>+#include <cstdlib> // integer abs
>+#include "bits/test_values.h"
>+
>+template <typename V>
>+ void
>+ test()
>+ {
>+ if constexpr (std::is_signed_v<typename V::value_type>)
>+ {
>+ using std::abs;
>+ using T = typename V::value_type;
>+ test_values<V>({std::__finite_max_v<T>, std::__norm_min_v<T>,
>+ -std::__norm_min_v<T>, std::__finite_min_v<T>,
>+ std::__finite_min_v<T> / 2, T(), -T(), T(-1), T(-2)},
>+ {1000}, [](V input) {
>+ const V expected(
>+ [&](auto i) { return T(std::abs(T(input[i]))); });
>+ COMPARE(abs(input), expected) << "input: " << input;
>+ });
>+ }
>+ }
>diff --git a/libstdc++-v3/testsuite/experimental/simd/tests/algorithms.cc b/libstdc++-v3/testsuite/experimental/simd/tests/algorithms.cc
>new file mode 100644
>index 00000000000..f79bb6b63d2
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/experimental/simd/tests/algorithms.cc
>@@ -0,0 +1,13 @@
>+#include "bits/verify.h"
>+#include "bits/metahelpers.h"
>+
>+template <typename V>
>+ void
>+ test()
>+ {
>+ using T = typename V::value_type;
>+ V a{[](auto i) -> T { return i & 1u; }};
>+ V b{[](auto i) -> T { return (i + 1u) & 1u; }};
>+ COMPARE(min(a, b), V{0});
>+ COMPARE(max(a, b), V{1});
>+ }
>diff --git a/libstdc++-v3/testsuite/experimental/simd/tests/bits/conversions.h b/libstdc++-v3/testsuite/experimental/simd/tests/bits/conversions.h
>new file mode 100644
>index 00000000000..601b783cec6
>--- /dev/null
>+++ b/libstdc++-v3/testsuite/experimental/simd/tests/bits/conversions.h
>@@ -0,0 +1,167 @@
>+#include <array>
>+
>+// is_conversion_undefined
>+/* implementation-defined
>+ * ======================
>+ * §4.7 p3 (integral conversions)
These section signs will cause errors if the testsuite is run with
something like -finput-charset=ascii, but I suppose we can say "don't
do that". We have tests that use that option and include all the
libstdc++ headers, so there should be no need to run the entire
testsuite with that option. So it's OK.
Apart from the -static question, this looks fine. The custom test
harness is unconventional, but I think it's the right solution here
given that it would be impolite to enable all these tests for the
default "make check" target, and the overhead of having DejaGnu skip
them by default is unacceptable.
Thanks for finding a way to add the tests without slowing down
everybody's testers.
next prev parent reply other threads:[~2020-12-17 13:10 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-12-16 11:58 Matthias Kretz
2020-12-17 13:10 ` Jonathan Wakely [this message]
2020-12-18 15:25 ` Matthias Kretz
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=20201217131051.GX2309743@redhat.com \
--to=jwakely@redhat.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=libstdc++@gcc.gnu.org \
--cc=m.kretz@gsi.de \
/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).