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.



Reply via email to