54c960236d542f26fd9dfbbf88f9baa35379ad9c
1 // See LICENSE for license details.
3 //**************************************************************************
4 // Vector-vector add benchmark
5 //--------------------------------------------------------------------------
6 // Author : Andrew Waterman
7 // TA : Christopher Celio
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
15 //--------------------------------------------------------------------------
23 //--------------------------------------------------------------------------
24 // Input/Reference Data
29 //--------------------------------------------------------------------------
30 // Basic Utilities and Multi-thread Support
35 //--------------------------------------------------------------------------
38 extern void __attribute__((noinline
)) vvadd(int coreid
, int ncores
, size_t n
, const data_t
* x
, const data_t
* y
, data_t
* z
);
41 //--------------------------------------------------------------------------
44 // all threads start executing thread_entry(). Use their "coreid" to
45 // differentiate between threads (each thread is running on a separate core).
47 void thread_entry(int cid
, int nc
)
49 // static allocates data in the binary, which is visible to both threads
50 static data_t results_data
[DATA_SIZE
];
52 // First do out-of-place vvadd
54 stats(vvadd(cid
, nc
, DATA_SIZE
, input1_data
, input2_data
, results_data
); barrier(nc
), DATA_SIZE
);
57 int res
= verifyDouble(DATA_SIZE
, results_data
, verify_data
);
61 // Second do in-place vvadd
65 for (i
= 0; i
< DATA_SIZE
; i
++)
66 results_data
[i
] = input1_data
[i
];
69 stats(vvadd(cid
, nc
, DATA_SIZE
, results_data
, input2_data
, results_data
); barrier(nc
), DATA_SIZE
);
72 int res
= verifyDouble(DATA_SIZE
, results_data
, verify_data
);