diff options
author | Cyril SIX <cyril.six@kalray.eu> | 2019-01-18 15:27:05 +0100 |
---|---|---|
committer | Cyril SIX <cyril.six@kalray.eu> | 2019-01-18 15:27:05 +0100 |
commit | fc104905f2258af120428c1d49492992276181a7 (patch) | |
tree | a2b91481eff934c1261f63cc0550960f09d357cb | |
parent | 458df74c1280ab4f6131272b20f8613cbd683f87 (diff) | |
parent | 99e5f103393d554b0d2725303682a35d343a09b6 (diff) | |
download | compcert-kvx-fc104905f2258af120428c1d49492992276181a7.tar.gz compcert-kvx-fc104905f2258af120428c1d49492992276181a7.zip |
Merge branch 'mppa_postpass' of gricad-gitlab.univ-grenoble-alpes.fr:sixcy/CompCert into mppa_postpass
-rw-r--r-- | test/monniaux/mod_int_mat/Makefile (renamed from test/monniaux/Makefile) | 0 | ||||
-rw-r--r-- | test/monniaux/mod_int_mat/int_mat.c (renamed from test/monniaux/int_mat.c) | 51 | ||||
-rw-r--r-- | test/monniaux/mod_int_mat/int_mat_run.c (renamed from test/monniaux/int_mat_run.c) | 25 | ||||
-rw-r--r-- | test/monniaux/mod_int_mat/modint.h (renamed from test/monniaux/modint.h) | 10 |
4 files changed, 84 insertions, 2 deletions
diff --git a/test/monniaux/Makefile b/test/monniaux/mod_int_mat/Makefile index be534653..be534653 100644 --- a/test/monniaux/Makefile +++ b/test/monniaux/mod_int_mat/Makefile diff --git a/test/monniaux/int_mat.c b/test/monniaux/mod_int_mat/int_mat.c index a750937d..d3e14e26 100644 --- a/test/monniaux/int_mat.c +++ b/test/monniaux/mod_int_mat/int_mat.c @@ -58,6 +58,57 @@ 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; + } +} + +void modint_mat_mul5(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 j2=0, n2=n/2; j2<n2; j2++) { + modint p0 = *pa_i_j * *pb_j_k; + pa_i_j ++; + pb_j_k += stride_b; + modint p1 = *pa_i_j * *pb_j_k; + pa_i_j ++; + pb_j_k += stride_b; + total += p0 + p1; + } + if (n%2) { + total += *pa_i_j * *pb_j_k; + } + 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/mod_int_mat/int_mat_run.c index b8d836af..9d5c0c57 100644 --- a/test/monniaux/int_mat_run.c +++ b/test/monniaux/mod_int_mat/int_mat_run.c @@ -54,20 +54,41 @@ 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; + + modint *c5 = malloc(sizeof(modint) * m * p); + cycle_t c5_time = get_cycle(); + modint_mat_mul5(m, n, p, c5, p, a, n, b, p); + c5_time = get_cycle()-c5_time; + printf("c1==c2: %s\n" "c1==c3: %s\n" + "c1==c4: %s\n" + "c1==c5: %s\n" "c1_time = %" PRIu64 "\n" "c2_time = %" PRIu64 "\n" - "c3_time = %" PRIu64 "\n", + "c3_time = %" PRIu64 "\n" + "c4_time = %" PRIu64 "\n" + "c5_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", + modint_mat_equal(m, n, c1, p, c5, p)?"true":"false", c1_time, c2_time, - c3_time); + c3_time, + c4_time, + c5_time); free(a); free(b); free(c1); free(c2); + free(c3); + free(c4); + free(c5); return 0; } diff --git a/test/monniaux/modint.h b/test/monniaux/mod_int_mat/modint.h index 3636657d..5295258b 100644 --- a/test/monniaux/modint.h +++ b/test/monniaux/mod_int_mat/modint.h @@ -19,6 +19,16 @@ 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); + +void modint_mat_mul5(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, |