vlc | branch: master | Jean-Baptiste Kempf <[email protected]> | Fri Dec 9 16:23:28 2011 +0100| [09215763d3fa819c516fb88419f01f37e58c7383] | committer: Jean-Baptiste Kempf
Detect AVX-enabled processors > http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=09215763d3fa819c516fb88419f01f37e58c7383 --- configure.ac | 22 ++++++++++++++++++++++ include/vlc_cpu.h | 11 +++++++++++ src/misc/cpu.c | 15 +++++++++++++++ 3 files changed, 48 insertions(+), 0 deletions(-) diff --git a/configure.ac b/configure.ac index d0538e2..869b9d2 100644 --- a/configure.ac +++ b/configure.ac @@ -1336,6 +1336,28 @@ AS_IF([test "${ac_cv_3dnow_inline}" != "no"], [ ]) AM_CONDITIONAL([HAVE_3DNOW], [test "$have_3dnow" = "yes"]) +VLC_SAVE_FLAGS +CFLAGS="${CFLAGS} -mavx" +have_avx="no" +AC_CACHE_CHECK([if $CC groks AVX inline assembly], [ac_cv_avx_inline], [ + AC_COMPILE_IFELSE([AC_LANG_PROGRAM(,[[ +void *p; +asm volatile("vzeroall"::"r"(p)); +]]) + ], [ + ac_cv_avx_inline=yes + ], [ + ac_cv_avx_inline=no + ]) +]) +VLC_RESTORE_FLAGS +AS_IF([test "${ac_cv_avx_inline}" != "no"], [ + AC_DEFINE(CAN_COMPILE_AVX, 1, + [Define to 1 if AVX inline assembly is available.]) + have_3dnow="yes" +]) +AM_CONDITIONAL([HAVE_AVX], [test "$have_3dnow" = "yes"]) + AC_ARG_ENABLE(neon, [AS_HELP_STRING([--disable-neon], diff --git a/include/vlc_cpu.h b/include/vlc_cpu.h index 63cc978..a4dc66b 100644 --- a/include/vlc_cpu.h +++ b/include/vlc_cpu.h @@ -37,6 +37,7 @@ # define CPU_CAPABILITY_SSE4_1 (1<<10) # define CPU_CAPABILITY_SSE4_2 (1<<11) # define CPU_CAPABILITY_SSE4A (1<<12) +# define CPU_CAPABILITY_AVX (1<<13) # if defined (__MMX__) # define VLC_MMX @@ -54,6 +55,15 @@ # define VLC_SSE VLC_SSE_is_not_implemented_on_this_compiler # endif +# if defined (__AVX__) +# define VLC_AVX +# elif VLC_GCC_VERSION(4, 6) +# define VLC_AVX __attribute__ ((__target__ ("avx"))) +# else +# define VLC_AVX VLC_AVX_is_not_implemented_on_this_compiler +# endif + + # else # define CPU_CAPABILITY_MMX (0) # define CPU_CAPABILITY_3DNOW (0) @@ -65,6 +75,7 @@ # define CPU_CAPABILITY_SSE4_1 (0) # define CPU_CAPABILITY_SSE4_2 (0) # define CPU_CAPABILITY_SSE4A (0) +# define CPU_CAPABILITY_AVX (0) # endif # if defined (__ppc__) || defined (__ppc64__) || defined (__powerpc__) diff --git a/src/misc/cpu.c b/src/misc/cpu.c index 7c28b25..97826a9 100644 --- a/src/misc/cpu.c +++ b/src/misc/cpu.c @@ -125,6 +125,13 @@ VLC_MMX static void ThreeD_Now_test (void) asm volatile ("pfadd %%mm0,%%mm0\n" "femms\n" : : : "mm0"); } #endif +#if defined (CAN_COMPILE_AVX) && !defined (__AVX__) +VLC_AVX static void AVX_test (void) +{ + asm volatile ("vzeroall\n" ); +} +#endif + #if defined (CAN_COMPILE_ALTIVEC) static void Altivec_text (void) @@ -262,6 +269,13 @@ void vlc_CPU_init (void) i_capabilities |= CPU_CAPABILITY_SSE4_2; # endif +# if defined (__AVX__) + i_capabilities |= CPU_CAPABILITY_AVX; +# elif defined (CAN_COMPILE_AVX) + if ((i_ecx & (1 << 28)) && vlc_CPU_check ("AVX", AVX_test)) + i_capabilities |= CPU_CAPABILITY_AVX; +# endif + /* test for additional capabilities */ cpuid( 0x80000000 ); @@ -384,6 +398,7 @@ void vlc_CPU_dump (vlc_object_t *obj) PRINT_CAPABILITY(CPU_CAPABILITY_SSE4_1, "SSE4.1"); PRINT_CAPABILITY(CPU_CAPABILITY_SSE4_2, "SSE4.2"); PRINT_CAPABILITY(CPU_CAPABILITY_SSE4A, "SSE4A"); + PRINT_CAPABILITY(CPU_CAPABILITY_AVX, "AVX"); #elif defined (__powerpc__) || defined (__ppc__) || defined (__ppc64__) PRINT_CAPABILITY(CPU_CAPABILITY_ALTIVEC, "AltiVec"); _______________________________________________ vlc-commits mailing list [email protected] http://mailman.videolan.org/listinfo/vlc-commits
