use textbook mul for N = 8

update-fork
MITSUNARI Shigeo 4 years ago
parent a9eef7fe49
commit 570396efd8
  1. 3
      src/gen.cpp
  2. 2
      test/llvm_test.cpp

@ -715,11 +715,12 @@ struct Code : public mcl::Generator {
Operand z = mul(x, y); Operand z = mul(x, y);
storeN(z, pz); storeN(z, pz);
ret(Void); ret(Void);
} else if (N >= 8 && (N % 2) == 0) { } else if (N > 8 && (N % 2) == 0) {
/* /*
W = 1 << half W = 1 << half
(aW + b)(cW + d) = acW^2 + (ad + bc)W + bd (aW + b)(cW + d) = acW^2 + (ad + bc)W + bd
ad + bc = (a + b)(c + d) - ac - bd ad + bc = (a + b)(c + d) - ac - bd
@note Karatsuba is slower for N = 8
*/ */
const int H = N / 2; const int H = N / 2;
const int half = bit / 2; const int half = bit / 2;

@ -70,7 +70,7 @@ void bench(Unit *x, Unit *y, const Unit *p)
{ {
printf("N=%zd\n", N); printf("N=%zd\n", N);
Unit xx[N * 2], yy[N * 2]; Unit xx[N * 2], yy[N * 2];
const int C = 1000; const int C = 10000;
CYBOZU_BENCH_C("mulPre", C, mulPre<N>, xx, x, y); CYBOZU_BENCH_C("mulPre", C, mulPre<N>, xx, x, y);
CYBOZU_BENCH_C("sqrPre", C, sqrPre<N>, yy, x); CYBOZU_BENCH_C("sqrPre", C, sqrPre<N>, yy, x);
CYBOZU_BENCH_C("mod ", C, mod<N>, yy, xx, p); CYBOZU_BENCH_C("mod ", C, mod<N>, yy, xx, p);

Loading…
Cancel
Save