Commit f48f2d38afba9f7c56d6d9d1256e193ff1ad7f6b

Authored by Adam Disney
2 parents 5be1fecb 5832024d
Exists in master and in 3 other branches v2, v3, wip-18092

Merge remote-tracking branch 'dalgaaf/wip-da-sca-20140513'

src/gf_w128.c
... ... @@ -568,7 +568,6 @@ gf_w128_split_4_128_multiply_region(gf_t *gf, void *src, void *dest, gf_val_128_
568 568 printf("\n");
569 569 }
570 570 */
571   - i = 0;
572 571 while (d64 < top) {
573 572 v[0] = (xor) ? d64[0] : 0;
574 573 v[1] = (xor) ? d64[1] : 0;
... ... @@ -613,7 +612,6 @@ gf_w128_split_4_128_sse_multiply_region(gf_t *gf, void *src, void *dest, gf_val_
613 612 }
614 613  
615 614 h = (gf_internal_t *) gf->scratch;
616   - pp = h->prim_poly;
617 615  
618 616 /* We only do this to check on alignment. */
619 617 gf_set_region_data(&rd, gf, src, dest, bytes, 0, xor, 16);
... ... @@ -713,7 +711,6 @@ gf_w128_split_4_128_sse_altmap_multiply_region(gf_t *gf, void *src, void *dest,
713 711 }
714 712  
715 713 h = (gf_internal_t *) gf->scratch;
716   - pp = h->prim_poly;
717 714  
718 715 /* We only do this to check on alignment. */
719 716 gf_set_region_data(&rd, gf, src, dest, bytes, 0, xor, 256);
... ...
src/gf_w16.c
... ... @@ -1268,9 +1268,10 @@ int gf_w16_split_init(gf_t *gf)
1268 1268  
1269 1269 h = (gf_internal_t *) gf->scratch;
1270 1270  
1271   -issse3 = 0;
1272 1271 #ifdef INTEL_SSSE3
1273 1272 issse3 = 1;
  1273 +#else
  1274 + issse3 = 0;
1274 1275 #endif
1275 1276  
1276 1277 if (h->arg1 == 8 && h->arg2 == 8) {
... ... @@ -2270,7 +2271,6 @@ void gf_w16_group_4_4_region_multiply(gf_t *gf, void *src, void *dest, gf_val_32
2270 2271 top = (uint16_t *) rd.d_top;
2271 2272  
2272 2273 while (d16 < top) {
2273   - p = 0;
2274 2274 a16 = *s16;
2275 2275 p16 = (xor) ? *d16 : 0;
2276 2276 ind = a16 >> 12;
... ...
src/gf_w32.c
... ... @@ -914,7 +914,6 @@ gf_w32_group_4_4_multiply(gf_t *gf, gf_val_32_t a, gf_val_32_t b)
914 914 d44 = (struct gf_w32_group_data *) h->private;
915 915 gf_w32_group_set_shift_tables(d44->shift, b, h);
916 916  
917   - p = 0;
918 917 a32 = a;
919 918 ind = a32 >> 28;
920 919 a32 <<= 4;
... ... @@ -1609,7 +1608,7 @@ gf_w32_split_16_32_lazy_multiply_region(gf_t *gf, void *src, void *dest, uint32_
1609 1608 p = (xor) ? *d32 : 0;
1610 1609 a = *s32;
1611 1610 i = 0;
1612   - while (a != 0) {
  1611 + while (a != 0 && i < 2) {
1613 1612 v = (a & 0xffff);
1614 1613 p ^= t[i][v];
1615 1614 a >>= 16;
... ... @@ -1745,7 +1744,6 @@ gf_w32_split_2_32_lazy_sse_multiply_region(gf_t *gf, void *src, void *dest, uint
1745 1744 xi = _mm_and_si128(si, mask2);
1746 1745 xi = _mm_xor_si128(xi, adder);
1747 1746 pi = _mm_xor_si128(pi, _mm_shuffle_epi8(tables[tindex], xi));
1748   - si = _mm_srli_epi16(si, 2);
1749 1747 tindex++;
1750 1748  
1751 1749 vi = _mm_srli_epi32(vi, 8);
... ... @@ -2206,11 +2204,6 @@ gf_w32_split_4_32_lazy_sse_multiply_region(gf_t *gf, void *src, void *dest, uint
2206 2204 v2 = _mm_packus_epi16(tv2, tv0);
2207 2205 v3 = _mm_packus_epi16(tv3, tv1);
2208 2206  
2209   - p0 = v0;
2210   - p1 = v1;
2211   - p2 = v2;
2212   - p3 = v3;
2213   -
2214 2207 si = _mm_and_si128(v0, mask1);
2215 2208 p0 = _mm_shuffle_epi8(tables[6][0], si);
2216 2209 p1 = _mm_shuffle_epi8(tables[6][1], si);
... ... @@ -2297,14 +2290,16 @@ int gf_w32_split_init(gf_t *gf)
2297 2290 uint32_t p, basep;
2298 2291 int i, j, exp, ispclmul, issse3;
2299 2292  
2300   - ispclmul = 0;
2301 2293 #if defined(INTEL_SSE4_PCLMUL)
2302 2294 ispclmul = 1;
  2295 +#else
  2296 + ispclmul = 0;
2303 2297 #endif
2304 2298  
2305   - issse3 = 0;
2306 2299 #ifdef INTEL_SSSE3
2307 2300 issse3 = 1;
  2301 +#else
  2302 + issse3 = 0;
2308 2303 #endif
2309 2304  
2310 2305 h = (gf_internal_t *) gf->scratch;
... ...
src/gf_w64.c
... ... @@ -100,7 +100,7 @@ xor)
100 100 __m128i result, r1;
101 101 __m128i prim_poly;
102 102 __m128i w;
103   - __m128i m1, m2, m3, m4;
  103 + __m128i m1, m3, m4;
104 104 gf_internal_t * h = gf->scratch;
105 105  
106 106 if (val == 0) { gf_multby_zero(dest, bytes, xor); return; }
... ... @@ -112,8 +112,6 @@ xor)
112 112 prim_poly = _mm_set_epi32(0, 0, 0, (uint32_t)(h->prim_poly & 0xffffffffULL));
113 113 b = _mm_insert_epi64 (_mm_setzero_si128(), val, 0);
114 114 m1 = _mm_set_epi32(0, 0, 0, (uint32_t)0xffffffff);
115   - m2 = _mm_slli_si128(m1, 4);
116   - m2 = _mm_or_si128(m1, m2);
117 115 m3 = _mm_slli_si128(m1, 8);
118 116 m4 = _mm_slli_si128(m3, 4);
119 117  
... ... @@ -321,12 +319,9 @@ gf_w64_shift_multiply (gf_t *gf, gf_val_64_t a64, gf_val_64_t b64)
321 319 gf_internal_t *h;
322 320  
323 321 h = (gf_internal_t *) gf->scratch;
324   - ppr = h->prim_poly;
325 322  
326 323 /* Allen: set leading one of primitive polynomial */
327 324  
328   - ppl = 1;
329   -
330 325 a = a64;
331 326 bl = 0;
332 327 br = b64;
... ...
src/gf_w8.c
... ... @@ -1209,9 +1209,10 @@ int gf_w8_table_init(gf_t *gf)
1209 1209  
1210 1210 h = (gf_internal_t *) gf->scratch;
1211 1211  
1212   - issse = 0;
1213 1212 #ifdef INTEL_SSSE3
1214 1213 issse = 1;
  1214 +#else
  1215 + issse = 0;
1215 1216 #endif
1216 1217  
1217 1218 if (h->mult_type == GF_MULT_DEFAULT && issse) {
... ...
test/gf_unit.c
... ... @@ -141,15 +141,12 @@ int main(int argc, char **argv)
141 141 if (!gf_init_hard(&gf_def, w, GF_MULT_DEFAULT, GF_REGION_DEFAULT, GF_DIVIDE_DEFAULT,
142 142 (h->mult_type != GF_MULT_COMPOSITE) ? h->prim_poly : 0, 0, 0, NULL, NULL))
143 143 problem("No default for this value of w");
  144 +
144 145 if (w == 4) {
145 146 mult4 = gf_w4_get_mult_table(&gf);
146   - }
147   -
148   - if (w == 8) {
  147 + } else if (w == 8) {
149 148 mult8 = gf_w8_get_mult_table(&gf);
150   - }
151   -
152   - if (w == 16) {
  149 + } else if (w == 16) {
153 150 log16 = gf_w16_get_log_table(&gf);
154 151 alog16 = gf_w16_get_mult_alog_table(&gf);
155 152 }
... ... @@ -308,7 +305,6 @@ int main(int argc, char **argv)
308 305 gf_general_val_to_s(c, w, cs, 1);
309 306 printf("Error in single multiplication (all numbers in hex):\n\n");
310 307 printf(" gf.multiply(gf, %s, %s) = %s, which is clearly wrong.\n", as, bs, cs);
311   -;
312 308 exit(1);
313 309 }
314 310 }
... ... @@ -422,5 +418,15 @@ int main(int argc, char **argv)
422 418 gf_general_do_region_check(&gf, a, rc+s_start, rd+d_start, target+d_start, bytes, xor);
423 419 }
424 420 }
  421 +
  422 + free(a);
  423 + free(b);
  424 + free(c);
  425 + free(d);
  426 + free(ra);
  427 + free(rb);
  428 + free(rc);
  429 + free(rd);
  430 +
425 431 return 0;
426 432 }
... ...
tools/gf_inline_time.c
... ... @@ -116,8 +116,7 @@ int main(int argc, char **argv)
116 116 printf("Inline mult: %10.6lf s Mops: %10.3lf %10.3lf Mega-ops/s\n",
117 117 elapsed, dnum/1024.0/1024.0, dnum/1024.0/1024.0/elapsed);
118 118  
119   - }
120   - if (w == 8) {
  119 + } else if (w == 8) {
121 120 mult8 = gf_w8_get_mult_table(&gf);
122 121 if (mult8 == NULL) {
123 122 printf("Couldn't get inline multiplication table.\n");
... ... @@ -139,8 +138,7 @@ int main(int argc, char **argv)
139 138 }
140 139 printf("Inline mult: %10.6lf s Mops: %10.3lf %10.3lf Mega-ops/s\n",
141 140 elapsed, dnum/1024.0/1024.0, dnum/1024.0/1024.0/elapsed);
142   - }
143   - if (w == 16) {
  141 + } else if (w == 16) {
144 142 log16 = gf_w16_get_log_table(&gf);
145 143 alog16 = gf_w16_get_mult_alog_table(&gf);
146 144 if (log16 == NULL) {
... ... @@ -164,5 +162,9 @@ int main(int argc, char **argv)
164 162 printf("Inline mult: %10.6lf s Mops: %10.3lf %10.3lf Mega-ops/s\n",
165 163 elapsed, dnum/1024.0/1024.0, dnum/1024.0/1024.0/elapsed);
166 164 }
  165 + free (ra);
  166 + free (rb);
  167 + free (ra16);
  168 + free (rb16);
167 169 return 0;
168 170 }
... ...
tools/gf_poly.c
... ... @@ -52,6 +52,7 @@
52 52 #include <stdio.h>
53 53 #include <stdlib.h>
54 54 #include <string.h>
  55 +#include <assert.h>
55 56  
56 57 char *BM = "Bad Method: ";
57 58  
... ... @@ -203,9 +204,14 @@ int main(int argc, char **argv)
203 204 sprintf(string, "Argument '%s' not in proper format of power:coefficient\n", argv[i]);
204 205 usage(string);
205 206 }
206   - if (power < 0) usage("Can't have negative powers\n");
207   - if (power > n) n = power;
  207 + if (power < 0) {
  208 + usage("Can't have negative powers\n");
  209 + } else {
  210 + n = power;
  211 + }
208 212 }
  213 + // in case the for-loop header fails
  214 + assert (n >= 0);
209 215  
210 216 poly = (gf_general_t *) malloc(sizeof(gf_general_t)*(n+1));
211 217 for (i = 0; i <= n; i++) gf_general_set_zero(poly+i, w);
... ...
tools/gf_time.c
... ... @@ -188,8 +188,6 @@ int main(int argc, char **argv)
188 188 if (tmethods[(int)test] == NULL) {
189 189 printf("No %s method.\n", tstrings[(int)test]);
190 190 } else {
191   - elapsed = 0;
192   -
193 191 if (test == '0') gf_general_set_zero(&a, w);
194 192 if (test == '1') gf_general_set_one(&a, w);
195 193 if (test == '2') gf_general_set_two(&a, w);
... ...