Added exhaustive test support (Ethan's changes to gf_unit and gf_methods) and overrode autoconf's defaults for CFLAGS.

master
Kevin Greenan 2013-12-07 16:00:12 -08:00
parent 87bb260417
commit e1c76b4dd4
14 changed files with 90 additions and 72 deletions

View File

@ -1,5 +1,5 @@
# GF-Complete AM file # Top-level GF-Complete AM file
# Only creates library and distributes header files # Distributes headers
SUBDIRS = src tools test examples SUBDIRS = src tools test examples
ACLOCAL_AMFLAGS = -I m4 ACLOCAL_AMFLAGS = -I m4

View File

@ -15,8 +15,8 @@
@SET_MAKE@ @SET_MAKE@
# GF-Complete AM file # Top-level GF-Complete AM file
# Only creates library and distributes header files # Distributes headers
VPATH = @srcdir@ VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@

4
configure vendored
View File

@ -10972,6 +10972,10 @@ ac_config_headers="$ac_config_headers include/config.h"
# Override default CFLAGS
CFLAGS="-O3 -g"
CXXFLAGS="-O3 -g"
ac_ext=c ac_ext=c
ac_cpp='$CPP $CPPFLAGS' ac_cpp='$CPP $CPPFLAGS'
ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5' ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'

View File

@ -13,6 +13,10 @@ AC_CONFIG_HEADER(include/config.h)
dnl Needed when reconfiguring with 'autoreconf -i -s' dnl Needed when reconfiguring with 'autoreconf -i -s'
AC_CONFIG_MACRO_DIR([m4]) AC_CONFIG_MACRO_DIR([m4])
# Override default CFLAGS
CFLAGS="-O3 -g"
CXXFLAGS="-O3 -g"
dnl Compiling with per-target flags requires AM_PROG_CC_C_O. dnl Compiling with per-target flags requires AM_PROG_CC_C_O.
AC_PROG_CC AC_PROG_CC

View File

@ -1,5 +1,4 @@
# GF-Complete AM file # GF-Complete 'examples' AM file
# Only creates library and distributes header files
INCLUDES=-I./ -I../include INCLUDES=-I./ -I../include
AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC $(INCLUDES) AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC $(INCLUDES)

View File

@ -15,8 +15,7 @@
@SET_MAKE@ @SET_MAKE@
# GF-Complete AM file # GF-Complete 'examples' AM file
# Only creates library and distributes header files
VPATH = @srcdir@ VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@

View File

@ -1,5 +1,5 @@
# GF-Complete AM file # GF-Complete 'core' AM file
# Only creates library and distributes header files # Creates the library
INCLUDES=-I./ -I../include INCLUDES=-I./ -I../include
AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC $(INCLUDES) AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC $(INCLUDES)

View File

@ -15,8 +15,8 @@
@SET_MAKE@ @SET_MAKE@
# GF-Complete AM file # GF-Complete 'core' AM file
# Only creates library and distributes header files # Creates the library
VPATH = @srcdir@ VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@

View File

@ -1,5 +1,4 @@
# GF-Complete AM file # GF-Complete 'test' AM file
# Only creates library and distributes header files
INCLUDES=-I./ -I../include INCLUDES=-I./ -I../include
AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC $(INCLUDES) AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC $(INCLUDES)

View File

@ -15,8 +15,7 @@
@SET_MAKE@ @SET_MAKE@
# GF-Complete AM file # GF-Complete 'test' AM file
# Only creates library and distributes header files
VPATH = @srcdir@ VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@

View File

@ -22,7 +22,7 @@
#include "gf_rand.h" #include "gf_rand.h"
#include "gf_general.h" #include "gf_general.h"
#define REGION_SIZE (16384) #define REGION_SIZE (16384)
#define RMASK (0x00000000ffffffffLL) #define RMASK (0x00000000ffffffffLL)
#define LMASK (0xffffffff00000000LL) #define LMASK (0xffffffff00000000LL)
@ -38,7 +38,7 @@ char *BM = "Bad Method: ";
void usage(char *s) void usage(char *s)
{ {
fprintf(stderr, "usage: gf_unit w tests seed [method] - does unit testing in GF(2^w)\n"); fprintf(stderr, "usage: gf_unit w tests seed [method] - does unit testing in GF(2^w)\n");
fprintf(stderr, "\n"); fprintf(stderr, "\n");
fprintf(stderr, "Legal w are: 1 - 32, 64 and 128\n"); fprintf(stderr, "Legal w are: 1 - 32, 64 and 128\n");
fprintf(stderr, " 128 is hex only (i.e. '128' will be an error - do '128h')\n"); fprintf(stderr, " 128 is hex only (i.e. '128' will be an error - do '128h')\n");
fprintf(stderr, "\n"); fprintf(stderr, "\n");
@ -95,9 +95,16 @@ int main(int argc, char **argv)
MOA_Seed(t0); MOA_Seed(t0);
if (w > 32 && w != 64 && w != 128) usage("Bad w"); if (w > 32 && w != 64 && w != 128) usage("Bad w");
if (create_gf_from_argv(&gf, w, argc, argv, 4) == 0) usage(BM); if (create_gf_from_argv(&gf, w, argc, argv, 4) == 0) {
printf("Size (bytes): %d\n", gf_size(&gf)); usage(BM);
}
printf("Args: ");
for (i = 1; i < argc; i++) {
printf ("%s ", argv[i]);
}
printf("/ size (bytes): %d\n", gf_size(&gf));
for (i = 0; i < strlen(argv[2]); i++) { for (i = 0; i < strlen(argv[2]); i++) {
if (strchr("ASRV", argv[2][i]) == NULL) usage("Bad test\n"); if (strchr("ASRV", argv[2][i]) == NULL) usage("Bad test\n");

View File

@ -1,5 +1,4 @@
# GF-Complete AM file # GF-Complete 'tools' AM file
# Only creates library and distributes header files
INCLUDES=-I./ -I../include INCLUDES=-I./ -I../include
AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC $(INCLUDES) AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC $(INCLUDES)

View File

@ -15,8 +15,7 @@
@SET_MAKE@ @SET_MAKE@
# GF-Complete AM file # GF-Complete 'tools' AM file
# Only creates library and distributes header files
VPATH = @srcdir@ VPATH = @srcdir@
pkgdatadir = $(datadir)/@PACKAGE@ pkgdatadir = $(datadir)/@PACKAGE@

View File

@ -29,18 +29,27 @@ static char *regions[NREGIONS] = { "DOUBLE", "QUAD", "LAZY", "SSE", "NOSSE",
#define NDIVS (2) #define NDIVS (2)
static char *divides[NDIVS] = { "MATRIX", "EUCLID" }; static char *divides[NDIVS] = { "MATRIX", "EUCLID" };
int main()
int main(int argc, char *argv[])
{ {
int m, r, d, w, i, sa, j, k, reset; int m, r, d, w, i, sa, j, k, reset;
char *argv[50]; char *gf_argv[50];
gf_t gf; gf_t gf;
char divs[200], ks[10], ls[10]; char divs[200], ks[10], ls[10];
char * w_str = "w=%d:";
if (argc == 2) {
if (!strcmp (argv[1], "-U")) {
w_str = "%d A -1";
}
}
for (i = 2; i < 8; i++) { for (i = 2; i < 8; i++) {
w = (1 << i); w = (1 << i);
argv[0] = "-"; gf_argv[0] = "-";
if (create_gf_from_argv(&gf, w, 1, argv, 0) > 0) { if (create_gf_from_argv(&gf, w, 1, gf_argv, 0) > 0) {
printf("w=%d: -\n", w); printf(w_str, w);
printf(" - \n");
gf_free(&gf, 1); gf_free(&gf, 1);
} else if (_gf_errno == GF_E_DEFAULT) { } else if (_gf_errno == GF_E_DEFAULT) {
fprintf(stderr, "Unlabeled failed method: w=%d: -\n", 2); fprintf(stderr, "Unlabeled failed method: w=%d: -\n", 2);
@ -49,83 +58,83 @@ int main()
for (m = 0; m < NMULTS; m++) { for (m = 0; m < NMULTS; m++) {
sa = 0; sa = 0;
argv[sa++] = "-m"; gf_argv[sa++] = "-m";
if (strcmp(mults[m], "GROUP44") == 0) { if (strcmp(mults[m], "GROUP44") == 0) {
argv[sa++] = "GROUP"; gf_argv[sa++] = "GROUP";
argv[sa++] = "4"; gf_argv[sa++] = "4";
argv[sa++] = "4"; gf_argv[sa++] = "4";
} else if (strcmp(mults[m], "GROUP48") == 0) { } else if (strcmp(mults[m], "GROUP48") == 0) {
argv[sa++] = "GROUP"; gf_argv[sa++] = "GROUP";
argv[sa++] = "4"; gf_argv[sa++] = "4";
argv[sa++] = "8"; gf_argv[sa++] = "8";
} else if (strcmp(mults[m], "SPLIT2") == 0) { } else if (strcmp(mults[m], "SPLIT2") == 0) {
argv[sa++] = "SPLIT"; gf_argv[sa++] = "SPLIT";
sprintf(ls, "%d", w); sprintf(ls, "%d", w);
argv[sa++] = ls; gf_argv[sa++] = ls;
argv[sa++] = "2"; gf_argv[sa++] = "2";
} else if (strcmp(mults[m], "SPLIT4") == 0) { } else if (strcmp(mults[m], "SPLIT4") == 0) {
argv[sa++] = "SPLIT"; gf_argv[sa++] = "SPLIT";
sprintf(ls, "%d", w); sprintf(ls, "%d", w);
argv[sa++] = ls; gf_argv[sa++] = ls;
argv[sa++] = "4"; gf_argv[sa++] = "4";
} else if (strcmp(mults[m], "SPLIT8") == 0) { } else if (strcmp(mults[m], "SPLIT8") == 0) {
argv[sa++] = "SPLIT"; gf_argv[sa++] = "SPLIT";
sprintf(ls, "%d", w); sprintf(ls, "%d", w);
argv[sa++] = ls; gf_argv[sa++] = ls;
argv[sa++] = "8"; gf_argv[sa++] = "8";
} else if (strcmp(mults[m], "SPLIT16") == 0) { } else if (strcmp(mults[m], "SPLIT16") == 0) {
argv[sa++] = "SPLIT"; gf_argv[sa++] = "SPLIT";
sprintf(ls, "%d", w); sprintf(ls, "%d", w);
argv[sa++] = ls; gf_argv[sa++] = ls;
argv[sa++] = "16"; gf_argv[sa++] = "16";
} else if (strcmp(mults[m], "SPLIT88") == 0) { } else if (strcmp(mults[m], "SPLIT88") == 0) {
argv[sa++] = "SPLIT"; gf_argv[sa++] = "SPLIT";
argv[sa++] = "8"; gf_argv[sa++] = "8";
argv[sa++] = "8"; gf_argv[sa++] = "8";
} else if (strcmp(mults[m], "COMPOSITE") == 0) { } else if (strcmp(mults[m], "COMPOSITE") == 0) {
argv[sa++] = "COMPOSITE"; gf_argv[sa++] = "COMPOSITE";
argv[sa++] = "2"; gf_argv[sa++] = "2";
argv[sa++] = "-"; gf_argv[sa++] = "-";
} else { } else {
argv[sa++] = mults[m]; gf_argv[sa++] = mults[m];
} }
reset = sa; reset = sa;
for (r = 0; r < (1 << NREGIONS); r++) { for (r = 0; r < (1 << NREGIONS); r++) {
sa = reset; sa = reset;
for (k = 0; k < NREGIONS; k++) { for (k = 0; k < NREGIONS; k++) {
if (r & 1 << k) { if (r & 1 << k) {
argv[sa++] = "-r"; gf_argv[sa++] = "-r";
argv[sa++] = regions[k]; gf_argv[sa++] = regions[k];
} }
} }
argv[sa++] = "-"; gf_argv[sa++] = "-";
if (create_gf_from_argv(&gf, w, sa, argv, 0) > 0) { if (create_gf_from_argv(&gf, w, sa, gf_argv, 0) > 0) {
printf("w=%d:", w); printf(w_str, w);
for (j = 0; j < sa; j++) printf(" %s", argv[j]); for (j = 0; j < sa; j++) printf(" %s", gf_argv[j]);
printf("\n"); printf("\n");
gf_free(&gf, 1); gf_free(&gf, 1);
} else if (_gf_errno == GF_E_DEFAULT) { } else if (_gf_errno == GF_E_DEFAULT) {
fprintf(stderr, "Unlabeled failed method: w=%d:", w); fprintf(stderr, "Unlabeled failed method: w=%d:", w);
for (j = 0; j < sa; j++) fprintf(stderr, " %s", argv[j]); for (j = 0; j < sa; j++) fprintf(stderr, " %s", gf_argv[j]);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
exit(1); exit(1);
} }
sa--; sa--;
for (d = 0; d < NDIVS; d++) { for (d = 0; d < NDIVS; d++) {
argv[sa++] = "-d"; gf_argv[sa++] = "-d";
argv[sa++] = divides[d]; gf_argv[sa++] = divides[d];
/* printf("w=%d:", w); /* printf("w=%d:", w);
for (j = 0; j < sa; j++) printf(" %s", argv[j]); for (j = 0; j < sa; j++) printf(" %s", gf_argv[j]);
printf("\n"); */ printf("\n"); */
argv[sa++] = "-"; gf_argv[sa++] = "-";
if (create_gf_from_argv(&gf, w, sa, argv, 0) > 0) { if (create_gf_from_argv(&gf, w, sa, gf_argv, 0) > 0) {
printf("w=%d:", w); printf(w_str, w);
for (j = 0; j < sa; j++) printf(" %s", argv[j]); for (j = 0; j < sa; j++) printf(" %s", gf_argv[j]);
printf("\n"); printf("\n");
gf_free(&gf, 1); gf_free(&gf, 1);
} else if (_gf_errno == GF_E_DEFAULT) { } else if (_gf_errno == GF_E_DEFAULT) {
fprintf(stderr, "Unlabeled failed method: w=%d:", w); fprintf(stderr, "Unlabeled failed method: w=%d:", w);
for (j = 0; j < sa; j++) fprintf(stderr, " %s", argv[j]); for (j = 0; j < sa; j++) fprintf(stderr, " %s", gf_argv[j]);
fprintf(stderr, "\n"); fprintf(stderr, "\n");
exit(1); exit(1);
} }