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 // to print out arrays, etc.
18 //--------------------------------------------------------------------------
26 //--------------------------------------------------------------------------
27 // Input/Reference Data
32 //--------------------------------------------------------------------------
33 // Basic Utilities and Multi-thread Support
38 //--------------------------------------------------------------------------
41 extern void __attribute__((noinline
)) vvadd(int coreid
, int ncores
, size_t n
, const data_t
* x
, const data_t
* y
, data_t
* z
);
44 //--------------------------------------------------------------------------
47 // all threads start executing thread_entry(). Use their "coreid" to
48 // differentiate between threads (each thread is running on a separate core).
50 void thread_entry(int cid
, int nc
)
52 // static allocates data in the binary, which is visible to both threads
53 static data_t results_data
[DATA_SIZE
];
55 // First do out-of-place vvadd
57 stats(vvadd(cid
, nc
, DATA_SIZE
, input1_data
, input2_data
, results_data
); barrier(nc
), DATA_SIZE
);
61 printDoubleArray("out-of-place results: ", DATA_SIZE
, results_data
);
62 printDoubleArray("out-of-place verify : ", DATA_SIZE
, verify_data
);
64 int res
= verifyDouble(DATA_SIZE
, results_data
, verify_data
);
68 // Second do in-place vvadd
72 for (i
= 0; i
< DATA_SIZE
; i
++)
73 results_data
[i
] = input1_data
[i
];
76 stats(vvadd(cid
, nc
, DATA_SIZE
, results_data
, input2_data
, results_data
); barrier(nc
), DATA_SIZE
);
80 printDoubleArray("in-place results: ", DATA_SIZE
, results_data
);
81 printDoubleArray("in-place verify : ", DATA_SIZE
, verify_data
);
83 int res
= verifyDouble(DATA_SIZE
, results_data
, verify_data
);