diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2003-06-29 00:39:57 +0000 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2003-06-29 00:39:57 +0000 |
commit | a4adb60858f1fa0b35b08576ea34e531f0f83459 (patch) | |
tree | 95fd262e09e47e01dc4ccfc549a258a2c10e2d8f /libavcodec/ppc | |
parent | 2c094d6338c50a24d1b5df037a07040b59d4d60f (diff) | |
download | ffmpeg-a4adb60858f1fa0b35b08576ea34e531f0f83459.tar.gz |
PPC970 patch + cpu-specific tuning support by (Romain Dolbeau <dolbeau at irisa dot fr>)
Originally committed as revision 1997 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec/ppc')
-rw-r--r-- | libavcodec/ppc/dsputil_ppc.c | 71 | ||||
-rw-r--r-- | libavcodec/ppc/dsputil_ppc.h | 1 | ||||
-rw-r--r-- | libavcodec/ppc/gcc_fixes.h | 8 |
3 files changed, 73 insertions, 7 deletions
diff --git a/libavcodec/ppc/dsputil_ppc.c b/libavcodec/ppc/dsputil_ppc.c index 374309e378..8a5de9d74f 100644 --- a/libavcodec/ppc/dsputil_ppc.c +++ b/libavcodec/ppc/dsputil_ppc.c @@ -57,7 +57,8 @@ static unsigned char* perfname[] = { "put_no_rnd_pixels8_xy2_altivec", "put_pixels16_xy2_altivec", "put_no_rnd_pixels16_xy2_altivec", - "clear_blocks_dcbz32_ppc" + "clear_blocks_dcbz32_ppc", + "clear_blocks_dcbz128_ppc" }; #ifdef POWERPC_PERF_USE_PMC unsigned long long perfdata_miss[powerpc_perf_total][powerpc_data_total]; @@ -110,6 +111,18 @@ void powerpc_display_perf_report(void) It simply clear to zero a single cache line, so you need to know the cache line size to use it ! It's absurd, but it's fast... + + update 24/06/2003 : Apple released yesterday the G5, + with a PPC970. cache line size : 128 bytes. Oups. + The semantic of dcbz was changed, it always clear + 32 bytes. so the function below will work, but will + be slow. So I fixed check_dcbz_effect to use dcbzl, + which is defined to clear a cache line (as dcbz before). + So we still can distinguish, and use dcbz (32 bytes) + or dcbzl (one cache line) as required. + + see <http://developer.apple.com/technotes/tn/tn2087.html> + and <http://developer.apple.com/technotes/tn/tn2086.html> */ void clear_blocks_dcbz32_ppc(DCTELEM *blocks) { @@ -126,7 +139,7 @@ POWERPC_TBL_START_COUNT(powerpc_clear_blocks_dcbz32, 1); i += 16; } for ( ; i < sizeof(DCTELEM)*6*64 ; i += 32) { - asm volatile("dcbz %0,%1" : : "r" (blocks), "r" (i) : "memory"); + asm volatile("dcbz %0,%1" : : "r" (i), "r" (blocks) : "memory"); } if (misal) { ((unsigned long*)blocks)[188] = 0L; @@ -141,8 +154,45 @@ POWERPC_TBL_START_COUNT(powerpc_clear_blocks_dcbz32, 1); POWERPC_TBL_STOP_COUNT(powerpc_clear_blocks_dcbz32, 1); } +/* same as above, when dcbzl clear a whole 128B cache line + i.e. the PPC970 aka G5 */ +#ifndef NO_DCBZL +void clear_blocks_dcbz128_ppc(DCTELEM *blocks) +{ +POWERPC_TBL_DECLARE(powerpc_clear_blocks_dcbz128, 1); + register int misal = ((unsigned long)blocks & 0x0000007f); + register int i = 0; +POWERPC_TBL_START_COUNT(powerpc_clear_blocks_dcbz128, 1); +#if 1 + if (misal) { + // we could probably also optimize this case, + // but there's not much point as the machines + // aren't available yet (2003-06-26) + memset(blocks, 0, sizeof(DCTELEM)*6*64); + } + else + for ( ; i < sizeof(DCTELEM)*6*64 ; i += 128) { + asm volatile("dcbzl %0,%1" : : "r" (i), "r" (blocks) : "memory"); + } +#else + memset(blocks, 0, sizeof(DCTELEM)*6*64); +#endif +POWERPC_TBL_STOP_COUNT(powerpc_clear_blocks_dcbz128, 1); +} +#else +void clear_blocks_dcbz128_ppc(DCTELEM *blocks) +{ + memset(blocks, 0, sizeof(DCTELEM)*6*64); +} +#endif + +#ifndef NO_DCBZL /* check dcbz report how many bytes are set to 0 by dcbz */ -long check_dcbz_effect(void) +/* update 24/06/2003 : replace dcbz by dcbzl to get + the intended effect (Apple "fixed" dcbz) + unfortunately this cannot be used unless the assembler + knows about dcbzl ... */ +long check_dcbzl_effect(void) { register char *fakedata = (char*)av_malloc(1024); register char *fakedata_middle; @@ -159,7 +209,7 @@ long check_dcbz_effect(void) memset(fakedata, 0xFF, 1024); - asm volatile("dcbz %0, %1" : : "r" (fakedata_middle), "r" (zero)); + asm volatile("dcbzl %0, %1" : : "r" (fakedata_middle), "r" (zero)); for (i = 0; i < 1024 ; i ++) { @@ -171,15 +221,24 @@ long check_dcbz_effect(void) return count; } +#else +long check_dcbzl_effect(void) +{ + return 0; +} +#endif void dsputil_init_ppc(DSPContext* c, AVCodecContext *avctx) { - // Common optimisations whether Altivec or not + // Common optimizations whether Altivec is available or not - switch (check_dcbz_effect()) { + switch (check_dcbzl_effect()) { case 32: c->clear_blocks = clear_blocks_dcbz32_ppc; break; + case 128: + c->clear_blocks = clear_blocks_dcbz128_ppc; + break; default: break; } diff --git a/libavcodec/ppc/dsputil_ppc.h b/libavcodec/ppc/dsputil_ppc.h index ef1481a999..0e619ee17a 100644 --- a/libavcodec/ppc/dsputil_ppc.h +++ b/libavcodec/ppc/dsputil_ppc.h @@ -37,6 +37,7 @@ enum powerpc_perf_index { altivec_put_pixels16_xy2_num, altivec_put_no_rnd_pixels16_xy2_num, powerpc_clear_blocks_dcbz32, + powerpc_clear_blocks_dcbz128, powerpc_perf_total }; enum powerpc_data_index { diff --git a/libavcodec/ppc/gcc_fixes.h b/libavcodec/ppc/gcc_fixes.h index 855a5b4f7b..653378d5bc 100644 --- a/libavcodec/ppc/gcc_fixes.h +++ b/libavcodec/ppc/gcc_fixes.h @@ -13,9 +13,15 @@ #ifdef CONFIG_DARWIN #define AVV(x...) (x) +/* The Apple assembler shipped w/ gcc-3.3 knows about DCBZL, previous assemblers don't + We assume here that the Darwin GCC is from Apple.... */ +#if (__GNUC__ * 100 + __GNUC_MINOR__ < 303) +#define NO_DCBZL +#endif #else #define AVV(x...) {x} - +/* I don't think any non-Apple assembler knows about DCBZL */ +#define NO_DCBZL #if (__GNUC__ * 100 + __GNUC_MINOR__ < 303) /* This code was provided to me by Bartosch Pixa |