[FFmpeg-devel] [PATCH 3/8] avutil: detect when AVX-512 is available

James Darnley jdarnley at obe.tv
Mon Oct 30 15:08:30 EET 2017


---
 libavutil/x86/cpu.c | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/libavutil/x86/cpu.c b/libavutil/x86/cpu.c
index f33088c8c7..b22a950b79 100644
--- a/libavutil/x86/cpu.c
+++ b/libavutil/x86/cpu.c
@@ -143,6 +143,7 @@ int ff_get_cpu_flags_x86(void)
 #endif /* HAVE_SSE */
     }
     if (max_std_level >= 7) {
+        int xcr0_lo = 0, xcr0_hi = 0;
         cpuid(7, eax, ebx, ecx, edx);
 #if HAVE_AVX2
         if ((rval & AV_CPU_FLAG_AVX) && (ebx & 0x00000020))
@@ -154,6 +155,14 @@ int ff_get_cpu_flags_x86(void)
             if (ebx & 0x00000100)
                 rval |= AV_CPU_FLAG_BMI2;
         }
+#if HAVE_AVX512 /* F, CD, BW, DQ, VL */
+        xgetbv(0, xcr0_lo, xcr0_hi);
+        if ((xcr0_lo & 0xe6) == 0xe6) {
+            if ((ebx & 0xd0030000) == 0xd0030000)
+                rval |= AV_CPU_FLAG_AVX512;
+
+        }
+#endif
     }
 
     cpuid(0x80000000, max_ext_level, ebx, ecx, edx);
-- 
2.14.2



More information about the ffmpeg-devel mailing list