Mercurial > libavcodec.hg
comparison ppc/dsputil_ppc.h @ 1015:35cf2f4a0f8c libavcodec
PPC perf, PPC clear_block, AltiVec put_pixels8_xy2 patch by (Romain Dolbeau <dolbeau at irisa dot fr>)
author | michaelni |
---|---|
date | Sun, 19 Jan 2003 19:00:45 +0000 |
parents | |
children | 9cc1031e1864 |
comparison
equal
deleted
inserted
replaced
1014:48349e11c9b2 | 1015:35cf2f4a0f8c |
---|---|
1 /* | |
2 * Copyright (c) 2003 Romain Dolbeau <romain@dolbeau.org> | |
3 * | |
4 * This library is free software; you can redistribute it and/or | |
5 * modify it under the terms of the GNU Lesser General Public | |
6 * License as published by the Free Software Foundation; either | |
7 * version 2 of the License, or (at your option) any later version. | |
8 * | |
9 * This library is distributed in the hope that it will be useful, | |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
12 * Lesser General Public License for more details. | |
13 * | |
14 * You should have received a copy of the GNU Lesser General Public | |
15 * License along with this library; if not, write to the Free Software | |
16 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA | |
17 */ | |
18 | |
19 #ifndef _DSPUTIL_PPC_ | |
20 #define _DSPUTIL_PPC_ | |
21 | |
22 #ifdef POWERPC_TBL_PERFORMANCE_REPORT | |
23 void powerpc_display_perf_report(void); | |
24 /* if you add to the enum below, also add to the perfname array | |
25 in dsputil_ppc.c */ | |
26 enum powerpc_perf_index { | |
27 altivec_fft_num = 0, | |
28 altivec_gmc1_num, | |
29 altivec_dct_unquantize_h263_num, | |
30 altivec_idct_add_num, | |
31 altivec_idct_put_num, | |
32 altivec_put_pixels_clamped_num, | |
33 altivec_put_pixels16_num, | |
34 altivec_avg_pixels16_num, | |
35 altivec_avg_pixels8_num, | |
36 altivec_put_pixels8_xy2_num, | |
37 powerpc_clear_blocks_dcbz32, | |
38 powerpc_perf_total | |
39 }; | |
40 enum powerpc_data_index { | |
41 powerpc_data_min = 0, | |
42 powerpc_data_max, | |
43 powerpc_data_sum, | |
44 powerpc_data_num, | |
45 powerpc_data_total | |
46 }; | |
47 extern unsigned long long perfdata[powerpc_perf_total][powerpc_data_total]; | |
48 #ifdef POWERPC_PERF_USE_PMC | |
49 extern unsigned long long perfdata_miss[powerpc_perf_total][powerpc_data_total]; | |
50 #endif | |
51 | |
52 #ifndef POWERPC_PERF_USE_PMC | |
53 #define POWERPC_GET_CYCLES(a) asm volatile("mftb %0" : "=r" (a)) | |
54 #define POWERPC_TBL_DECLARE(a, cond) register unsigned long tbl_start, tbl_stop | |
55 #define POWERPC_TBL_START_COUNT(a, cond) do { POWERPC_GET_CYCLES(tbl_start); } while (0) | |
56 #define POWERPC_TBL_STOP_COUNT(a, cond) do { \ | |
57 POWERPC_GET_CYCLES(tbl_stop); \ | |
58 if (tbl_stop > tbl_start) \ | |
59 { \ | |
60 unsigned long diff = tbl_stop - tbl_start; \ | |
61 if (cond) \ | |
62 { \ | |
63 if (diff < perfdata[a][powerpc_data_min]) \ | |
64 perfdata[a][powerpc_data_min] = diff; \ | |
65 if (diff > perfdata[a][powerpc_data_max]) \ | |
66 perfdata[a][powerpc_data_max] = diff; \ | |
67 perfdata[a][powerpc_data_sum] += diff; \ | |
68 perfdata[a][powerpc_data_num] ++; \ | |
69 } \ | |
70 } \ | |
71 } while (0) | |
72 | |
73 #else /* POWERPC_PERF_USE_PMC */ | |
74 #define POWERPC_GET_CYCLES(a) asm volatile("mfspr %0, 937" : "=r" (a)) | |
75 #define POWERPC_GET_MISS(a) asm volatile("mfspr %0, 938" : "=r" (a)) | |
76 #define POWERPC_TBL_DECLARE(a, cond) register unsigned long cycles_start, cycles_stop, miss_start, miss_stop; | |
77 #define POWERPC_TBL_START_COUNT(a, cond) do { POWERPC_GET_MISS(miss_start); POWERPC_GET_CYCLES(cycles_start); } while (0) | |
78 #define POWERPC_TBL_STOP_COUNT(a, cond) do { \ | |
79 POWERPC_GET_CYCLES(cycles_stop); \ | |
80 POWERPC_GET_MISS(miss_stop); \ | |
81 if (cycles_stop >= cycles_start) \ | |
82 { \ | |
83 unsigned long diff = \ | |
84 cycles_stop - cycles_start; \ | |
85 if (cond) \ | |
86 { \ | |
87 if (diff < perfdata[a][powerpc_data_min]) \ | |
88 perfdata[a][powerpc_data_min] = diff; \ | |
89 if (diff > perfdata[a][powerpc_data_max]) \ | |
90 perfdata[a][powerpc_data_max] = diff; \ | |
91 perfdata[a][powerpc_data_sum] += diff; \ | |
92 perfdata[a][powerpc_data_num] ++; \ | |
93 } \ | |
94 } \ | |
95 if (miss_stop >= miss_start) \ | |
96 { \ | |
97 unsigned long diff = \ | |
98 miss_stop - miss_start; \ | |
99 if (cond) \ | |
100 { \ | |
101 if (diff < perfdata_miss[a][powerpc_data_min]) \ | |
102 perfdata_miss[a][powerpc_data_min] = diff; \ | |
103 if (diff > perfdata_miss[a][powerpc_data_max]) \ | |
104 perfdata_miss[a][powerpc_data_max] = diff; \ | |
105 perfdata_miss[a][powerpc_data_sum] += diff; \ | |
106 perfdata_miss[a][powerpc_data_num] ++; \ | |
107 } \ | |
108 } \ | |
109 } while (0) | |
110 | |
111 #endif /* POWERPC_PERF_USE_PMC */ | |
112 | |
113 | |
114 #else /* POWERPC_TBL_PERFORMANCE_REPORT */ | |
115 #define POWERPC_TBL_DECLARE(a, cond) | |
116 #define POWERPC_TBL_START_COUNT(a, cond) | |
117 #define POWERPC_TBL_STOP_COUNT(a, cond) | |
118 #endif /* POWERPC_TBL_PERFORMANCE_REPORT */ | |
119 | |
120 #endif /* _DSPUTIL_PPC_ */ |