Commit e1c76b4dd48a3ab323e20e94ebe984d7ded7c183

Authored by KMG
1 parent 87bb2604
Exists in master and in 3 other branches v1, v2, v3

Added exhaustive test support (Ethan's changes to gf_unit and gf_methods) and ov…

…errode autoconf's defaults for CFLAGS.
Makefile.am
1   -# GF-Complete AM file
2   -# Only creates library and distributes header files
  1 +# Top-level GF-Complete AM file
  2 +# Distributes headers
3 3  
4 4 SUBDIRS = src tools test examples
5 5 ACLOCAL_AMFLAGS = -I m4
... ...
Makefile.in
... ... @@ -15,8 +15,8 @@
15 15  
16 16 @SET_MAKE@
17 17  
18   -# GF-Complete AM file
19   -# Only creates library and distributes header files
  18 +# Top-level GF-Complete AM file
  19 +# Distributes headers
20 20  
21 21 VPATH = @srcdir@
22 22 pkgdatadir = $(datadir)/@PACKAGE@
... ...
configure
... ... @@ -10972,6 +10972,10 @@ ac_config_headers="$ac_config_headers include/config.h"
10972 10972  
10973 10973  
10974 10974  
  10975 +# Override default CFLAGS
  10976 +CFLAGS="-O3 -g"
  10977 +CXXFLAGS="-O3 -g"
  10978 +
10975 10979 ac_ext=c
10976 10980 ac_cpp='$CPP $CPPFLAGS'
10977 10981 ac_compile='$CC -c $CFLAGS $CPPFLAGS conftest.$ac_ext >&5'
... ...
configure.ac
... ... @@ -13,6 +13,10 @@ AC_CONFIG_HEADER(include/config.h)
13 13 dnl Needed when reconfiguring with 'autoreconf -i -s'
14 14 AC_CONFIG_MACRO_DIR([m4])
15 15  
  16 +# Override default CFLAGS
  17 +CFLAGS="-O3 -g"
  18 +CXXFLAGS="-O3 -g"
  19 +
16 20 dnl Compiling with per-target flags requires AM_PROG_CC_C_O.
17 21 AC_PROG_CC
18 22  
... ...
examples/Makefile.am
1   -# GF-Complete AM file
2   -# Only creates library and distributes header files
  1 +# GF-Complete 'examples' AM file
3 2  
4 3 INCLUDES=-I./ -I../include
5 4 AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC $(INCLUDES)
... ...
examples/Makefile.in
... ... @@ -15,8 +15,7 @@
15 15  
16 16 @SET_MAKE@
17 17  
18   -# GF-Complete AM file
19   -# Only creates library and distributes header files
  18 +# GF-Complete 'examples' AM file
20 19  
21 20 VPATH = @srcdir@
22 21 pkgdatadir = $(datadir)/@PACKAGE@
... ...
src/Makefile.am
1   -# GF-Complete AM file
2   -# Only creates library and distributes header files
  1 +# GF-Complete 'core' AM file
  2 +# Creates the library
3 3  
4 4 INCLUDES=-I./ -I../include
5 5 AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC $(INCLUDES)
... ...
src/Makefile.in
... ... @@ -15,8 +15,8 @@
15 15  
16 16 @SET_MAKE@
17 17  
18   -# GF-Complete AM file
19   -# Only creates library and distributes header files
  18 +# GF-Complete 'core' AM file
  19 +# Creates the library
20 20  
21 21 VPATH = @srcdir@
22 22 pkgdatadir = $(datadir)/@PACKAGE@
... ...
test/Makefile.am
1   -# GF-Complete AM file
2   -# Only creates library and distributes header files
  1 +# GF-Complete 'test' AM file
3 2  
4 3 INCLUDES=-I./ -I../include
5 4 AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC $(INCLUDES)
... ...
test/Makefile.in
... ... @@ -15,8 +15,7 @@
15 15  
16 16 @SET_MAKE@
17 17  
18   -# GF-Complete AM file
19   -# Only creates library and distributes header files
  18 +# GF-Complete 'test' AM file
20 19  
21 20 VPATH = @srcdir@
22 21 pkgdatadir = $(datadir)/@PACKAGE@
... ...
test/gf_unit.c
... ... @@ -22,7 +22,7 @@
22 22 #include "gf_rand.h"
23 23 #include "gf_general.h"
24 24  
25   -#define REGION_SIZE (16384)
  25 +#define REGION_SIZE (16384)
26 26 #define RMASK (0x00000000ffffffffLL)
27 27 #define LMASK (0xffffffff00000000LL)
28 28  
... ... @@ -38,7 +38,7 @@ char *BM = "Bad Method: ";
38 38 void usage(char *s)
39 39 {
40 40 fprintf(stderr, "usage: gf_unit w tests seed [method] - does unit testing in GF(2^w)\n");
41   - fprintf(stderr, "\n");
  41 + fprintf(stderr, "\n");
42 42 fprintf(stderr, "Legal w are: 1 - 32, 64 and 128\n");
43 43 fprintf(stderr, " 128 is hex only (i.e. '128' will be an error - do '128h')\n");
44 44 fprintf(stderr, "\n");
... ... @@ -95,9 +95,16 @@ int main(int argc, char **argv)
95 95 MOA_Seed(t0);
96 96  
97 97 if (w > 32 && w != 64 && w != 128) usage("Bad w");
98   -
99   - if (create_gf_from_argv(&gf, w, argc, argv, 4) == 0) usage(BM);
100   - printf("Size (bytes): %d\n", gf_size(&gf));
  98 +
  99 + if (create_gf_from_argv(&gf, w, argc, argv, 4) == 0) {
  100 + usage(BM);
  101 + }
  102 +
  103 + printf("Args: ");
  104 + for (i = 1; i < argc; i++) {
  105 + printf ("%s ", argv[i]);
  106 + }
  107 + printf("/ size (bytes): %d\n", gf_size(&gf));
101 108  
102 109 for (i = 0; i < strlen(argv[2]); i++) {
103 110 if (strchr("ASRV", argv[2][i]) == NULL) usage("Bad test\n");
... ...
tools/Makefile.am
1   -# GF-Complete AM file
2   -# Only creates library and distributes header files
  1 +# GF-Complete 'tools' AM file
3 2  
4 3 INCLUDES=-I./ -I../include
5 4 AM_CFLAGS = -O3 $(SIMD_FLAGS) -fPIC $(INCLUDES)
... ...
tools/Makefile.in
... ... @@ -15,8 +15,7 @@
15 15  
16 16 @SET_MAKE@
17 17  
18   -# GF-Complete AM file
19   -# Only creates library and distributes header files
  18 +# GF-Complete 'tools' AM file
20 19  
21 20 VPATH = @srcdir@
22 21 pkgdatadir = $(datadir)/@PACKAGE@
... ...
tools/gf_methods.c
... ... @@ -29,18 +29,27 @@ static char *regions[NREGIONS] = { &quot;DOUBLE&quot;, &quot;QUAD&quot;, &quot;LAZY&quot;, &quot;SSE&quot;, &quot;NOSSE&quot;,
29 29 #define NDIVS (2)
30 30 static char *divides[NDIVS] = { "MATRIX", "EUCLID" };
31 31  
32   -int main()
  32 +
  33 +int main(int argc, char *argv[])
33 34 {
34 35 int m, r, d, w, i, sa, j, k, reset;
35   - char *argv[50];
  36 + char *gf_argv[50];
36 37 gf_t gf;
37 38 char divs[200], ks[10], ls[10];
38   -
  39 + char * w_str = "w=%d:";
  40 +
  41 + if (argc == 2) {
  42 + if (!strcmp (argv[1], "-U")) {
  43 + w_str = "%d A -1";
  44 + }
  45 + }
  46 +
39 47 for (i = 2; i < 8; i++) {
40 48 w = (1 << i);
41   - argv[0] = "-";
42   - if (create_gf_from_argv(&gf, w, 1, argv, 0) > 0) {
43   - printf("w=%d: -\n", w);
  49 + gf_argv[0] = "-";
  50 + if (create_gf_from_argv(&gf, w, 1, gf_argv, 0) > 0) {
  51 + printf(w_str, w);
  52 + printf(" - \n");
44 53 gf_free(&gf, 1);
45 54 } else if (_gf_errno == GF_E_DEFAULT) {
46 55 fprintf(stderr, "Unlabeled failed method: w=%d: -\n", 2);
... ... @@ -49,83 +58,83 @@ int main()
49 58  
50 59 for (m = 0; m < NMULTS; m++) {
51 60 sa = 0;
52   - argv[sa++] = "-m";
  61 + gf_argv[sa++] = "-m";
53 62 if (strcmp(mults[m], "GROUP44") == 0) {
54   - argv[sa++] = "GROUP";
55   - argv[sa++] = "4";
56   - argv[sa++] = "4";
  63 + gf_argv[sa++] = "GROUP";
  64 + gf_argv[sa++] = "4";
  65 + gf_argv[sa++] = "4";
57 66 } else if (strcmp(mults[m], "GROUP48") == 0) {
58   - argv[sa++] = "GROUP";
59   - argv[sa++] = "4";
60   - argv[sa++] = "8";
  67 + gf_argv[sa++] = "GROUP";
  68 + gf_argv[sa++] = "4";
  69 + gf_argv[sa++] = "8";
61 70 } else if (strcmp(mults[m], "SPLIT2") == 0) {
62   - argv[sa++] = "SPLIT";
  71 + gf_argv[sa++] = "SPLIT";
63 72 sprintf(ls, "%d", w);
64   - argv[sa++] = ls;
65   - argv[sa++] = "2";
  73 + gf_argv[sa++] = ls;
  74 + gf_argv[sa++] = "2";
66 75 } else if (strcmp(mults[m], "SPLIT4") == 0) {
67   - argv[sa++] = "SPLIT";
  76 + gf_argv[sa++] = "SPLIT";
68 77 sprintf(ls, "%d", w);
69   - argv[sa++] = ls;
70   - argv[sa++] = "4";
  78 + gf_argv[sa++] = ls;
  79 + gf_argv[sa++] = "4";
71 80 } else if (strcmp(mults[m], "SPLIT8") == 0) {
72   - argv[sa++] = "SPLIT";
  81 + gf_argv[sa++] = "SPLIT";
73 82 sprintf(ls, "%d", w);
74   - argv[sa++] = ls;
75   - argv[sa++] = "8";
  83 + gf_argv[sa++] = ls;
  84 + gf_argv[sa++] = "8";
76 85 } else if (strcmp(mults[m], "SPLIT16") == 0) {
77   - argv[sa++] = "SPLIT";
  86 + gf_argv[sa++] = "SPLIT";
78 87 sprintf(ls, "%d", w);
79   - argv[sa++] = ls;
80   - argv[sa++] = "16";
  88 + gf_argv[sa++] = ls;
  89 + gf_argv[sa++] = "16";
81 90 } else if (strcmp(mults[m], "SPLIT88") == 0) {
82   - argv[sa++] = "SPLIT";
83   - argv[sa++] = "8";
84   - argv[sa++] = "8";
  91 + gf_argv[sa++] = "SPLIT";
  92 + gf_argv[sa++] = "8";
  93 + gf_argv[sa++] = "8";
85 94 } else if (strcmp(mults[m], "COMPOSITE") == 0) {
86   - argv[sa++] = "COMPOSITE";
87   - argv[sa++] = "2";
88   - argv[sa++] = "-";
  95 + gf_argv[sa++] = "COMPOSITE";
  96 + gf_argv[sa++] = "2";
  97 + gf_argv[sa++] = "-";
89 98 } else {
90   - argv[sa++] = mults[m];
  99 + gf_argv[sa++] = mults[m];
91 100 }
92 101 reset = sa;
93 102 for (r = 0; r < (1 << NREGIONS); r++) {
94 103 sa = reset;
95 104 for (k = 0; k < NREGIONS; k++) {
96 105 if (r & 1 << k) {
97   - argv[sa++] = "-r";
98   - argv[sa++] = regions[k];
  106 + gf_argv[sa++] = "-r";
  107 + gf_argv[sa++] = regions[k];
99 108 }
100 109 }
101   - argv[sa++] = "-";
102   - if (create_gf_from_argv(&gf, w, sa, argv, 0) > 0) {
103   - printf("w=%d:", w);
104   - for (j = 0; j < sa; j++) printf(" %s", argv[j]);
  110 + gf_argv[sa++] = "-";
  111 + if (create_gf_from_argv(&gf, w, sa, gf_argv, 0) > 0) {
  112 + printf(w_str, w);
  113 + for (j = 0; j < sa; j++) printf(" %s", gf_argv[j]);
105 114 printf("\n");
106 115 gf_free(&gf, 1);
107 116 } else if (_gf_errno == GF_E_DEFAULT) {
108 117 fprintf(stderr, "Unlabeled failed method: w=%d:", w);
109   - for (j = 0; j < sa; j++) fprintf(stderr, " %s", argv[j]);
  118 + for (j = 0; j < sa; j++) fprintf(stderr, " %s", gf_argv[j]);
110 119 fprintf(stderr, "\n");
111 120 exit(1);
112 121 }
113 122 sa--;
114 123 for (d = 0; d < NDIVS; d++) {
115   - argv[sa++] = "-d";
116   - argv[sa++] = divides[d];
  124 + gf_argv[sa++] = "-d";
  125 + gf_argv[sa++] = divides[d];
117 126 /* printf("w=%d:", w);
118   - for (j = 0; j < sa; j++) printf(" %s", argv[j]);
  127 + for (j = 0; j < sa; j++) printf(" %s", gf_argv[j]);
119 128 printf("\n"); */
120   - argv[sa++] = "-";
121   - if (create_gf_from_argv(&gf, w, sa, argv, 0) > 0) {
122   - printf("w=%d:", w);
123   - for (j = 0; j < sa; j++) printf(" %s", argv[j]);
  129 + gf_argv[sa++] = "-";
  130 + if (create_gf_from_argv(&gf, w, sa, gf_argv, 0) > 0) {
  131 + printf(w_str, w);
  132 + for (j = 0; j < sa; j++) printf(" %s", gf_argv[j]);
124 133 printf("\n");
125 134 gf_free(&gf, 1);
126 135 } else if (_gf_errno == GF_E_DEFAULT) {
127 136 fprintf(stderr, "Unlabeled failed method: w=%d:", w);
128   - for (j = 0; j < sa; j++) fprintf(stderr, " %s", argv[j]);
  137 + for (j = 0; j < sa; j++) fprintf(stderr, " %s", gf_argv[j]);
129 138 fprintf(stderr, "\n");
130 139 exit(1);
131 140 }
... ...