summaryrefslogtreecommitdiff
path: root/vpx_ports
diff options
context:
space:
mode:
authorBirk Magnussen <birk.magnussen@googlemail.com>2019-10-17 00:11:26 +0200
committerBirk Magnussen <birk.magnussen@googlemail.com>2019-10-17 13:16:54 +0200
commit602d25ec4344f96031ce1043c15490e79438c1bc (patch)
tree33ea45e4fcf9f671f7ce86b574a110ed6f394e0d /vpx_ports
parent2be0ee5f05b3dc0782626b8b10894d5d920bcb96 (diff)
downloadlibvpx-602d25ec4344f96031ce1043c15490e79438c1bc.tar
libvpx-602d25ec4344f96031ce1043c15490e79438c1bc.tar.gz
libvpx-602d25ec4344f96031ce1043c15490e79438c1bc.tar.bz2
libvpx-602d25ec4344f96031ce1043c15490e79438c1bc.zip
Fix AVX-512 capability detection
When Checking for AVX Support, only the CPU's Capabilities and YMM Register support by the OS were queried. In case of AVX-512, that is insufficient, and ZMM Register support by the OS needs querying, otherwise the OS will raise an Illegal Operation Exception if the CPU is capable of AVX-512 but the OS is not. Change-Id: I3444b19156d5743841de96cecbdaac19cc3f2b3f
Diffstat (limited to 'vpx_ports')
-rw-r--r--vpx_ports/x86.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/vpx_ports/x86.h b/vpx_ports/x86.h
index 970ac2518..ed26b1671 100644
--- a/vpx_ports/x86.h
+++ b/vpx_ports/x86.h
@@ -202,6 +202,7 @@ static INLINE int x86_simd_caps(void) {
// bits 27 (OSXSAVE) & 28 (256-bit AVX)
if ((reg_ecx & (BIT(27) | BIT(28))) == (BIT(27) | BIT(28))) {
+ // Check for OS-support of YMM state. Necessary for AVX and AVX2.
if ((xgetbv() & 0x6) == 0x6) {
flags |= HAS_AVX;
@@ -214,8 +215,10 @@ static INLINE int x86_simd_caps(void) {
// bits 16 (AVX-512F) & 17 (AVX-512DQ) & 28 (AVX-512CD) &
// 30 (AVX-512BW) & 32 (AVX-512VL)
if ((reg_ebx & (BIT(16) | BIT(17) | BIT(28) | BIT(30) | BIT(31))) ==
- (BIT(16) | BIT(17) | BIT(28) | BIT(30) | BIT(31)))
- flags |= HAS_AVX512;
+ (BIT(16) | BIT(17) | BIT(28) | BIT(30) | BIT(31))) {
+ // Check for OS-support of ZMM and YMM state. Necessary for AVX-512.
+ if ((xgetbv() & 0xe6) == 0xe6) flags |= HAS_AVX512;
+ }
}
}
}