[vlc-devel] commit: SSE3 detection (runtime) (Jean-Baptiste Kempf )

David Wolstencroft lordrpi at gmail.com
Wed Sep 23 02:23:42 CEST 2009


j-b,

Whether or not fork() is slow - it probably shouldn't matter since it should
only be called once to initialize the CPU capabilities, but can't you use
cpuid for this?
However, I'm not sure this line is correct:

+# if defined (__SSE3__)
+    i_capabilities |= CPU_CAPABILITY_SSE3;
__SSE3__ is defined with -msse3 is passed in to gcc whether or not the
processor supports it, therefore you should still do the same check.



On Tue, Sep 22, 2009 at 4:49 PM, git version control <git at videolan.org>wrote:

> vlc | branch: master | Jean-Baptiste Kempf <jb at videolan.org> | Tue Sep 22
> 19:34:00 2009 +0200| [ceb2efd46999603aa75a59201b4e869d9c36e458] | committer:
> Jean-Baptiste Kempf
>
> SSE3 detection (runtime)
>
> Isn't fork() supposed to be slow on Windows?
>
> >
> http://git.videolan.org/gitweb.cgi/vlc.git/?a=commit;h=ceb2efd46999603aa75a59201b4e869d9c36e458
> ---
>
>  src/libvlc-module.c |    8 ++++++++
>  src/libvlc.c        |    3 +++
>  src/misc/cpu.c      |   18 ++++++++++++++++++
>  3 files changed, 29 insertions(+), 0 deletions(-)
>
> diff --git a/src/libvlc-module.c b/src/libvlc-module.c
> index d92e614..18cefcd 100644
> --- a/src/libvlc-module.c
> +++ b/src/libvlc-module.c
> @@ -1009,6 +1009,12 @@ static const char *const ppsz_clock_descriptions[] =
>     "If your processor supports the SSE2 instructions set, VLC can take " \
>     "advantage of them.")
>
> +#define SSE3_TEXT N_("Enable CPU SSE3 support")
> +#define SSE3_LONGTEXT N_( \
> +    "If your processor supports the SSE3 instructions set, VLC can take "
> \
> +    "advantage of them.")
> +
> +
>  #define ALTIVEC_TEXT N_("Enable CPU AltiVec support")
>  #define ALTIVEC_LONGTEXT N_( \
>     "If your processor supports the AltiVec instructions set, VLC can take
> " \
> @@ -1927,6 +1933,8 @@ vlc_module_begin ()
>         change_need_restart ()
>     add_bool( "sse2", 1, NULL, SSE2_TEXT, SSE2_LONGTEXT, true )
>         change_need_restart ()
> +    add_bool( "sse3", 1, NULL, SSE3_TEXT, SSE3_LONGTEXT, true )
> +        change_need_restart ()
>  #endif
>  #if defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
>     add_bool( "altivec", 1, NULL, ALTIVEC_TEXT, ALTIVEC_LONGTEXT, true )
> diff --git a/src/libvlc.c b/src/libvlc.c
> index 97755fd..a1784b1 100644
> --- a/src/libvlc.c
> +++ b/src/libvlc.c
> @@ -761,12 +761,15 @@ int libvlc_InternalInit( libvlc_int_t *p_libvlc, int
> i_argc,
>         cpu_flags &= ~CPU_CAPABILITY_SSE;
>     if( !config_GetInt( p_libvlc, "sse2" ) )
>         cpu_flags &= ~CPU_CAPABILITY_SSE2;
> +    if( !config_GetInt( p_libvlc, "sse3" ) )
> +        cpu_flags &= ~CPU_CAPABILITY_SSE3;
>
>     PRINT_CAPABILITY( CPU_CAPABILITY_MMX, "MMX" );
>     PRINT_CAPABILITY( CPU_CAPABILITY_3DNOW, "3DNow!" );
>     PRINT_CAPABILITY( CPU_CAPABILITY_MMXEXT, "MMXEXT" );
>     PRINT_CAPABILITY( CPU_CAPABILITY_SSE, "SSE" );
>     PRINT_CAPABILITY( CPU_CAPABILITY_SSE2, "SSE2" );
> +    PRINT_CAPABILITY( CPU_CAPABILITY_SSE3, "SSE3" );
>
>  #elif defined( __powerpc__ ) || defined( __ppc__ ) || defined( __ppc64__ )
>     if( !config_GetInt( p_libvlc, "altivec" ) )
> diff --git a/src/misc/cpu.c b/src/misc/cpu.c
> index 615484c..9ca2ab8 100644
> --- a/src/misc/cpu.c
> +++ b/src/misc/cpu.c
> @@ -201,6 +201,24 @@ uint32_t CPUCapabilities( void )
>     }
>  # endif
>
> +# if defined (__SSE3__)
> +    i_capabilities |= CPU_CAPABILITY_SSE3;
> +# elif defined (CAN_COMPILE_SSE3)
> +    if( i_ecx & 0x00000001 )
> +    {
> +        /* We test if OS supports the SSE3 instructions */
> +        pid_t pid = fork();
> +        if( pid == 0 )
> +        {
> +            /* Test a SSE3 instruction */
> +            __asm__ __volatile__ ( "movsldup %%xmm1, %%xmm0\n" : : );
> +            exit(0);
> +        }
> +        if( check_OS_capability( "SSE3", pid ) )
> +            i_capabilities |= CPU_CAPABILITY_SSE3;
> +    }
> +# endif
> +
>     /* test for additional capabilities */
>     cpuid( 0x80000000 );
>
>
> _______________________________________________
> vlc-devel mailing list
> To unsubscribe or modify your subscription options:
> http://mailman.videolan.org/listinfo/vlc-devel
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/vlc-devel/attachments/20090922/b30dc7c1/attachment.html>


More information about the vlc-devel mailing list