Add Power ISA SIMD detection to mozglue
Categories
(Core :: mozglue, enhancement)
Tracking
()
Tracking | Status | |
---|---|---|
firefox70 | --- | fixed |
People
(Reporter: spectre, Assigned: spectre)
References
Details
Attachments
(1 file, 5 obsolete files)
It's Time To Make AltiVec Great Again
This adds VMX, VSX and VSX-3 detection to mozglue. Unfortunately, while the altivec
string in /proc/cpuinfo
is invariant for VMX, VSX is not yet exposed there, so we check for processor strings a la MIPS for the time being.
Prerequisite for some other work I will be prepping to land.
Assignee | ||
Comment 1•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Wouldn't it be better to base the flags on getauxval(AT_HWCAP{,2})
output rather than to parse /proc/cpuinfo
?
Assignee | ||
Comment 3•5 years ago
|
||
I guess I could have an XP_LINUX
check in there for that, and then fall back to /proc/cpuinfo
if not available so that it would still build on a non-Linux (i.e., BSD, etc.) OS.
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 4•5 years ago
|
||
I think we can rely on <sys/auxv.h> also for the CPU feature flags (defined in <bits/hwcap.h>). ARCH_3_00 is available since glibc 2.23 (released 2016-02-19), so I've rather added a check for it, but maybe it's old enough.
Assignee | ||
Comment 6•5 years ago
|
||
I'm fine with your concept if you want to submit that instead.
Updated•5 years ago
|
Assignee | ||
Comment 7•5 years ago
|
||
Dan, are you submitting it, or am I? I want to try to get some other stuff in but I need this first.
Assignee | ||
Comment 8•5 years ago
|
||
Dan and I discussed in E-mail and I will submit in the interests of time since it's blocking other work.
Assignee | ||
Comment 9•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Updated•5 years ago
|
Comment 10•5 years ago
|
||
/proc/cpuinfo
doesn't expose powerpc* features on FreeBSD and NetBSD while OpenBSD removed /proc
filesystem entirely. FreeBSD 12+ has a function similar to getauxval()
. After this patch bug 817042 can be retired. Can you integrate it into the review on phabricator?
Also, /proc
fallback should probably be replaced with compile-time detection based on -maltivec
(aka __ALTIVEC__
), -msvx
(aka __VSX__
), -mpower9-vector
(aka __POWER9_VECTOR__
) flags.
https://github.com/llvm/llvm-project/blob/llvmorg-8.0.1/clang/lib/Basic/Targets/PPC.cpp#L160-L175
Comment 11•5 years ago
|
||
Landry, does OpenBSD support detecting VSX and/or VSX3 at runtime?
Martin, does NetBSD support detecting VSX and/or VSX3 at runtime?
Assignee | ||
Comment 12•5 years ago
|
||
I don't have a way of testing on the *BSDs (for that matter, I'm not aware that anything but FreeBSD supports POWER8+). This is blocking additional work and I'd prefer someone who can test it do that in a followup. I need this to land any of the Altivec stuff I'm working on; I can't land it until the build support is in.
As far as compile vs runtime, the "Mozilla way" seems to be runtime detection, not compile-time detection, or at least that's what everything else in mozglue/build
is doing. For little vs big endian PPC in future patches, that will be compile-time, since that distinction is already compile-time in Firefox. I'll defer to :glandium if that is no longer the case.
Comment 14•5 years ago
•
|
||
(In reply to Cameron Kaiser [:spectre] from comment #12)
I'd prefer someone who can test it do that in a followup.
I can't test as part of Firefox (doesn't build, anyway) but FreeBSD bits extracted into standalone sample worked fine on ref12-ppc64.freebsd.org. NetBSD bits were tested on x86_64 after replacing CPU_ALTIVEC
with HW_NCPU
(can't use powerpc* macro on non-powerpc*). OpenBSD has similar code in devel/sdl package.
In other words, if you want the perfect testing then it won't happen for years. During that time living with broken /proc
fallback doesn't seem desirable.
the "Mozilla way" seems to be runtime detection, not compile-time detection
x86_32 and x86_64 translate __MMX__
, __SSE__
, __AVX__
, etc. into MOZILLA_PRESUME_*
which is later used to skip runtime checks e.g.,
https://searchfox.org/mozilla-central/rev/30b01f4f60db/mozglue/build/SSE.cpp#186-188
Assignee | ||
Comment 15•5 years ago
|
||
I'm deferring to :glandium for what he wants to do. Notice that bug 817042 never did get landed and I don't want to boil the ocean in this bug or we're never going to get support in for any OS.
Comment 16•5 years ago
|
||
I'm with Cameron in this, runtime detection is preferred in general on Power. So lets start with this and improve it incrementally. Also the x86 world is much more complex in the various SIMD acceleration features than the 3 flags for all Power/ppc cpus.
Comment 17•5 years ago
|
||
(In reply to Jan Beich from comment #11)
NetBSD does not currently support any of the CPUs providing this.
When this changes, it will be visible as sysctl (like currently machdep.altivec is for older CPUs)
Assignee | ||
Comment 18•5 years ago
|
||
:glandium, are you okay for reviewing this, or would someone else be better?
Updated•5 years ago
|
Assignee | ||
Comment 19•5 years ago
|
||
Updated•5 years ago
|
Comment 21•5 years ago
|
||
Pushed by ccoroiu@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/252643ff91c5
basic support for Power ISA SIMD detection (v2). r=glandium
Comment 22•5 years ago
|
||
bugherder |
Description
•