diff options
author | MITSUNARI Shigeo <herumi@nifty.com> | 2016-11-01 08:43:52 +0800 |
---|---|---|
committer | MITSUNARI Shigeo <herumi@nifty.com> | 2016-11-01 08:43:52 +0800 |
commit | 58f2467b4dc946a90756f87aa64b7dfaf00cf6e7 (patch) | |
tree | 5e17d9c26df215789227c8db48efe8d9f2022e50 | |
parent | 6a5dfe97544ef719ec27c6edb386b8d67aeaf3af (diff) | |
download | dexon-mcl-58f2467b4dc946a90756f87aa64b7dfaf00cf6e7.tar.gz dexon-mcl-58f2467b4dc946a90756f87aa64b7dfaf00cf6e7.tar.zst dexon-mcl-58f2467b4dc946a90756f87aa64b7dfaf00cf6e7.zip |
use karatsuba if llvm
-rw-r--r-- | misc/karatsuba.cpp | 4 | ||||
-rw-r--r-- | src/fp_llvm.hpp | 5 | ||||
-rw-r--r-- | src/fp_proto.hpp | 6 |
3 files changed, 12 insertions, 3 deletions
diff --git a/misc/karatsuba.cpp b/misc/karatsuba.cpp index b62b3b6..fb04ed9 100644 --- a/misc/karatsuba.cpp +++ b/misc/karatsuba.cpp @@ -26,11 +26,11 @@ void dump(const Unit *x, size_t N) void gggKara(uint64_t *z, const uint64_t *x, const uint64_t *y) { - MulPre<6, Gtag>::karatsuba(z, x, y); + MulPre<8, Gtag>::f(z, x, y); } void gggLLVM(uint64_t *z, const uint64_t *x, const uint64_t *y) { - MulPre<6, Ltag>::f(z, x, y); + MulPre<8, Ltag>::f(z, x, y); } template<size_t N> diff --git a/src/fp_llvm.hpp b/src/fp_llvm.hpp index cc28753..7c295d3 100644 --- a/src/fp_llvm.hpp +++ b/src/fp_llvm.hpp @@ -2,6 +2,11 @@ namespace mcl { namespace fp { +template<> +struct EnableKaratsuba<Ltag> { + static const size_t minN = 8; /* use karatsuba if N >= 8 */ +}; + #define MCL_DEF_LLVM_FUNC(n) \ template<>const u3u AddPre<n, Ltag>::f = &mcl_fp_addPre ## n ## L; \ template<>const u3u SubPre<n, Ltag>::f = &mcl_fp_subPre ## n ## L; \ diff --git a/src/fp_proto.hpp b/src/fp_proto.hpp index d053d29..73fc272 100644 --- a/src/fp_proto.hpp +++ b/src/fp_proto.hpp @@ -111,6 +111,10 @@ struct MulPreCore { template<size_t N, class Tag> const void3u MulPreCore<N, Tag>::f = MulPreCore<N, Tag>::func; +template<class Tag = Gtag> +struct EnableKaratsuba { + static const size_t minN = 100; /* always use mpn_mul_n for Gtag */ +}; template<size_t N, class Tag = Gtag> struct MulPre { /* @@ -147,7 +151,7 @@ struct MulPre { static inline void func(Unit *z, const Unit *x, const Unit *y) { #if 1 - if (N >= 8 && (N % 2) == 0) { + if (N >= EnableKaratsuba<Tag>::minN && (N % 2) == 0) { karatsuba(z, x, y); return; } |