public inbox for libstdc++@gcc.gnu.org
 help / color / mirror / Atom feed
From: Matthias Kretz <m.kretz@gsi.de>
To: <gcc-patches@gcc.gnu.org>
Cc: <libstdc++@gcc.gnu.org>,
	Segher Boessenkool <segher@kernel.crashing.org>,
	 David Edelsohn <dje.gcc@gmail.com>,
	Alexandre Oliva <oliva@adacore.com>
Subject: Re: [PATCH] libstdc++: ppc: conditionalize vsx-only simd intrinsics
Date: Thu, 28 Apr 2022 15:56:18 +0200	[thread overview]
Message-ID: <15649943.RDIVbhacDa@minbar> (raw)
In-Reply-To: <oree1h91sd.fsf@lxoliva.fsfla.org>

On Thursday, 28 April 2022 08:09:54 CEST Alexandre Oliva via Gcc-patches 
wrote:
> libstdc++'s bits/simd.h section for PPC (Altivec) defines various
> intrinsic vector types that are only available along with VSX: 64-bit
> long double, double, (un)signed long long, and 64-bit (un)signed long.

Oh, so uttering `__vector double` is ill-formed (now) without VSX? I'm fairly 
certain I tested without VSX and the __intrinsic_type_impl definitions were 
fine.

> experimental/simd/standard_abi_usable{,_2}.cc tests error out reporting
> the unmet requirements when the target cpu doesn't enable VSX.  Make the
> reported instrinsic types conditional on VSX so that <experimental/simd>
> can be used on ppc variants that do not have VSX support.

IIRC this will break other valid uses. You'd have to run `make check-simd` 
(see libstdc++-v3/testsuite/experimental/simd/README.md) to be certain nothing 
breaks. I will also take a look.

> Regstrapped on powerpc64el-linux-gnu.  Ok to install?
> 
> This is also relevant for gcc-11.  Tested with
> x86_64-linux-gnu-x-ppc64-vx7r2.  Ok for gcc-11?
> 
> 
> for  libstdc++-v3/ChangeLog
> 
> 	* include/experimental/bits/simd.h [__ALTIVEC__]: Require VSX
> 	for double, long long, and 64-bit long and 64-bit long double
> 	intrinsic types.
> ---
>  libstdc++-v3/include/experimental/bits/simd.h |   11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
> 
> diff --git a/libstdc++-v3/include/experimental/bits/simd.h
> b/libstdc++-v3/include/experimental/bits/simd.h index
> 82e9841195e1d..66c07127ec435 100644
> --- a/libstdc++-v3/include/experimental/bits/simd.h
> +++ b/libstdc++-v3/include/experimental/bits/simd.h
> @@ -2430,17 +2430,23 @@ template <typename _Tp>
>    template <>                                                              
>    \ struct __intrinsic_type_impl<_Tp> { using type = __vector _Tp; }
> _GLIBCXX_SIMD_PPC_INTRIN(float);
> +# ifdef __VSX__
>  _GLIBCXX_SIMD_PPC_INTRIN(double);
> +# endif
>  _GLIBCXX_SIMD_PPC_INTRIN(signed char);
>  _GLIBCXX_SIMD_PPC_INTRIN(unsigned char);
>  _GLIBCXX_SIMD_PPC_INTRIN(signed short);
>  _GLIBCXX_SIMD_PPC_INTRIN(unsigned short);
>  _GLIBCXX_SIMD_PPC_INTRIN(signed int);
>  _GLIBCXX_SIMD_PPC_INTRIN(unsigned int);
> +# if defined __VSX__ || __LONG_WIDTH__ == 32
>  _GLIBCXX_SIMD_PPC_INTRIN(signed long);
>  _GLIBCXX_SIMD_PPC_INTRIN(unsigned long);
> +# endif
> +# ifdef __VSX__
>  _GLIBCXX_SIMD_PPC_INTRIN(signed long long);
>  _GLIBCXX_SIMD_PPC_INTRIN(unsigned long long);
> +# endif
>  #undef _GLIBCXX_SIMD_PPC_INTRIN
> 
>  template <typename _Tp, size_t _Bytes>
> @@ -2452,8 +2458,9 @@ template <typename _Tp, size_t _Bytes>
>      static_assert(!(_S_is_ldouble && sizeof(long double) > sizeof(double)),
> "no __intrinsic_type support for long double on PPC");
>  #ifndef __VSX__
> -    static_assert(!is_same_v<_Tp, double>,
> -		  "no __intrinsic_type support for double on PPC w/o VSX");
> +    static_assert(!(is_same_v<_Tp, double>
> +		    || (_S_is_ldouble && sizeof(long double) == 
sizeof(double))),
> +		  "no __intrinsic_type support for [long] double on PPC w/o 
VSX");

The missing condition here was an incorrect omission. With -mlong-double-64 
and without VSX no assertion caught the issue.

IIRC, a user won't get to see this error message unless there's a bug in the 
simd library implementation, so the error message is good enough for me. (It's 
talking about __intrinsic_type, the user would be lost in any case.)

>  #endif
>      using type =
>        typename __intrinsic_type_impl<


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




  parent reply	other threads:[~2022-04-28 13:56 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-04-28  6:09 Alexandre Oliva
2022-04-28 13:03 ` Segher Boessenkool
2022-04-29  1:53   ` Alexandre Oliva
2022-04-29 18:44     ` Matthias Kretz
2022-05-02 21:36     ` Segher Boessenkool
2022-05-03  2:00       ` [PATCH v2] " Alexandre Oliva
2022-05-06 16:14         ` Segher Boessenkool
2022-05-06 17:05           ` Jonathan Wakely
2022-05-06 18:24             ` [PATCH v3] " Alexandre Oliva
2022-04-28 13:56 ` Matthias Kretz [this message]
2022-04-28 16:06   ` [PATCH] " Segher Boessenkool

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=15649943.RDIVbhacDa@minbar \
    --to=m.kretz@gsi.de \
    --cc=dje.gcc@gmail.com \
    --cc=gcc-patches@gcc.gnu.org \
    --cc=libstdc++@gcc.gnu.org \
    --cc=oliva@adacore.com \
    --cc=segher@kernel.crashing.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).