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