Discussion:
Are G3/ no altivec cpu still usable on Debian?
(too old to reply)
Lorenzo
2023-06-03 09:50:01 UTC
Permalink
[ please keep me in CC, I'm not subscribed ]

Hello powerpc porters,

There is a bug in mplayer [1] that could be fixed by building a variant
of mplayer without altivec, however I can't tell if such bug can
still be triggered nowadays. The ppc port is gone right? Are cpus without
altivec still usable on one of Debian's powerpc ports?

Regards,
Lorenzo

[1] https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=410962
John Paul Adrian Glaubitz
2023-06-03 10:20:01 UTC
Permalink
Hello!
Post by Lorenzo
There is a bug in mplayer [1] that could be fixed by building a variant
of mplayer without altivec, however I can't tell if such bug can
still be triggered nowadays. The ppc port is gone right? Are cpus without
altivec still usable on one of Debian's powerpc ports?
https://cdimage.debian.org/cdimage/ports/snapshots/2023-05-28/debian-12.0.0-powerpc-NETINST-1.iso
As for Altivec support in mplayer: Have you tried the latest version? It
might be possible there is proper runtime detection these days.

Adrian
--
.''`. John Paul Adrian Glaubitz
: :' : Debian Developer
`. `' Physicist
`- GPG: 62FF 8A75 84E0 2956 9546 0006 7426 3B37 F5B5 F913
Lorenzo
2023-06-04 10:20:01 UTC
Permalink
On Sat, 03 Jun 2023 12:14:47 +0200
Post by John Paul Adrian Glaubitz
Hello!
Post by Lorenzo
There is a bug in mplayer [1] that could be fixed by building a
variant of mplayer without altivec, however I can't tell if such
bug can still be triggered nowadays. The ppc port is gone right?
Are cpus without altivec still usable on one of Debian's powerpc
ports?
https://cdimage.debian.org/cdimage/ports/snapshots/2023-05-28/debian-12.0.0-powerpc-NETINST-1.iso
As for Altivec support in mplayer: Have you tried the latest version?
It might be possible there is proper runtime detection these days.
According to mplayer upstream [1] "AltiVec runtime detection never
worked reliably" and "the way it was detected in libavcodec was an
unacceptable hack".. that was in back in 2007, I'll check if upstream
still consider runtime detection unfeasible.

Thanks for your help,
Lorenzo
Post by John Paul Adrian Glaubitz
Adrian
[1]https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=448105
Jeffrey Walton
2023-06-04 11:00:02 UTC
Permalink
Post by Lorenzo
On Sat, 03 Jun 2023 12:14:47 +0200
Post by John Paul Adrian Glaubitz
Hello!
Post by Lorenzo
There is a bug in mplayer [1] that could be fixed by building a
variant of mplayer without altivec, however I can't tell if such
bug can still be triggered nowadays. The ppc port is gone right?
Are cpus without altivec still usable on one of Debian's powerpc
ports?
https://cdimage.debian.org/cdimage/ports/snapshots/2023-05-28/debian-12.0.0-powerpc-NETINST-1.iso
As for Altivec support in mplayer: Have you tried the latest version?
It might be possible there is proper runtime detection these days.
According to mplayer upstream [1] "AltiVec runtime detection never
worked reliably" and "the way it was detected in libavcodec was an
unacceptable hack".. that was in back in 2007, I'll check if upstream
still consider runtime detection unfeasible.
[...]
[1]https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=448105
Altivec detection on Linux is relatively easy nowadays using
getauxval(). From
https://github.com/weidai11/cryptopp/blob/master/cpu.cpp#L1210 :

inline bool CPU_QueryAltivec()
{
#if defined(__linux__) && defined(PPC_FEATURE_HAS_ALTIVEC)
if ((getauxval(AT_HWCAP) & PPC_FEATURE_HAS_ALTIVEC) != 0)
return true;
#elif defined(_AIX)
if (__power_6_andup() != 0)
return true;
#elif ...
#endif
return false;
}

Botan uses similar runtime detection via getauxval() at
https://github.com/randombit/botan/blob/master/src/lib/utils/cpuid/cpuid_ppc.cpp.

OpenSSL performs runtime probes in
https://github.com/openssl/openssl/blob/master/crypto/ppccap.c. But
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.

The tricky machines are Apple running MacOS 9 and OS X. You have to be
careful of runtime probes and SIGILLs. On Apple machines, memory
corruption happens with runtime CPU probes.

Jeff
Paul Wise
2023-06-05 03:20:01 UTC
Permalink
Post by Jeffrey Walton
Altivec detection on Linux is relatively easy nowadays using
getauxval(). From
...
Post by Jeffrey Walton
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.
--
bye,
pabs

https://wiki.debian.org/PaulWise
Jeffrey Walton
2023-06-05 05:30:01 UTC
Permalink
Post by Paul Wise
Post by Jeffrey Walton
Altivec detection on Linux is relatively easy nowadays using
getauxval(). From
...
Post by Jeffrey Walton
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

Paul Wise
2023-06-05 03:10:02 UTC
Permalink
Post by Lorenzo
According to mplayer upstream [1] "AltiVec runtime detection never
worked reliably" and "the way it was detected in libavcodec was an
unacceptable hack".. that was in back in 2007, I'll check if upstream
still consider runtime detection unfeasible.
Runtime instruction selection has gotten a lot easier since then,
please take a look at the Debian documentation for this:

https://wiki.debian.org/InstructionSelection
--
bye,
pabs

https://wiki.debian.org/PaulWise
Loading...