1 //**************************************************************************
2 // Median filter bencmark
3 //--------------------------------------------------------------------------
5 // This benchmark performs a 1D three element median filter. The
6 // input data (and reference data) should be generated using the
7 // median_gendata.pl perl script and dumped to a file named
8 // dataset1.h You should not change anything except the
9 // HOST_DEBUG and PREALLOCATE macros for your timing run.
16 //--------------------------------------------------------------------------
19 // Set HOST_DEBUG to 1 if you are going to compile this for a host
20 // machine (ie Athena/Linux) for debug purposes and set HOST_DEBUG
21 // to 0 if you are compiling with the smips-gcc toolchain.
27 // Set PREALLOCATE to 1 if you want to preallocate the benchmark
28 // function before starting stats. If you have instruction/data
29 // caches and you don't want to count the overhead of misses, then
30 // you will need to use preallocation.
36 // Set SET_STATS to 1 if you want to carve out the piece that actually
37 // does the computation.
43 //--------------------------------------------------------------------------
44 // Input/Reference Data
48 //--------------------------------------------------------------------------
51 int verify( int n
, int test
[], int correct
[] )
54 for ( i
= 0; i
< n
; i
++ ) {
55 if ( test
[i
] != correct
[i
] ) {
63 void printArray( char name
[], int n
, int arr
[] )
66 printf( " %10s :", name
);
67 for ( i
= 0; i
< n
; i
++ )
68 printf( " %3d ", arr
[i
] );
73 void setStats( int enable
)
75 #if ( !HOST_DEBUG && SET_STATS )
76 asm( "mtpcr %0, cr10" : : "r" (enable
) );
80 //--------------------------------------------------------------------------
83 int main( int argc
, char* argv
[] )
85 int results_data
[DATA_SIZE
];
87 // Output the input array
90 printArray( "input", DATA_SIZE
, input_data
);
91 printArray( "verify", DATA_SIZE
, verify_data
);
94 // If needed we preallocate everything in the caches
96 #if ( !HOST_DEBUG && PREALLOCATE )
97 median( DATA_SIZE
, input_data
, results_data
);
103 median( DATA_SIZE
, input_data
, results_data
);
106 median( DATA_SIZE
, input_data
, results_data
);
110 // Print out the results
113 printArray( "results", DATA_SIZE
, results_data
);
118 finishTest(verify( DATA_SIZE
, results_data
, verify_data
));