From 3b42111855b525d07ef0960b36d0114621b247f8 Mon Sep 17 00:00:00 2001 From: David Monniaux Date: Thu, 31 Jan 2019 14:12:59 +0100 Subject: multiplication of matrices in a finite ring --- test/monniaux/xor_and_mat/int_mat.c | 210 ++++++++++++++++++++++++++++++++++++ 1 file changed, 210 insertions(+) create mode 100644 test/monniaux/xor_and_mat/int_mat.c (limited to 'test/monniaux/xor_and_mat/int_mat.c') diff --git a/test/monniaux/xor_and_mat/int_mat.c b/test/monniaux/xor_and_mat/int_mat.c new file mode 100644 index 00000000..0bfe16b9 --- /dev/null +++ b/test/monniaux/xor_and_mat/int_mat.c @@ -0,0 +1,210 @@ +#include "xor_and.h" + +#define ADD ^= +#define MUL & + +void xor_and_mat_mul1(unsigned m, unsigned n, unsigned p, + xor_and * restrict c, unsigned stride_c, + const xor_and *a, unsigned stride_a, + const xor_and *b, unsigned stride_b) { + for(unsigned i=0; i 0) { + do { + CHUNK + CHUNK + j2++; + } while (j2 < n2); + } + if (n%2) { + total ADD (*pa_i_j MUL *pb_j_k); + } + pc_i[k] = total; + } + pa_i += stride_a; + pc_i += stride_c; + } +} + +#define UNROLL 4 +void xor_and_mat_mul7(unsigned m, unsigned n, unsigned p, + xor_and * c, unsigned stride_c, + const xor_and *a, unsigned stride_a, + const xor_and *b, unsigned stride_b) { + const xor_and *pa_i = a; + xor_and * pc_i = c; + for(unsigned i=0; i 0) { + do { + CHUNK + CHUNK + CHUNK + CHUNK + j4++; + } while (j4 < n4); + } + } + { + unsigned j4=0, n4=n%UNROLL; + if (n4 > 0) { + do { + CHUNK + j4++; + } while (j4 < n4); + } + } + pc_i[k] = total; + } + pa_i += stride_a; + pc_i += stride_c; + } +} + +xor_and xor_and_random(void) { + static uint64_t next = 1325997111; + next = next * 1103515249 + 12345; + return next; +} + +void xor_and_mat_random(unsigned m, + unsigned n, + xor_and *a, unsigned stride_a) { + for(unsigned i=0; i