Remove smips/host-debugging cruft
[riscv-tests.git] / benchmarks / mt-vvadd / mt-vvadd.c
1 // See LICENSE for license details.
2
3 //**************************************************************************
4 // Vector-vector add benchmark
5 //--------------------------------------------------------------------------
6 // Author : Andrew Waterman
7 // TA : Christopher Celio
8 // Student :
9 //
10 // This benchmark adds two vectors and writes the results to a
11 // third vector. The input data (and reference data) should be
12 // generated using the vvadd_gendata.pl perl script and dumped
13 // to a file named dataset.h
14
15 //--------------------------------------------------------------------------
16 // Includes
17
18 #include <string.h>
19 #include <stdlib.h>
20 #include <stdio.h>
21
22
23 //--------------------------------------------------------------------------
24 // Input/Reference Data
25
26 #include "dataset.h"
27
28
29 //--------------------------------------------------------------------------
30 // Basic Utilities and Multi-thread Support
31
32 #include "util.h"
33
34
35 //--------------------------------------------------------------------------
36 // vvadd function
37
38 extern void __attribute__((noinline)) vvadd(int coreid, int ncores, size_t n, const data_t* x, const data_t* y, data_t* z);
39
40
41 //--------------------------------------------------------------------------
42 // Main
43 //
44 // all threads start executing thread_entry(). Use their "coreid" to
45 // differentiate between threads (each thread is running on a separate core).
46
47 void thread_entry(int cid, int nc)
48 {
49 // static allocates data in the binary, which is visible to both threads
50 static data_t results_data[DATA_SIZE];
51
52 // First do out-of-place vvadd
53 barrier(nc);
54 stats(vvadd(cid, nc, DATA_SIZE, input1_data, input2_data, results_data); barrier(nc), DATA_SIZE);
55
56 if(cid == 0) {
57 int res = verifyDouble(DATA_SIZE, results_data, verify_data);
58 if(res) exit(res);
59 }
60
61 // Second do in-place vvadd
62 // Copying input
63 size_t i;
64 if(cid == 0) {
65 for (i = 0; i < DATA_SIZE; i++)
66 results_data[i] = input1_data[i];
67 }
68 barrier(nc);
69 stats(vvadd(cid, nc, DATA_SIZE, results_data, input2_data, results_data); barrier(nc), DATA_SIZE);
70
71 if(cid == 0) {
72 int res = verifyDouble(DATA_SIZE, results_data, verify_data);
73 if(res) exit(res);
74 }
75
76 barrier(nc);
77 exit(0);
78 }