Clean up benchmarks; support uarch-specific counters
[riscv-tests.git] / benchmarks / median / median_main.c
1 //**************************************************************************
2 // Median filter bencmark
3 //--------------------------------------------------------------------------
4 //
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.
10
11 #include "util.h"
12
13 #include "median.h"
14
15 //--------------------------------------------------------------------------
16 // Input/Reference Data
17
18 #include "dataset1.h"
19
20 //--------------------------------------------------------------------------
21 // Main
22
23 int main( int argc, char* argv[] )
24 {
25 int results_data[DATA_SIZE];
26
27 // Output the input array
28 printArray( "input", DATA_SIZE, input_data );
29 printArray( "verify", DATA_SIZE, verify_data );
30
31 #if PREALLOCATE
32 // If needed we preallocate everything in the caches
33 median( DATA_SIZE, input_data, results_data );
34 #endif
35
36 // Do the filter
37 setStats(1);
38 median( DATA_SIZE, input_data, results_data );
39 setStats(0);
40
41 // Print out the results
42 printArray( "results", DATA_SIZE, results_data );
43
44 // Check the results
45 return verify( DATA_SIZE, results_data, verify_data );
46 }