[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Are G3/ no altivec cpu still usable on Debian?



On Sun, Jun 4, 2023 at 11:10 PM Paul Wise <pabs@debian.org> wrote:
>
> On Sun, 2023-06-04 at 06:51 -0400, Jeffrey Walton wrote:
>
> > Altivec detection on Linux is relatively easy nowadays using
> > getauxval(). From
> ...
> > instead of using a query via getauxval(), OpenSSL does a runtime probe
> > by executing an Altivec instruction. If a SIGILL is encountered, then
> > Altivec is false.
>
> These are all obsoleted by GCC function multi-versioning where possible
> and a manual ifunc that uses the __builtin_cpu_supports builtin
> function where not possible.
>
> https://wiki.debian.org/InstructionSelection
>
> The comment about GCC support for PowerPC being spotty is probably
> incorrect, it would be great if that could be verified though.

Crypto++ and OpenSSL support back to GCC 3. Function multiversioning
and ifunc's are not available back that far.

For modern versions of GCC, GCC is still broken for C++ templates.
This does not work. It will not compile.

    __attribute__ ((target ("default")))
    template <class T>
    int foo ()
    {
      // The default version of foo.
      return ...;
    }

    __attribute__ ((target ("sse4.2")))
    template <class T>
    int foo ()
    {
      // foo version for SSE4.2
      return ...;
    }

    __attribute__ ((target ("avx2")))
    template <class T>
    int foo ()
    {
      // foo version for AVX2
      return ...;
    }

And there's no measurable difference in performance if you do this at
runtime versus ifunc's (and friends):

    bool has_altivec = DetectAltivec();
    if (has_altivec) {
        // SIMD impl using Altivec
    } else {
        // C/C++ impl
    }

Jeff


Reply to: