minor mt updates
[riscv-tests.git] / benchmarks / mt-matmul / mt-matmul.c
1 //**************************************************************************
2 // Multi-threaded Matrix Multiply benchmark
3 //--------------------------------------------------------------------------
4 // TA : Christopher Celio
5 // Student:
6 //
7 //
8 // This benchmark multiplies two 2-D arrays together and writes the results to
9 // a third vector. The input data (and reference data) should be generated
10 // using the matmul_gendata.pl perl script and dumped to a file named
11 // dataset.h.
12
13
14 // print out arrays, etc.
15 //#define DEBUG
16
17 //--------------------------------------------------------------------------
18 // Includes
19
20 #include <string.h>
21 #include <stdlib.h>
22 #include <stdio.h>
23
24
25 //--------------------------------------------------------------------------
26 // Input/Reference Data
27
28 #include "dataset.h"
29
30
31 //--------------------------------------------------------------------------
32 // Basic Utilities and Multi-thread Support
33
34 #include "util.h"
35
36
37 //--------------------------------------------------------------------------
38 // matmul function
39
40 extern void __attribute__((noinline)) matmul(const int coreid, const int ncores, const int lda, const data_t A[], const data_t B[], data_t C[] );
41
42
43 //--------------------------------------------------------------------------
44 // Main
45 //
46 // all threads start executing thread_entry(). Use their "coreid" to
47 // differentiate between threads (each thread is running on a separate core).
48
49 void thread_entry(int cid, int nc)
50 {
51 static data_t results_data[ARRAY_SIZE];
52
53 stats(matmul(cid, nc, DIM_SIZE, input1_data, input2_data, results_data); barrier(nc), DIM_SIZE/DIM_SIZE/DIM_SIZE);
54
55 int res = verifyDouble(ARRAY_SIZE, results_data, verify_data);
56
57 #ifdef DEBUG
58 printArray("results:", ARRAY_SIZE, results_data);
59 printArray("verify :", ARRAY_SIZE, verify_data);
60 #endif
61
62 exit(res);
63 }