aboutsummaryrefslogtreecommitdiffstats
path: root/test/monniaux
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-01-18 12:57:55 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-01-18 12:57:55 +0100
commit3685268c6334f68001b2454fc3fa294d8b7a0688 (patch)
tree0efe448199f077bf4c84e13463cacfe25b5e62b2 /test/monniaux
parent6d9954bf61b0e709ae93e7e7212c8090fc07dc56 (diff)
downloadcompcert-kvx-3685268c6334f68001b2454fc3fa294d8b7a0688.tar.gz
compcert-kvx-3685268c6334f68001b2454fc3fa294d8b7a0688.zip
fourth version
Diffstat (limited to 'test/monniaux')
-rw-r--r--test/monniaux/int_mat.c22
-rw-r--r--test/monniaux/int_mat_run.c13
-rw-r--r--test/monniaux/modint.h5
3 files changed, 38 insertions, 2 deletions
diff --git a/test/monniaux/int_mat.c b/test/monniaux/int_mat.c
index a750937d..cc8c59e5 100644
--- a/test/monniaux/int_mat.c
+++ b/test/monniaux/int_mat.c
@@ -58,6 +58,28 @@ void modint_mat_mul3(unsigned m, unsigned n, unsigned p,
}
}
+void modint_mat_mul4(unsigned m, unsigned n, unsigned p,
+ modint * c, unsigned stride_c,
+ const modint *a, unsigned stride_a,
+ const modint *b, unsigned stride_b) {
+ const modint *pa_i = a;
+ modint * pc_i = c;
+ for(unsigned i=0; i<m; i++) {
+ for(unsigned k=0; k<p; k++) {
+ const modint *pb_j_k = b+k, *pa_i_j = pa_i;
+ modint total = 0;
+ for(unsigned j=0; j<n; j++) {
+ total += *pa_i_j * *pb_j_k;
+ pa_i_j ++;
+ pb_j_k += stride_b;
+ }
+ pc_i[k] = total % MODULUS;
+ }
+ pa_i += stride_a;
+ pc_i += stride_c;
+ }
+}
+
modint modint_random(void) {
static uint64_t next = 1325997111;
next = next * 1103515245 + 12345;
diff --git a/test/monniaux/int_mat_run.c b/test/monniaux/int_mat_run.c
index b8d836af..3fc4b64e 100644
--- a/test/monniaux/int_mat_run.c
+++ b/test/monniaux/int_mat_run.c
@@ -54,16 +54,25 @@ int main() {
modint_mat_mul3(m, n, p, c3, p, a, n, b, p);
c3_time = get_cycle()-c3_time;
+ modint *c4 = malloc(sizeof(modint) * m * p);
+ cycle_t c4_time = get_cycle();
+ modint_mat_mul4(m, n, p, c4, p, a, n, b, p);
+ c4_time = get_cycle()-c4_time;
+
printf("c1==c2: %s\n"
"c1==c3: %s\n"
+ "c1==c4: %s\n"
"c1_time = %" PRIu64 "\n"
"c2_time = %" PRIu64 "\n"
- "c3_time = %" PRIu64 "\n",
+ "c3_time = %" PRIu64 "\n"
+ "c4_time = %" PRIu64 "\n",
modint_mat_equal(m, n, c1, p, c2, p)?"true":"false",
modint_mat_equal(m, n, c1, p, c3, p)?"true":"false",
+ modint_mat_equal(m, n, c1, p, c4, p)?"true":"false",
c1_time,
c2_time,
- c3_time);
+ c3_time,
+ c4_time);
free(a);
free(b);
diff --git a/test/monniaux/modint.h b/test/monniaux/modint.h
index 3636657d..d3a154c1 100644
--- a/test/monniaux/modint.h
+++ b/test/monniaux/modint.h
@@ -19,6 +19,11 @@ void modint_mat_mul3(unsigned m, unsigned n, unsigned p,
const modint *a, unsigned stride_a,
const modint *b, unsigned stride_b);
+void modint_mat_mul4(unsigned m, unsigned n, unsigned p,
+ modint * restrict c, unsigned stride_c,
+ const modint *a, unsigned stride_a,
+ const modint *b, unsigned stride_b);
+
modint modint_random(void);
void modint_mat_random(unsigned m,