From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id 8E23C385EC56 for ; Thu, 17 Dec 2020 13:10:58 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.3.2 sourceware.org 8E23C385EC56 Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-399-u4b8MwvvM2OkAVi3YCjLTw-1; Thu, 17 Dec 2020 08:10:54 -0500 X-MC-Unique: u4b8MwvvM2OkAVi3YCjLTw-1 Received: from smtp.corp.redhat.com (int-mx01.intmail.prod.int.phx2.redhat.com [10.5.11.11]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 15241809DCD; Thu, 17 Dec 2020 13:10:53 +0000 (UTC) Received: from localhost (unknown [10.33.36.115]) by smtp.corp.redhat.com (Postfix) with ESMTP id A80EF1981C; Thu, 17 Dec 2020 13:10:52 +0000 (UTC) Date: Thu, 17 Dec 2020 13:10:51 +0000 From: Jonathan Wakely To: Matthias Kretz Cc: gcc-patches@gcc.gnu.org, libstdc++@gcc.gnu.org Subject: Re: [PATCH] Add simd testsuite Message-ID: <20201217131051.GX2309743@redhat.com> References: <8364569.lWL0Ik8vYZ@excalibur> MIME-Version: 1.0 In-Reply-To: <8364569.lWL0Ik8vYZ@excalibur> X-Clacks-Overhead: GNU Terry Pratchett X-Scanned-By: MIMEDefang 2.79 on 10.5.11.11 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=iso-8859-1; format=flowed Content-Disposition: inline Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-13.9 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H3, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=unavailable autolearn_force=no version=3.4.2 X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on server2.sourceware.org X-BeenThere: libstdc++@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libstdc++ mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 17 Dec 2020 13:10:59 -0000 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 >+# 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 // abs & sqrt >+#include // integer abs >+#include "bits/test_values.h" >+ >+template >+ void >+ test() >+ { >+ if constexpr (std::is_signed_v) >+ { >+ using std::abs; >+ using T = typename V::value_type; >+ test_values({std::__finite_max_v, std::__norm_min_v, >+ -std::__norm_min_v, std::__finite_min_v, >+ std::__finite_min_v / 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 >+ 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 >+ >+// 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.