00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef AVCODEC_PPC_DSPUTIL_PPC_H
00022 #define AVCODEC_PPC_DSPUTIL_PPC_H
00023
00024 #include "config.h"
00025
00026 #if CONFIG_POWERPC_PERF
00027 void powerpc_display_perf_report(void);
00028
00029
00030
00031
00032 #define POWERPC_NUM_PMC_ENABLED 6
00033
00034
00035 enum powerpc_perf_index {
00036 altivec_fft_num = 0,
00037 altivec_gmc1_num,
00038 altivec_dct_unquantize_h263_num,
00039 altivec_fdct,
00040 altivec_idct_add_num,
00041 altivec_idct_put_num,
00042 altivec_put_pixels16_num,
00043 altivec_avg_pixels16_num,
00044 altivec_avg_pixels8_num,
00045 altivec_put_pixels8_xy2_num,
00046 altivec_put_no_rnd_pixels8_xy2_num,
00047 altivec_put_pixels16_xy2_num,
00048 altivec_put_no_rnd_pixels16_xy2_num,
00049 altivec_hadamard8_diff8x8_num,
00050 altivec_hadamard8_diff16_num,
00051 altivec_avg_pixels8_xy2_num,
00052 powerpc_clear_blocks_dcbz32,
00053 powerpc_clear_blocks_dcbz128,
00054 altivec_put_h264_chroma_mc8_num,
00055 altivec_avg_h264_chroma_mc8_num,
00056 altivec_put_h264_qpel16_h_lowpass_num,
00057 altivec_avg_h264_qpel16_h_lowpass_num,
00058 altivec_put_h264_qpel16_v_lowpass_num,
00059 altivec_avg_h264_qpel16_v_lowpass_num,
00060 altivec_put_h264_qpel16_hv_lowpass_num,
00061 altivec_avg_h264_qpel16_hv_lowpass_num,
00062 powerpc_perf_total
00063 };
00064 enum powerpc_data_index {
00065 powerpc_data_min = 0,
00066 powerpc_data_max,
00067 powerpc_data_sum,
00068 powerpc_data_num,
00069 powerpc_data_total
00070 };
00071 extern unsigned long long perfdata[POWERPC_NUM_PMC_ENABLED][powerpc_perf_total][powerpc_data_total];
00072
00073 #if !HAVE_PPC64
00074 #define POWERP_PMC_DATATYPE unsigned long
00075 #define POWERPC_GET_PMC1(a) __asm__ volatile("mfspr %0, 937" : "=r" (a))
00076 #define POWERPC_GET_PMC2(a) __asm__ volatile("mfspr %0, 938" : "=r" (a))
00077 #if (POWERPC_NUM_PMC_ENABLED > 2)
00078 #define POWERPC_GET_PMC3(a) __asm__ volatile("mfspr %0, 941" : "=r" (a))
00079 #define POWERPC_GET_PMC4(a) __asm__ volatile("mfspr %0, 942" : "=r" (a))
00080 #else
00081 #define POWERPC_GET_PMC3(a) do {} while (0)
00082 #define POWERPC_GET_PMC4(a) do {} while (0)
00083 #endif
00084 #if (POWERPC_NUM_PMC_ENABLED > 4)
00085 #define POWERPC_GET_PMC5(a) __asm__ volatile("mfspr %0, 929" : "=r" (a))
00086 #define POWERPC_GET_PMC6(a) __asm__ volatile("mfspr %0, 930" : "=r" (a))
00087 #else
00088 #define POWERPC_GET_PMC5(a) do {} while (0)
00089 #define POWERPC_GET_PMC6(a) do {} while (0)
00090 #endif
00091 #else
00092 #define POWERP_PMC_DATATYPE unsigned long long
00093 #define POWERPC_GET_PMC1(a) __asm__ volatile("mfspr %0, 771" : "=r" (a))
00094 #define POWERPC_GET_PMC2(a) __asm__ volatile("mfspr %0, 772" : "=r" (a))
00095 #if (POWERPC_NUM_PMC_ENABLED > 2)
00096 #define POWERPC_GET_PMC3(a) __asm__ volatile("mfspr %0, 773" : "=r" (a))
00097 #define POWERPC_GET_PMC4(a) __asm__ volatile("mfspr %0, 774" : "=r" (a))
00098 #else
00099 #define POWERPC_GET_PMC3(a) do {} while (0)
00100 #define POWERPC_GET_PMC4(a) do {} while (0)
00101 #endif
00102 #if (POWERPC_NUM_PMC_ENABLED > 4)
00103 #define POWERPC_GET_PMC5(a) __asm__ volatile("mfspr %0, 775" : "=r" (a))
00104 #define POWERPC_GET_PMC6(a) __asm__ volatile("mfspr %0, 776" : "=r" (a))
00105 #else
00106 #define POWERPC_GET_PMC5(a) do {} while (0)
00107 #define POWERPC_GET_PMC6(a) do {} while (0)
00108 #endif
00109 #endif
00110 #define POWERPC_PERF_DECLARE(a, cond) \
00111 POWERP_PMC_DATATYPE \
00112 pmc_start[POWERPC_NUM_PMC_ENABLED], \
00113 pmc_stop[POWERPC_NUM_PMC_ENABLED], \
00114 pmc_loop_index;
00115 #define POWERPC_PERF_START_COUNT(a, cond) do { \
00116 POWERPC_GET_PMC6(pmc_start[5]); \
00117 POWERPC_GET_PMC5(pmc_start[4]); \
00118 POWERPC_GET_PMC4(pmc_start[3]); \
00119 POWERPC_GET_PMC3(pmc_start[2]); \
00120 POWERPC_GET_PMC2(pmc_start[1]); \
00121 POWERPC_GET_PMC1(pmc_start[0]); \
00122 } while (0)
00123 #define POWERPC_PERF_STOP_COUNT(a, cond) do { \
00124 POWERPC_GET_PMC1(pmc_stop[0]); \
00125 POWERPC_GET_PMC2(pmc_stop[1]); \
00126 POWERPC_GET_PMC3(pmc_stop[2]); \
00127 POWERPC_GET_PMC4(pmc_stop[3]); \
00128 POWERPC_GET_PMC5(pmc_stop[4]); \
00129 POWERPC_GET_PMC6(pmc_stop[5]); \
00130 if (cond) { \
00131 for(pmc_loop_index = 0; \
00132 pmc_loop_index < POWERPC_NUM_PMC_ENABLED; \
00133 pmc_loop_index++) { \
00134 if (pmc_stop[pmc_loop_index] >= pmc_start[pmc_loop_index]) { \
00135 POWERP_PMC_DATATYPE diff = \
00136 pmc_stop[pmc_loop_index] - pmc_start[pmc_loop_index]; \
00137 if (diff < perfdata[pmc_loop_index][a][powerpc_data_min]) \
00138 perfdata[pmc_loop_index][a][powerpc_data_min] = diff; \
00139 if (diff > perfdata[pmc_loop_index][a][powerpc_data_max]) \
00140 perfdata[pmc_loop_index][a][powerpc_data_max] = diff; \
00141 perfdata[pmc_loop_index][a][powerpc_data_sum] += diff; \
00142 perfdata[pmc_loop_index][a][powerpc_data_num] ++; \
00143 } \
00144 } \
00145 } \
00146 } while (0)
00147 #else
00148
00149 #define POWERPC_PERF_DECLARE(a, cond) int altivec_placeholder __attribute__ ((unused))
00150 #define POWERPC_PERF_START_COUNT(a, cond) do {} while (0)
00151 #define POWERPC_PERF_STOP_COUNT(a, cond) do {} while (0)
00152 #endif
00153
00154 #endif