diff options
author | Andrew Waterman <waterman@cs.berkeley.edu> | 2014-12-12 18:17:31 -0800 |
---|---|---|
committer | Andrew Waterman <waterman@cs.berkeley.edu> | 2014-12-12 18:17:31 -0800 |
commit | 984abbe6e67503c93dbb13d9a305960f11c4ba7b (patch) | |
tree | f5e5ad55b5e39b1a960d689b93ad3fda35b75283 /benchmarks | |
parent | 1d8e02859be502647b52a71623f543712c869b2f (diff) | |
download | riscv-tests-984abbe6e67503c93dbb13d9a305960f11c4ba7b.zip riscv-tests-984abbe6e67503c93dbb13d9a305960f11c4ba7b.tar.gz riscv-tests-984abbe6e67503c93dbb13d9a305960f11c4ba7b.tar.bz2 |
Add more entropy to matrix multiplication input
This will exercise the floating-point units more thoroughly.
Diffstat (limited to 'benchmarks')
-rw-r--r-- | benchmarks/common/util.h | 8 | ||||
-rw-r--r-- | benchmarks/mm/mm_main.c | 12 |
2 files changed, 15 insertions, 5 deletions
diff --git a/benchmarks/common/util.h b/benchmarks/common/util.h index 638f024..24a1cad 100644 --- a/benchmarks/common/util.h +++ b/benchmarks/common/util.h @@ -31,6 +31,8 @@ static void setStats(int enable) {} extern void setStats(int enable); #endif +#include <stdint.h> + extern int have_vec; #define static_assert(cond) switch(0) { case 0: case !!(long)(cond): ; } @@ -109,6 +111,12 @@ static void __attribute__((noinline)) barrier(int ncores) __sync_synchronize(); } +static uint64_t lfsr(uint64_t x) +{ + uint64_t bit = (x ^ (x >> 1)) & 1; + return (x >> 1) | (bit << 62); +} + #ifdef __riscv #include "encoding.h" #endif diff --git a/benchmarks/mm/mm_main.c b/benchmarks/mm/mm_main.c index 3bbfdcf..e119235 100644 --- a/benchmarks/mm/mm_main.c +++ b/benchmarks/mm/mm_main.c @@ -8,6 +8,7 @@ void thread_entry(int cid, int nc) { const int R = 8; int m, n, p; + uint64_t s = 0xdeadbeefU; if (have_vec) { m = HCBM; @@ -25,10 +26,10 @@ void thread_entry(int cid, int nc) for (size_t i = 0; i < m; i++) for (size_t j = 0; j < p; j++) - a[i*p+j] = i+j; + a[i*p+j] = (t)(s = lfsr(s)); for (size_t i = 0; i < p; i++) for (size_t j = 0; j < n; j++) - b[i*n+j] = i-j; + b[i*n+j] = (t)(s = lfsr(s)); memset(c, 0, m*n*sizeof(c[0])); size_t instret, cycles; @@ -65,9 +66,10 @@ void thread_entry(int cid, int nc) for (size_t j = 0; j < n; j++) { t s = 0; - for (size_t aik = i, bkj = -j; aik < i+p; aik++, bkj++) - s += (t)aik*(t)bkj; - if (fabs(c[i*n+j]-s*R) > 1e-6*s) + for (size_t k = 0; k < p; k++) + s += a[i*p+k] * b[k*n+j]; + s *= R; + if (fabs(c[i*n+j]-s) > fabs(1e-6*s)) { printf("C%d: c[%lu][%lu] %f != %f\n", cid, i, j, c[i*n+j], s); exit(1); |