aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMITSUNARI Shigeo <herumi@nifty.com>2017-01-27 08:52:16 +0800
committerMITSUNARI Shigeo <herumi@nifty.com>2017-01-27 08:52:41 +0800
commit74975e85c83c98f67b4a954764fe5d2de726a822 (patch)
tree0b8bc6569b8f4b0177db690dcd4bf758a695a89d
parent33ec5bad907b2236ee6a97223a686c0257a3b64b (diff)
downloaddexon-mcl-74975e85c83c98f67b4a954764fe5d2de726a822.tar.gz
dexon-mcl-74975e85c83c98f67b4a954764fe5d2de726a822.tar.zst
dexon-mcl-74975e85c83c98f67b4a954764fe5d2de726a822.zip
change selection of Mont and SqrMont for bitSize == 1024
-rw-r--r--src/fp.cpp5
-rw-r--r--src/low_func.hpp4
-rw-r--r--src/low_func_llvm.hpp8
-rw-r--r--src/proto.hpp3
-rw-r--r--test/fp_tower_test.cpp8
5 files changed, 18 insertions, 10 deletions
diff --git a/src/fp.cpp b/src/fp.cpp
index d00b99b..c1d3728 100644
--- a/src/fp.cpp
+++ b/src/fp.cpp
@@ -393,7 +393,7 @@ void Op::init(const std::string& mstr, size_t maxBitSize, Mode mode)
case 7: setOp<7>(*this, mode); break;
case 8: setOp<8>(*this, mode); break;
case 9: setOp<9>(*this, mode); break; // 576 if 64-bit
-#if CYBOZU_OS_BIT == 32 || MCL_MAX_BIT_SIZE == 768
+#if CYBOZU_OS_BIT == 32 || MCL_MAX_BIT_SIZE >= 768
case 10: setOp<10>(*this, mode); break;
case 11: setOp<11>(*this, mode); break;
case 12: setOp<12>(*this, mode); break; // 768 if 64-bit
@@ -406,6 +406,9 @@ void Op::init(const std::string& mstr, size_t maxBitSize, Mode mode)
case 17: setOp<17>(*this, mode); break; // 544 if 32-bit
#endif
#if CYBOZU_OS_BIT == 64 && MCL_MAX_BIT_SIZE == 1024
+ case 13: setOp<13>(*this, mode); break;
+ case 14: setOp<14>(*this, mode); break;
+ case 15: setOp<15>(*this, mode); break;
case 16: setOp<16>(*this, mode); break;
#endif
default:
diff --git a/src/low_func.hpp b/src/low_func.hpp
index cc75464..fa340f1 100644
--- a/src/low_func.hpp
+++ b/src/low_func.hpp
@@ -513,7 +513,7 @@ template<size_t N, bool isFullBit, class Tag = Gtag>
struct Mont {
static inline void func(Unit *z, const Unit *x, const Unit *y, const Unit *p)
{
-#if CYBOZU_OS_BIT == 32 // check speed
+#if MCL_MAX_BIT_SIZE == 1024 || CYBOZU_OS_BIT == 32 // check speed
Unit xy[N * 2];
MulPre<N, Tag>::f(xy, x, y);
MontRed<N, Tag>::f(z, xy, p);
@@ -597,7 +597,7 @@ template<size_t N, bool isFullBit, class Tag = Gtag>
struct SqrMont {
static inline void func(Unit *y, const Unit *x, const Unit *p)
{
-#if CYBOZU_OS_BIT == 32 // check speed
+#if MCL_MAX_BIT_SIZE == 1024 || CYBOZU_OS_BIT == 32 // check speed
Unit xx[N * 2];
SqrPre<N, Tag>::f(xx, x);
MontRed<N, Tag>::f(y, xx, p);
diff --git a/src/low_func_llvm.hpp b/src/low_func_llvm.hpp
index fe48853..294c022 100644
--- a/src/low_func_llvm.hpp
+++ b/src/low_func_llvm.hpp
@@ -59,7 +59,7 @@ MCL_DEF_LLVM_FUNC(6)
MCL_DEF_LLVM_FUNC(7)
MCL_DEF_LLVM_FUNC(8)
MCL_DEF_LLVM_FUNC(9)
-#if CYBOZU_OS_BIT == 32 || MCL_MAX_BIT_SIZE == 768
+#if CYBOZU_OS_BIT == 32 || MCL_MAX_BIT_SIZE >= 768
MCL_DEF_LLVM_FUNC(10)
MCL_DEF_LLVM_FUNC(11)
MCL_DEF_LLVM_FUNC(12)
@@ -72,7 +72,11 @@ MCL_DEF_LLVM_FUNC(16)
MCL_DEF_LLVM_FUNC(17)
#endif
#if CYBOZU_OS_BIT == 64 && MCL_MAX_BIT_SIZE == 1024
-MCL_DEF_LLVM_FUNC(16)
+MCL_DEF_LLVM_FUNC(14)
+//MCL_DEF_LLVM_FUNC(16)
+/// QQQ : check speed
+template<>const void3u MontRed<16, Ltag>::f = &mcl_fp_montRed16L;
+template<>const void3u MontRed<16, LBMI2tag>::f = &mcl_fp_montRed16Lbmi2;
#endif
} } // mcl::fp
diff --git a/src/proto.hpp b/src/proto.hpp
index c11c8ec..ea78a4b 100644
--- a/src/proto.hpp
+++ b/src/proto.hpp
@@ -46,7 +46,7 @@ MCL_FP_DEF_FUNC(6)
MCL_FP_DEF_FUNC(7)
MCL_FP_DEF_FUNC(8)
MCL_FP_DEF_FUNC(9)
-#if CYBOZU_OS_BIT == 32 || MCL_MAX_BIT_SIZE == 768
+#if CYBOZU_OS_BIT == 32 || MCL_MAX_BIT_SIZE >= 768
MCL_FP_DEF_FUNC(10)
MCL_FP_DEF_FUNC(11)
MCL_FP_DEF_FUNC(12)
@@ -59,6 +59,7 @@ MCL_FP_DEF_FUNC(16)
MCL_FP_DEF_FUNC(17)
#endif
#if CYBOZU_OS_BIT == 64 && MCL_MAX_BIT_SIZE == 1024
+MCL_FP_DEF_FUNC(14)
MCL_FP_DEF_FUNC(16)
#endif
diff --git a/test/fp_tower_test.cpp b/test/fp_tower_test.cpp
index b249bf3..ab62235 100644
--- a/test/fp_tower_test.cpp
+++ b/test/fp_tower_test.cpp
@@ -7,8 +7,8 @@
#include <mcl/fp.hpp>
#include <mcl/fp_tower.hpp>
-#if MCL_MAX_BIT_SIZE == 768
-typedef mcl::FpT<mcl::FpTag, 768> Fp;
+#if MCL_MAX_BIT_SIZE >= 768
+typedef mcl::FpT<mcl::FpTag, MCL_MAX_BIT_SIZE> Fp;
#else
typedef mcl::FpT<mcl::FpTag, 256> Fp;
#endif
@@ -23,7 +23,7 @@ void testFp2()
{
using namespace mcl;
puts(__FUNCTION__);
-#if MCL_MAX_BIT_SIZE != 768
+#if MCL_MAX_BIT_SIZE < 768
CYBOZU_TEST_EQUAL(sizeof(Fp), 32);
CYBOZU_TEST_EQUAL(sizeof(Fp2), 32 * 2);
CYBOZU_TEST_EQUAL(sizeof(Fp6), 32 * 6);
@@ -413,7 +413,7 @@ void testAll()
"0x7523648240000001ba344d80000000086121000000000013a700000000000017",
"0x800000000000000000000000000000000000000000000000000000000000005f",
"0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff43", // max prime
-#if MCL_MAX_BIT_SIZE == 768
+#if MCL_MAX_BIT_SIZE >= 768
"776259046150354467574489744231251277628443008558348305569526019013025476343188443165439204414323238975243865348565536603085790022057407195722143637520590569602227488010424952775132642815799222412631499596858234375446423426908029627",
#endif
};