diff mbox series

libstdc++: Fix test on x86_64 and non-simd targets

Message ID 14856544.O9o76ZdvQC@vir-laptop
State New
Headers show
Series libstdc++: Fix test on x86_64 and non-simd targets | expand

Commit Message

Matthias Kretz June 21, 2024, 3:07 p.m. UTC
* Running a test compiled with AVX512 instructions requires
avx512f_runtime not just avx512f.

* The 'reduce2' test violated an invariant of fixed_size_simd_mask and
thus failed on all targets without 16-Byte vector builtins enabled (in
bits/simd.h).

Signed-off-by: Matthias Kretz <m.kretz@gsi.de>

libstdc++-v3/ChangeLog:

	PR libstdc++/115575
	* testsuite/experimental/simd/pr115454_find_last_set.cc: Require
	avx512f_runtime. Don't memcpy fixed_size masks.
---
 .../testsuite/experimental/simd/pr115454_find_last_set.cc   | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)


--
──────────────────────────────────────────────────────────────────────────
 Dr. Matthias Kretz                           https://mattkretz.github.io
 GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
 stdₓ::simd
──────────────────────────────────────────────────────────────────────────

Comments

Jonathan Wakely June 21, 2024, 3:54 p.m. UTC | #1
On Fri, 21 Jun 2024 at 16:07, Matthias Kretz <m.kretz@gsi.de> wrote:
>
>
> * Running a test compiled with AVX512 instructions requires
> avx512f_runtime not just avx512f.
>
> * The 'reduce2' test violated an invariant of fixed_size_simd_mask and
> thus failed on all targets without 16-Byte vector builtins enabled (in
> bits/simd.h).

OK, thanks for the quick diagnosis and fix.


>
> Signed-off-by: Matthias Kretz <m.kretz@gsi.de>
>
> libstdc++-v3/ChangeLog:
>
>         PR libstdc++/115575
>         * testsuite/experimental/simd/pr115454_find_last_set.cc: Require
>         avx512f_runtime. Don't memcpy fixed_size masks.
> ---
>  .../testsuite/experimental/simd/pr115454_find_last_set.cc   | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
>
> --
> ──────────────────────────────────────────────────────────────────────────
>  Dr. Matthias Kretz                           https://mattkretz.github.io
>  GSI Helmholtz Centre for Heavy Ion Research               https://gsi.de
>  stdₓ::simd
> ──────────────────────────────────────────────────────────────────────────
diff mbox series

Patch

diff --git a/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc b/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
index b47f19d3067..25a713b4e94 100644
--- a/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
+++ b/libstdc++-v3/testsuite/experimental/simd/pr115454_find_last_set.cc
@@ -1,7 +1,7 @@ 
 // { dg-options "-std=gnu++17" }
 // { dg-do run { target *-*-* } }
 // { dg-require-effective-target c++17 }
-// { dg-additional-options "-march=x86-64-v4" { target avx512f } }
+// { dg-additional-options "-march=x86-64-v4" { target avx512f_runtime } }
 // { dg-require-cmath "" }
 
 #include <experimental/simd>
@@ -25,7 +25,9 @@  namespace stdx
 {
   using M8 = typename V<short, 8>::mask_type;
   using M4 = typename V<int, 4>::mask_type;
-  if constexpr (sizeof(M8) == sizeof(M4))
+  if constexpr (sizeof(M8) == sizeof(M4)
+		  && !std::is_same_v<M4, stdx::fixed_size_simd_mask<int, 4>>)
+    // fixed_size invariant: padding bits of masks are zero, the memcpy would violate that
     {
       M4 k;
       __builtin_memcpy(&__data(k), &__data(M8(true)), sizeof(M4));