0be305159eb456fd0cbaf4aac94c06c2bb169f4e
1 //**************************************************************************
2 // Vector-vector add benchmark
3 //--------------------------------------------------------------------------
5 // This benchmark uses adds to vectors and writes the results to a
6 // third vector. The input data (and reference data) should be
7 // generated using the vvadd_gendata.pl perl script and dumped
8 // to a file named dataset1.h The smips-gcc toolchain does not
9 // support system calls so printf's can only be used on a host system,
10 // not on the smips processor simulator itself. You should not change
11 // anything except the HOST_DEBUG and PREALLOCATE macros for your timing
17 //--------------------------------------------------------------------------
20 // Set HOST_DEBUG to 1 if you are going to compile this for a host
21 // machine (ie Athena/Linux) for debug purposes and set HOST_DEBUG
22 // to 0 if you are compiling with the smips-gcc toolchain.
28 // Set PREALLOCATE to 1 if you want to preallocate the benchmark
29 // function before starting stats. If you have instruction/data
30 // caches and you don't want to count the overhead of misses, then
31 // you will need to use preallocation.
37 // Set SET_STATS to 1 if you want to carve out the piece that actually
38 // does the computation.
44 //--------------------------------------------------------------------------
45 // Input/Reference Data
49 //--------------------------------------------------------------------------
52 int verify( int n
, int test
[], int correct
[] )
55 for ( i
= 0; i
< n
; i
++ ) {
56 if ( test
[i
] != correct
[i
] ) {
64 void printArray( char name
[], int n
, int arr
[] )
67 printf( " %10s :", name
);
68 for ( i
= 0; i
< n
; i
++ )
69 printf( " %3d ", arr
[i
] );
74 //void finishTest( int toHostValue )
77 // if ( toHostValue == 1 )
78 // printf( "*** PASSED ***\n" );
80 // printf( "*** FAILED *** (tohost = %d)\n", toHostValue );
83 // asm( "mtpcr %0, tohost" : : "r" (toHostValue) );
88 void setStats( int enable
)
90 #if ( !HOST_DEBUG && SET_STATS )
91 asm( "mtpcr %0, cr10" : : "r" (enable
) );
95 //--------------------------------------------------------------------------
98 void vvadd( int n
, int a
[], int b
[], int c
[] )
101 for ( i
= 0; i
< n
; i
++ )
105 //--------------------------------------------------------------------------
108 int main( int argc
, char* argv
[] )
110 int results_data
[DATA_SIZE
];
112 // Output the input array
115 printArray( "input1", DATA_SIZE
, input1_data
);
116 printArray( "input2", DATA_SIZE
, input2_data
);
117 printArray( "verify", DATA_SIZE
, verify_data
);
120 // If needed we preallocate everything in the caches
123 vvadd( DATA_SIZE
, input1_data
, input2_data
, results_data
);
129 vvadd( DATA_SIZE
, input1_data
, input2_data
, results_data
);
132 // Print out the results
135 printArray( "results", DATA_SIZE
, results_data
);
140 finishTest(verify( DATA_SIZE
, results_data
, verify_data
));