Add LICENSE
[riscv-tests.git] / benchmarks / vvadd / vvadd_main.c
1 // See LICENSE for license details.
2
3 //**************************************************************************
4 // Vector-vector add benchmark
5 //--------------------------------------------------------------------------
6 //
7 // This benchmark uses adds to vectors and writes the results to a
8 // third vector. The input data (and reference data) should be
9 // generated using the vvadd_gendata.pl perl script and dumped
10 // to a file named dataset1.h The smips-gcc toolchain does not
11 // support system calls so printf's can only be used on a host system,
12 // not on the smips processor simulator itself. You should not change
13 // anything except the HOST_DEBUG and PREALLOCATE macros for your timing
14 // runs.
15
16 #include "util.h"
17
18 //--------------------------------------------------------------------------
19 // Input/Reference Data
20
21 #include "dataset1.h"
22
23 //--------------------------------------------------------------------------
24 // vvadd function
25
26 void vvadd( int n, int a[], int b[], int c[] )
27 {
28 int i;
29 for ( i = 0; i < n; i++ )
30 c[i] = a[i] + b[i];
31 }
32
33 //--------------------------------------------------------------------------
34 // Main
35
36 int main( int argc, char* argv[] )
37 {
38 int results_data[DATA_SIZE];
39
40 // Output the input array
41 printArray( "input1", DATA_SIZE, input1_data );
42 printArray( "input2", DATA_SIZE, input2_data );
43 printArray( "verify", DATA_SIZE, verify_data );
44
45 #if PREALLOCATE
46 // If needed we preallocate everything in the caches
47 vvadd( DATA_SIZE, input1_data, input2_data, results_data );
48 #endif
49
50 // Do the vvadd
51 setStats(1);
52 vvadd( DATA_SIZE, input1_data, input2_data, results_data );
53 setStats(0);
54
55 // Print out the results
56 printArray( "results", DATA_SIZE, results_data );
57
58 // Check the results
59 return verify( DATA_SIZE, results_data, verify_data );
60 }