[SCM] Fast arithmetic with dense matrices over F_{2^e} branch, upstream, updated. 9faf6ece9a183a703670566609063ab274b1c544
Martin Albrecht
martinralbrecht at googlemail.com
Mon Sep 10 12:24:24 UTC 2012
The following commit has been merged in the upstream branch:
commit 8bc4ae0e125e8a521a758be9a7a7c17dbb16c663
Author: Martin Albrecht <martinralbrecht at googlemail.com>
Date: Thu Aug 9 23:02:29 2012 +0100
removed dependency on Givaro for finite field creation
diff --git a/Makefile.am b/Makefile.am
index cea7cf3..f1ad325 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -41,9 +41,9 @@ libm4rie_la_LDFLAGS = -release 0.0.$(RELEASE) -no-undefined ${M4RIE_M4RI_LDFLAGS
libm4rie_la_LIBADD = -lm4ri
#testing
-TESTCXXFLAGS = ${AM_CFLAGS} @CXXFLAGS@ ${M4RIE_M4RI_CFLAGS} ${M4RIE_GIVARO_CXXFLAGS} ${M4RI_CFLAGS} -I./tests
-TESTLIBADD = -lm4ri -lm4rie -lgivaro -lgmpxx -lgmp -lm -lstdc++
-TESTLDADD = ${M4RIE_GIVARO_LDFLAGS}
+TESTCXXFLAGS = ${AM_CFLAGS} @CXXFLAGS@ ${M4RIE_M4RI_CFLAGS} ${M4RI_CFLAGS} -I./tests
+TESTLIBADD = -lm4ri -lm4rie
+TESTLDADD =
TESTLDFLAGS =
check_PROGRAMS = test_trsm test_elimination test_multiplication test_smallops test_ple
diff --git a/bench/Makefile.am b/bench/Makefile.am
index 2ba07ca..6d25a25 100644
--- a/bench/Makefile.am
+++ b/bench/Makefile.am
@@ -1,8 +1,8 @@
CPUCYCLES_DIR=./cpucycles-20060326
-BENCHCXXFLAGS = $(AM_CFLAGS) -I.. -I${CPUCYCLES_DIR} @CXXFLAGS@ ${M4RIE_GIVARO_CXXFLAGS} -DNDEBUG
-BENCHLIBADD = -lm4ri -lgivaro -lntl -lgmpxx -lgmp -lm -lstdc++ cpucycles.o
-BENCHLDFLAGS = -Wl,-rpath,../.libs/ ../.libs/libm4rie.so ${M4RIE_GIVARO_LDFLAGS} -L${CPUCYCLES_DIR} -Wl,-rpath,${M4RIE_GIVARO_PREFIX}/lib -Wl,-rpath,${M4RIE_M4RI_PREFIX}/lib
+BENCHCXXFLAGS = $(AM_CFLAGS) -I.. -I${CPUCYCLES_DIR} @CXXFLAGS@ -DNDEBUG
+BENCHLIBADD = -lm4ri cpucycles.o
+BENCHLDFLAGS = -Wl,-rpath,../.libs/ ../.libs/libm4rie.so -L${CPUCYCLES_DIR} -Wl,-rpath,${M4RIE_M4RI_PREFIX}/lib
EXTRA_PROGRAMS = bench_multiplication bench_elimination bench_smallops bench_trsm bench_ple
diff --git a/bench/bench_elimination.cc b/bench/bench_elimination.cc
index a49f9d8..7927838 100644
--- a/bench/bench_elimination.cc
+++ b/bench/bench_elimination.cc
@@ -1,10 +1,7 @@
-#include <gf2e_cxx/finite_field_givaro.h>
#include <m4rie/m4rie.h>
#include <cpucycles.h>
#include "benchmarking.h"
-using namespace M4RIE;
-
struct elim_params {
rci_t k;
rci_t m;
@@ -18,8 +15,7 @@ int run_mzed(void *_p, unsigned long long *data, int *data_len) {
struct elim_params *p = (struct elim_params *)_p;
*data_len = 2;
- FiniteField *F = (FiniteField*)(new GFqDom<int>(2,p->k));
- gf2e *ff = gf2e_init_givgfq(F);
+ gf2e *ff = gf2e_init(irreducible_polynomials[p->k][1]);
mzed_t *A = mzed_init(ff,p->m,p->n);
mzed_randomize(A);
@@ -42,7 +38,6 @@ int run_mzed(void *_p, unsigned long long *data, int *data_len) {
mzed_free(A);
gf2e_free(ff);
- delete F;
return 0;
}
@@ -50,8 +45,7 @@ int run_mzd_slice(void *_p, unsigned long long *data, int *data_len) {
struct elim_params *p = (struct elim_params *)_p;
*data_len = 2;
- FiniteField *F = (FiniteField*)(new GFqDom<int>(2,p->k));
- gf2e *ff = gf2e_init_givgfq(F);
+ gf2e *ff = gf2e_init(irreducible_polynomials[p->k][1]);
mzd_slice_t *A = mzd_slice_init(ff,p->m,p->n);
mzd_slice_randomize(A);
@@ -91,7 +85,6 @@ int run_mzd_slice(void *_p, unsigned long long *data, int *data_len) {
mzd_slice_free(A);
gf2e_free(ff);
- delete F;
return 0;
}
diff --git a/bench/bench_multiplication.cc b/bench/bench_multiplication.cc
index 90355ab..0b7aa58 100644
--- a/bench/bench_multiplication.cc
+++ b/bench/bench_multiplication.cc
@@ -1,11 +1,7 @@
-#include <gf2e_cxx/finite_field_givaro.h>
#include <m4rie/m4rie.h>
#include <cpucycles.h>
#include "benchmarking.h"
-using namespace M4RIE;
-
-
struct mul_params {
rci_t k;
rci_t m;
@@ -18,8 +14,7 @@ int run_mzed(void *_p, unsigned long long *data, int *data_len) {
struct mul_params *p = (struct mul_params *)_p;
*data_len = 2;
- FiniteField *F = (FiniteField*)(new GFqDom<int>(2,p->k));
- gf2e *ff = gf2e_init_givgfq(F);
+ gf2e *ff = gf2e_init(irreducible_polynomials[p->k][1]);
mzed_t *A = mzed_init(ff,p->m,p->n);
mzed_randomize(A);
@@ -52,7 +47,6 @@ int run_mzed(void *_p, unsigned long long *data, int *data_len) {
mzed_free(C);
gf2e_free(ff);
- delete F;
return 0;
}
@@ -61,8 +55,7 @@ int run_mzd_slice(void *_p, unsigned long long *data, int *data_len) {
struct mul_params *p = (struct mul_params *)_p;
*data_len = 2;
- FiniteField *F = (FiniteField*)(new GFqDom<int>(2,p->k));
- gf2e *ff = gf2e_init_givgfq(F);
+ gf2e *ff = gf2e_init(irreducible_polynomials[p->k][1]);
mzd_slice_t *A = mzd_slice_init(ff,p->m,p->n);
mzd_slice_randomize(A);
@@ -90,7 +83,6 @@ int run_mzd_slice(void *_p, unsigned long long *data, int *data_len) {
mzd_slice_free(C);
gf2e_free(ff);
- delete F;
return 0;
}
diff --git a/bench/bench_ple.cc b/bench/bench_ple.cc
index 4a566d6..38f1f52 100644
--- a/bench/bench_ple.cc
+++ b/bench/bench_ple.cc
@@ -1,10 +1,7 @@
-#include <gf2e_cxx/finite_field_givaro.h>
#include <m4rie/m4rie.h>
#include <cpucycles.h>
#include "benchmarking.h"
-using namespace M4RIE;
-
struct ple_params {
rci_t k;
rci_t m;
@@ -18,8 +15,7 @@ int run(void *_p, unsigned long long *data, int *data_len) {
struct ple_params *p = (struct ple_params *)_p;
*data_len = 2;
- FiniteField *F = (FiniteField*)(new GFqDom<int>(2,p->k));
- gf2e *ff = gf2e_init_givgfq(F);
+ gf2e *ff = gf2e_init(irreducible_polynomials[p->k][1]);
mzed_t *A = mzed_init(ff, p->m, p->n);
mzed_randomize(A);
@@ -44,7 +40,6 @@ int run(void *_p, unsigned long long *data, int *data_len) {
mzp_free(P);
mzp_free(Q);
gf2e_free(ff);
- delete F;
return 0;
}
diff --git a/bench/bench_smallops.cc b/bench/bench_smallops.cc
index 3b3ec45..db13c0a 100644
--- a/bench/bench_smallops.cc
+++ b/bench/bench_smallops.cc
@@ -1,10 +1,7 @@
-#include <gf2e_cxx/finite_field_givaro.h>
#include <m4rie/m4rie.h>
#include <cpucycles.h>
#include "benchmarking.h"
-using namespace M4RIE;
-
struct smallops_params {
rci_t k;
rci_t m;
@@ -16,8 +13,7 @@ int run_mzed_add(void *_p, unsigned long long *data, int *data_len) {
struct smallops_params *p = (struct smallops_params *)_p;
*data_len = 2;
- FiniteField *F = (FiniteField*)(new GFqDom<int>(2,p->k));
- gf2e *ff = gf2e_init_givgfq(F);
+ gf2e *ff = gf2e_init(irreducible_polynomials[p->k][1]);
mzed_t *A = mzed_init(ff,p->m,p->n);
mzed_randomize(A);
@@ -38,7 +34,6 @@ int run_mzed_add(void *_p, unsigned long long *data, int *data_len) {
mzed_free(C);
gf2e_free(ff);
- delete F;
return 0;
}
@@ -47,8 +42,7 @@ int run_mzed_slice(void *_p, unsigned long long *data, int *data_len) {
struct smallops_params *p = (struct smallops_params *)_p;
*data_len = 2;
- FiniteField *F = (FiniteField*)(new GFqDom<int>(2,p->k));
- gf2e *ff = gf2e_init_givgfq(F);
+ gf2e *ff = gf2e_init(irreducible_polynomials[p->k][1]);
mzed_t *A = mzed_init(ff,p->m,p->n);
mzed_randomize(A);
@@ -66,7 +60,6 @@ int run_mzed_slice(void *_p, unsigned long long *data, int *data_len) {
mzd_slice_free(a);
gf2e_free(ff);
- delete F;
return 0;
}
@@ -74,8 +67,7 @@ int run_mzed_cling(void *_p, unsigned long long *data, int *data_len) {
struct smallops_params *p = (struct smallops_params *)_p;
*data_len = 2;
- FiniteField *F = (FiniteField*)(new GFqDom<int>(2,p->k));
- gf2e *ff = gf2e_init_givgfq(F);
+ gf2e *ff = gf2e_init(irreducible_polynomials[p->k][1]);
mzd_slice_t *a = mzd_slice_init(ff,p->m,p->n);
mzd_slice_randomize(a);
@@ -93,7 +85,6 @@ int run_mzed_cling(void *_p, unsigned long long *data, int *data_len) {
mzd_slice_free(a);
gf2e_free(ff);
- delete F;
return 0;
}
diff --git a/bench/bench_trsm.cc b/bench/bench_trsm.cc
index 2e11995..67a1073 100644
--- a/bench/bench_trsm.cc
+++ b/bench/bench_trsm.cc
@@ -1,10 +1,7 @@
-#include <gf2e_cxx/finite_field_givaro.h>
#include <m4rie/m4rie.h>
#include <cpucycles.h>
#include "benchmarking.h"
-using namespace M4RIE;
-
struct elim_params {
rci_t e;
rci_t m;
@@ -19,8 +16,7 @@ int run_mzed(void *_p, unsigned long long *data, int *data_len) {
struct elim_params *p = (struct elim_params *)_p;
*data_len = 2;
- FiniteField *F = (FiniteField*)(new GFqDom<int>(2,p->e));
- gf2e *ff = gf2e_init_givgfq(F);
+ gf2e *ff = gf2e_init(irreducible_polynomials[p->e][1]);
mzed_t *A = mzed_init(ff,p->m,p->m);
mzed_randomize(A);
@@ -62,7 +58,6 @@ int run_mzed(void *_p, unsigned long long *data, int *data_len) {
mzed_free(A);
mzed_free(B);
gf2e_free(ff);
- delete F;
return 0;
}
@@ -70,8 +65,7 @@ int run_mzd_slice(void *_p, unsigned long long *data, int *data_len) {
struct elim_params *p = (struct elim_params *)_p;
*data_len = 2;
- FiniteField *F = (FiniteField*)(new GFqDom<int>(2,p->e));
- gf2e *ff = gf2e_init_givgfq(F);
+ gf2e *ff = gf2e_init(irreducible_polynomials[p->e][1]);
mzd_slice_t *A = mzd_slice_init(ff,p->m,p->m);
mzd_slice_randomize(A);
@@ -112,7 +106,6 @@ int run_mzd_slice(void *_p, unsigned long long *data, int *data_len) {
mzd_slice_free(A);
mzd_slice_free(B);
gf2e_free(ff);
- delete F;
return 0;
}
diff --git a/bench/cpucycles-20060326/do.notes b/bench/cpucycles-20060326/do.notes
index 29c42d9..ecc1cd0 100644
--- a/bench/cpucycles-20060326/do.notes
+++ b/bench/cpucycles-20060326/do.notes
@@ -1,6 +1,6 @@
===== Trying amd64tscfreq.c with gcc...
cpucycles-impl.o: In function `cpucycles_amd64tscfreq_persecond':
cpucycles-impl.c:(.text+0x3a): undefined reference to `sysctlbyname'
-collect2: ld returned 1 exit status
+collect2: error: ld returned 1 exit status
===== Trying amd64cpuinfo.c with gcc...
===== Success. Using amd64cpuinfo.c.
diff --git a/configure.ac b/configure.ac
index f78149f..3673e8c 100644
--- a/configure.ac
+++ b/configure.ac
@@ -56,17 +56,6 @@ if test -n $m4rie_config_m4riprefix; then
AC_SUBST(M4RIE_M4RI_CFLAGS)
fi
-AC_ARG_WITH(givaro,
- AS_HELP_STRING([--with-givaro@<:@=VALUE@:>@], [Optional prefix for Givaro library (for testing).]),[m4rie_config_givaroprefix=$withval])
-if test -n $m4rie_config_givaroprefix; then
- M4RIE_GIVARO_PREFIX=${m4rie_givaro_prefix}
- AC_SUBST(M4RIE_GIVARO_PREFIX)
- M4RIE_GIVARO_LDFLAGS="-L${m4rie_config_givaroprefix}/lib"
- AC_SUBST(M4RIE_GIVARO_LDFLAGS)
- M4RIE_GIVARO_CXXFLAGS="-I${m4rie_config_givaroprefix}/include"
- AC_SUBST(M4RIE_GIVARO_CXXFLAGS)
-fi
-
AX_M4RI_CFLAGS()
M4RI_CFLAGS=$ax_cv_m4ri_cflags
AC_SUBST(M4RI_CFLAGS)
diff --git a/tests/test_elimination.cc b/tests/test_elimination.cc
index efb3c06..4b41b4f 100644
--- a/tests/test_elimination.cc
+++ b/tests/test_elimination.cc
@@ -1,7 +1,30 @@
-#include "testing.h"
-#include <gf2e_cxx/finite_field_givaro.h>
+/**
+ * \file test_elimination.cc
+ * \brief Test code for elimination routines
+ *
+ * \author Martin Albrecht <martinralbrecht at googlemail.com>
+ */
+
+/******************************************************************************
+*
+* M4RIE: Linear Algebra over GF(2^e)
+*
+* Copyright (C) 2010-2012 Martin Albrecht <martinralbrecht at googlemail.com>
+*
+* Distributed under the terms of the GNU General Public License (GEL)
+* version 2 or higher.
+*
+* This code is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* General Public License for more details.
+*
+* The full text of the GPL is available at:
+*
+* http://www.gnu.org/licenses/
+******************************************************************************/
-using namespace M4RIE;
+#include "testing.h"
int test_equality(gf2e *ff, rci_t m, rci_t n) {
int fail_ret = 0;
@@ -77,8 +100,7 @@ int main(int argc, char **argv) {
int fail_ret = 0;
for(int k=2; k<=10; k++) {
- FiniteField F = FiniteField(k);
- ff[k] = gf2e_init_givgfq(&F);
+ ff[k] = gf2e_init(irreducible_polynomials[k][1]);
}
for(int k=2; k<=10; k++) {
diff --git a/tests/test_multiplication.cc b/tests/test_multiplication.cc
index 64a0d6b..615605d 100644
--- a/tests/test_multiplication.cc
+++ b/tests/test_multiplication.cc
@@ -9,7 +9,7 @@
*
* M4RIE: Linear Algebra over GF(2^e)
*
-* Copyright (C) 2010 Martin Albrecht <martinralbrecht at googlemail.com>
+* Copyright (C) 2010-2012 Martin Albrecht <martinralbrecht at googlemail.com>
*
* Distributed under the terms of the GNU General Public License (GEL)
* version 2 or higher.
@@ -24,11 +24,7 @@
* http://www.gnu.org/licenses/
******************************************************************************/
-
#include "testing.h"
-#include <gf2e_cxx/finite_field_givaro.h>
-
-using namespace M4RIE;
int test_addmul(gf2e *ff, rci_t m, rci_t n, rci_t l) {
int fail_ret = 0;
@@ -225,8 +221,7 @@ int main(int argc, char **argv) {
int fail_ret = 0;
for(int k=2; k<=10; k++) {
- FiniteField F = FiniteField(k);
- ff[k] = gf2e_init_givgfq(&F);
+ ff[k] = gf2e_init(irreducible_polynomials[k][1]);
}
for(int k=2; k<=10; k++) {
diff --git a/tests/test_ple.cc b/tests/test_ple.cc
index 5aa80dd..4cac5b4 100644
--- a/tests/test_ple.cc
+++ b/tests/test_ple.cc
@@ -1,7 +1,30 @@
-#include "testing.h"
-#include <gf2e_cxx/finite_field_givaro.h>
+/**
+ * \file test_ple.cc
+ * \brief Test code for PLE elimination routines
+ *
+ * \author Martin Albrecht <martinralbrecht at googlemail.com>
+ */
+
+/******************************************************************************
+*
+* M4RIE: Linear Algebra over GF(2^e)
+*
+* Copyright (C) 2010-2012 Martin Albrecht <martinralbrecht at googlemail.com>
+*
+* Distributed under the terms of the GNU General Public License (GEL)
+* version 2 or higher.
+*
+* This code is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* General Public License for more details.
+*
+* The full text of the GPL is available at:
+*
+* http://www.gnu.org/licenses/
+******************************************************************************/
-using namespace M4RIE;
+#include "testing.h"
int test_mzd_slice_ple(gf2e *ff, const rci_t m, const rci_t n, const rci_t r) {
int fail_ret = 0;
@@ -188,8 +211,7 @@ int main(int argc, char **argv) {
int fail_ret = 0;
for(int k=2; k<=10; k++) {
- FiniteField F = FiniteField(k);
- ff[k] = gf2e_init_givgfq(&F);
+ ff[k] = gf2e_init(irreducible_polynomials[k][1]);
}
for(int k=2; k<=10; k++) {
diff --git a/tests/test_smallops.cc b/tests/test_smallops.cc
index c7737ee..b7adaae 100644
--- a/tests/test_smallops.cc
+++ b/tests/test_smallops.cc
@@ -1,8 +1,30 @@
-#include "testing.h"
-
-#include <gf2e_cxx/finite_field_givaro.h>
+/**
+ * \file test_smallops.cc
+ * \brief Test code for auxilary routines
+ *
+ * \author Martin Albrecht <martinralbrecht at googlemail.com>
+ */
+
+/******************************************************************************
+*
+* M4RIE: Linear Algebra over GF(2^e)
+*
+* Copyright (C) 2010-2012 Martin Albrecht <martinralbrecht at googlemail.com>
+*
+* Distributed under the terms of the GNU General Public License (GEL)
+* version 2 or higher.
+*
+* This code is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* General Public License for more details.
+*
+* The full text of the GPL is available at:
+*
+* http://www.gnu.org/licenses/
+******************************************************************************/
-using namespace M4RIE;
+#include "testing.h"
int test_slice(gf2e *ff, int m, int n) {
int fail_ret = 0;
@@ -160,8 +182,7 @@ int main(int argc, char **argv) {
int fail_ret = 0;
for(int k=2; k<=10; k++) {
- FiniteField F = FiniteField(k);
- ff[k] = gf2e_init_givgfq(&F);
+ ff[k] = gf2e_init(irreducible_polynomials[k][1]);
}
for(int k=2; k<=8; k++) {
diff --git a/tests/test_trsm.cc b/tests/test_trsm.cc
index 9652e2a..9f0db40 100644
--- a/tests/test_trsm.cc
+++ b/tests/test_trsm.cc
@@ -1,5 +1,5 @@
/**
- * \file test_multiplication.cc
+ * \file test_trsm.cc
* \brief Test code for triangular system solving with matrices (TRSM) routines
*
* \author Martin Albrecht <martinralbrecht at googlemail.com>
@@ -25,10 +25,6 @@
******************************************************************************/
#include "testing.h"
-#include <gf2e_cxx/finite_field_givaro.h>
-
-using namespace M4RIE;
-
mzed_t *random_mzed_t_upper_left(gf2e *ff, rci_t m) {
const int bitmask = (1<<ff->degree)-1;
@@ -154,7 +150,7 @@ int test_mzed_trsm_upper_left(gf2e *ff, rci_t m, rci_t n) {
m4rie_check( mzed_canary_is_alive(B) );
m4rie_check( mzed_canary_is_alive(U) );
m4rie_check( mzed_canary_is_alive(X) );
-
+
m4rie_check(mzed_is_zero(B) == 1);
mzed_free(U);
@@ -201,7 +197,7 @@ int test_mzed_trsm_upper_left_echelonize(gf2e *ff, rci_t m, rci_t n) {
mzed_free_window(U);
mzed_free_window(B);
mzed_free(C);
-
+
return fail_ret;
}
@@ -270,7 +266,7 @@ int test_mzed_trsm_lower_left(gf2e *ff, rci_t m, rci_t n) {
m4rie_check( mzed_canary_is_alive(B) );
m4rie_check( mzed_canary_is_alive(L) );
m4rie_check( mzed_canary_is_alive(X) );
-
+
m4rie_check(mzed_is_zero(B) == 1);
mzed_free(L);
@@ -333,7 +329,7 @@ int test_mzd_slice_trsm_upper_left(gf2e *ff, rci_t m, rci_t n) {
m4rie_check( mzd_slice_canary_is_alive(U) );
m4rie_check( mzd_slice_canary_is_alive(X) );
-
+
m4rie_check(mzd_slice_cmp(U,H) == 0);
for(rci_t i=0; i<m; i++) {
@@ -412,7 +408,7 @@ int test_mzd_slice_trsm_lower_left(gf2e *ff, rci_t m, rci_t n) {
m4rie_check( mzd_slice_canary_is_alive(L) );
m4rie_check( mzd_slice_canary_is_alive(X) );
-
+
m4rie_check(mzd_slice_cmp(L,H) == 0);
for(rci_t i=0; i<m; i++) {
@@ -476,8 +472,7 @@ int main(int argc, char **argv) {
int fail_ret = 0;
for(int k=2; k<=10; k++) {
- FiniteField F = FiniteField(k);
- ff[k] = gf2e_init_givgfq(&F);
+ ff[k] = gf2e_init(irreducible_polynomials[k][1]);
}
for(int k=2; k<=10; k++) {
--
Fast arithmetic with dense matrices over F_{2^e}
More information about the debian-science-commits
mailing list