From: Steven Walters Date: Thu, 3 Mar 2011 01:39:25 +0000 (-0500) Subject: Patch Intel's CPU dispatcher X-Git-Url: http://www.zmx.ovh/git.videolan.org/?a=commitdiff_plain;h=9b7b3c7e238e3cac383dd7d2863b7c3c0f718422;p=x264.git Patch Intel's CPU dispatcher Reduces Intel Compiler's bias against non-Intel CPUs. Big thanks to Agner for the original information on how to do this. --- diff --git a/common/osdep.c b/common/osdep.c index fc035915..e44d26cc 100644 --- a/common/osdep.c +++ b/common/osdep.c @@ -89,3 +89,35 @@ int x264_threading_init( void ) return 0; } #endif + +#ifdef __INTEL_COMPILER +/* Agner's patch to Intel's CPU dispatcher from pages 131-132 of + * http://agner.org/optimize/optimizing_cpp.pdf (2011-01-30) + * adapted to x264's cpu schema. */ + +// Global variable indicating cpu +int __intel_cpu_indicator = 0; +// CPU dispatcher function +void __intel_cpu_indicator_init( void ) +{ + unsigned int cpu = x264_cpu_detect(); + if( cpu&X264_CPU_AVX ) + __intel_cpu_indicator = 0x20000; + else if( cpu&X264_CPU_SSE42 ) + __intel_cpu_indicator = 0x8000; + else if( cpu&X264_CPU_SSE4 ) + __intel_cpu_indicator = 0x2000; + else if( cpu&X264_CPU_SSSE3 ) + __intel_cpu_indicator = 0x1000; + else if( cpu&X264_CPU_SSE3 ) + __intel_cpu_indicator = 0x800; + else if( cpu&X264_CPU_SSE2 && !(cpu&X264_CPU_SSE2_IS_SLOW) ) + __intel_cpu_indicator = 0x200; + else if( cpu&X264_CPU_SSE ) + __intel_cpu_indicator = 0x80; + else if( cpu&X264_CPU_MMXEXT ) + __intel_cpu_indicator = 8; + else + __intel_cpu_indicator = 1; +} +#endif