aboutsummaryrefslogtreecommitdiffstats
path: root/test
diff options
context:
space:
mode:
authorDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-01-17 20:20:25 +0100
committerDavid Monniaux <david.monniaux@univ-grenoble-alpes.fr>2019-01-17 20:20:25 +0100
commitf9a0dd579dc72b09c4ebb036df0b59891412163d (patch)
tree6cd0b20ea7868eaffc92c34594ff54f9532094b5 /test
parentd366e22b0c8665ab73d162cf8db98b91b2e4314e (diff)
downloadcompcert-kvx-f9a0dd579dc72b09c4ebb036df0b59891412163d.tar.gz
compcert-kvx-f9a0dd579dc72b09c4ebb036df0b59891412163d.zip
for testing postpass
Diffstat (limited to 'test')
-rw-r--r--test/monniaux/Makefile24
-rw-r--r--test/monniaux/int_mat.c27
-rw-r--r--test/monniaux/int_mat_run.c22
-rw-r--r--test/monniaux/modint.h26
4 files changed, 64 insertions, 35 deletions
diff --git a/test/monniaux/Makefile b/test/monniaux/Makefile
index 26fd90d7..91644c2f 100644
--- a/test/monniaux/Makefile
+++ b/test/monniaux/Makefile
@@ -4,20 +4,26 @@ K1C_CFLAGS=-Wall -O3 -std=c99
K1C_CCOMP=../../ccomp
K1C_CCOMPFLAGS=-Wall -O3 -D__thread= -D__int128=int
-EXECUTABLES=int_mat.host int_mat.k1c int_mat.k1c_ccomp
+PRODUCTS=int_mat.host int_mat.k1c int_mat.k1c_ccomp int_mat.k1c_ccomp.s
-all: $(EXECUTABLES)
+all: $(PRODUCTS)
-int_mat.host: int_mat.c
- $(CC) $(CFLAGS) $+ -o $@
+int_mat.host: int_mat.c int_mat_run.c modint.h
+ $(CC) $(CFLAGS) int_mat.c int_mat_run.c -o $@
-int_mat.k1c: int_mat.c
- $(K1C_CC) $(K1C_CFLAGS) $+ -o $@
+int_mat.k1c: int_mat.c int_mat_run.k1c.o modint.h
+ $(K1C_CC) $(K1C_CFLAGS) int_mat.c int_mat_run.k1c.o -o $@
-int_mat.k1c_ccomp: int_mat.c
- $(K1C_CCOMP) $(K1C_CCOMPFLAGS) $+ -o $@
+int_mat_run.k1c.o: int_mat_run.c modint.h
+ $(K1C_CC) $(K1C_CFLAGS) -c int_mat_run.c -o $@
+
+int_mat.k1c_ccomp.s: int_mat.c modint.h
+ $(K1C_CCOMP) $(K1C_CCOMPFLAGS) -S int_mat.c -o $@
+
+int_mat.k1c_ccomp: int_mat.k1c_ccomp.s int_mat_run.k1c.o modint.h
+ $(K1C_CCOMP) $(K1C_CCOMPFLAGS) int_mat.k1c_ccomp.s int_mat_run.k1c.o -o $@
clean:
- $(RM) -f $(EXECUTABLES)
+ $(RM) -f $(PRODUCTS)
.PHONY: clean
diff --git a/test/monniaux/int_mat.c b/test/monniaux/int_mat.c
index a1615e70..936f45d6 100644
--- a/test/monniaux/int_mat.c
+++ b/test/monniaux/int_mat.c
@@ -1,11 +1,4 @@
-#include <stdint.h>
-#include <stdbool.h>
-#include <stdlib.h>
-#include <stdio.h>
-
-typedef uint32_t modint;
-
-#define MODULUS 257
+#include "modint.h"
void modint_mat_mul1(unsigned m, unsigned n, unsigned p,
modint * restrict c, unsigned stride_c,
@@ -72,21 +65,3 @@ bool modint_mat_equal(unsigned m,
}
return true;
}
-
-int main() {
- const unsigned m = 200, n = 100, p = 150;
- modint *a = malloc(sizeof(modint) * m * n);
- modint_mat_random(m, n, a, n);
- modint *b = malloc(sizeof(modint) * n * p);
- modint_mat_random(n, p, b, p);
- modint *c1 = malloc(sizeof(modint) * m * p);
- modint_mat_mul1(m, n, p, c1, p, a, n, b, p);
- modint *c2 = malloc(sizeof(modint) * m * p);
- modint_mat_mul2(m, n, p, c2, p, a, n, b, p);
- printf("equal = %s\n", modint_mat_equal(m, n, c1, p, c2, p)?"true":"false");
- free(a);
- free(b);
- free(c1);
- free(c2);
- return 0;
-}
diff --git a/test/monniaux/int_mat_run.c b/test/monniaux/int_mat_run.c
new file mode 100644
index 00000000..ec68d719
--- /dev/null
+++ b/test/monniaux/int_mat_run.c
@@ -0,0 +1,22 @@
+#include <stdbool.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include "modint.h"
+
+int main() {
+ const unsigned m = 40, n = 20, p = 30;
+ modint *a = malloc(sizeof(modint) * m * n);
+ modint_mat_random(m, n, a, n);
+ modint *b = malloc(sizeof(modint) * n * p);
+ modint_mat_random(n, p, b, p);
+ modint *c1 = malloc(sizeof(modint) * m * p);
+ modint_mat_mul1(m, n, p, c1, p, a, n, b, p);
+ modint *c2 = malloc(sizeof(modint) * m * p);
+ modint_mat_mul2(m, n, p, c2, p, a, n, b, p);
+ printf("equal = %s\n", modint_mat_equal(m, n, c1, p, c2, p)?"true":"false");
+ free(a);
+ free(b);
+ free(c1);
+ free(c2);
+ return 0;
+}
diff --git a/test/monniaux/modint.h b/test/monniaux/modint.h
new file mode 100644
index 00000000..f1c591f8
--- /dev/null
+++ b/test/monniaux/modint.h
@@ -0,0 +1,26 @@
+#include <stdint.h>
+#include <stdbool.h>
+
+typedef uint32_t modint;
+#define MODULUS 257
+
+void modint_mat_mul1(unsigned m, unsigned n, unsigned p,
+ modint * restrict c, unsigned stride_c,
+ const modint *a, unsigned stride_a,
+ const modint *b, unsigned stride_b);
+
+void modint_mat_mul2(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,
+ unsigned n,
+ modint *a, unsigned stride_a);
+
+bool modint_mat_equal(unsigned m,
+ unsigned n,
+ const modint *a, unsigned stride_a,
+ const modint *b, unsigned stride_b);