From 1317ddc6a7dd39febaa919a06f10ff07ce7edcb1 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 8 Mar 2021 09:52:34 +0900 Subject: [PATCH 1/7] [java] add test to main.yml --- .github/workflows/main.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 575892f..1aa177a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -12,3 +12,5 @@ jobs: - run: make test_ci DEBUG=1 -j3 CXX=clang++ - run: make clean - run: make test_go + - run: sudo apt install openjdk-8-jdk + - run: make -C ffi/java test JAVA_INC=-I/usr/lib/jvm/java-8-openjdk-amd64/include From fd4b408e521451dd266fa797c526100b9f58cfb0 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 8 Mar 2021 10:19:15 +0900 Subject: [PATCH 2/7] [ci] show dmesg if error --- .github/workflows/main.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 1aa177a..201202a 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -7,7 +7,8 @@ jobs: runs-on: ubuntu-latest steps: - uses: actions/checkout@v2 - - run: make test_ci DEBUG=1 -j3 + - run: lscpu + - run: make test_ci DEBUG=1 -j3 || dmesg | tail - run: make clean - run: make test_ci DEBUG=1 -j3 CXX=clang++ - run: make clean From 922a935e266de6d6e7581cf199055d6c79fc57b7 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 8 Mar 2021 16:57:07 +0900 Subject: [PATCH 3/7] fix crash on haswell --- src/fp_generator.hpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/fp_generator.hpp b/src/fp_generator.hpp index ecd022c..45097f4 100644 --- a/src/fp_generator.hpp +++ b/src/fp_generator.hpp @@ -1095,7 +1095,7 @@ private: */ void gen_fpDbl_mod4(const Reg64& z, const Reg64& xy, const Pack& t) { - if (!isFullBit_) { + if (!isFullBit_ && useMulx_ && useAdx_) { gen_fpDbl_mod4NF(z, xy, t); return; } @@ -2547,7 +2547,7 @@ private: } void gen_fpDbl_mulPre(void3u& f) { - if (!(useMulx_ && useAdx_)) return; + if (!useMulx_ || (pn_ == 6 && !useAdx_)) return; void3u func = getCurr(); switch (pn_) { case 2: From f52f4668ac334345d85488e012530e17a3f94522 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 8 Mar 2021 17:04:24 +0900 Subject: [PATCH 4/7] remove warnings --- include/mcl/gmp_util.hpp | 4 ++-- misc/snark-p.py | 5 +++++ src/fp_generator.hpp | 20 ++++++++++---------- test/bench.hpp | 22 ++++++++++++---------- 4 files changed, 29 insertions(+), 22 deletions(-) diff --git a/include/mcl/gmp_util.hpp b/include/mcl/gmp_util.hpp index c5e9700..f3fcfa3 100644 --- a/include/mcl/gmp_util.hpp +++ b/include/mcl/gmp_util.hpp @@ -951,7 +951,7 @@ struct SmallModp { static const size_t maxTblSize = (MCL_MAX_BIT_SIZE + unitBitSize - 1) / unitBitSize + 1; static const size_t maxMulN = 9; static const size_t pMulTblN = maxMulN + 1; - int N_; + uint32_t N_; uint32_t shiftL_; uint32_t shiftR_; uint32_t maxIdx_; @@ -997,7 +997,7 @@ struct SmallModp { void init(const mpz_class& p) { size_t pBitSize = mcl::gmp::getBitSize(p); - N_ = (pBitSize + unitBitSize - 1) / unitBitSize; + N_ = uint32_t((pBitSize + unitBitSize - 1) / unitBitSize); shiftR_ = (pBitSize - 1) % unitBitSize; shiftL_ = unitBitSize - shiftR_; mpz_class t = 0; diff --git a/misc/snark-p.py b/misc/snark-p.py index 8168f3b..cbb7f5a 100644 --- a/misc/snark-p.py +++ b/misc/snark-p.py @@ -11,3 +11,8 @@ print("maxarg") for i in range(16): print(i, maxarg(i << 253)) + +x=0x2c130429c1d4802eb8703197d038ebd5109f96aee333bd027963094f5bb33ad + +y = x * 9 +print(hex(y)) diff --git a/src/fp_generator.hpp b/src/fp_generator.hpp index 45097f4..d420980 100644 --- a/src/fp_generator.hpp +++ b/src/fp_generator.hpp @@ -3656,25 +3656,25 @@ private: } { - Pack t = sf.t; + Pack t2 = sf.t; if (pn_ == 4) { - t = t.sub(0, pn_ * 2); + t2 = t2.sub(0, pn_ * 2); } else if (pn_ == 6) { - t.append(gp1); - t.append(gp2); + t2.append(gp1); + t2.append(gp2); } - assert((int)t.size() == pn_ * 2); + assert((int)t2.size() == pn_ * 2); mov(gp0, ptr [z]); - load_rm(t, gp0 + FpByte_ * 2); - sub_rm(t, gp0); // d1 -= d0 - sub_rm(t, (RegExp)d2); // d1 -= d2 - store_mr(gp0 + FpByte_ * 2, t); + load_rm(t2, gp0 + FpByte_ * 2); + sub_rm(t2, gp0); // d1 -= d0 + sub_rm(t2, (RegExp)d2); // d1 -= d2 + store_mr(gp0 + FpByte_ * 2, t2); gen_raw_sub(gp0, gp0, d2, rax, pn_); const RegExp& d0H = gp0 + pn_ * 8; const RegExp& d2H = (RegExp)d2 + pn_ * 8; - gen_raw_fp_sub(d0H, d0H, d2H, t, true); + gen_raw_fp_sub(d0H, d0H, d2H, t2, true); } add(rsp, SS); ret(); diff --git a/test/bench.hpp b/test/bench.hpp index 11ced31..d407bc7 100644 --- a/test/bench.hpp +++ b/test/bench.hpp @@ -85,16 +85,18 @@ void testBench(const G1& P, const G2& Q) const int C3 = 100000; #if 1 const int C2 = 3000; - mpz_class a = x.getMpz(); - CYBOZU_BENCH_C("G1::mulCT ", C, G1::mulCT, Pa, P, a); - CYBOZU_BENCH_C("G1::mul ", C, G1::mul, Pa, Pa, a); - CYBOZU_BENCH_C("G1::add ", C, G1::add, Pa, Pa, P); - CYBOZU_BENCH_C("G1::dbl ", C, G1::dbl, Pa, Pa); - CYBOZU_BENCH_C("G2::mulCT ", C, G2::mulCT, Qa, Q, a); - CYBOZU_BENCH_C("G2::mul ", C, G2::mul, Qa, Qa, a); - CYBOZU_BENCH_C("G2::add ", C, G2::add, Qa, Qa, Q); - CYBOZU_BENCH_C("G2::dbl ", C, G2::dbl, Qa, Qa); - CYBOZU_BENCH_C("GT::pow ", C, GT::pow, e1, e1, a); + { + mpz_class a = x.getMpz(); + CYBOZU_BENCH_C("G1::mulCT ", C, G1::mulCT, Pa, P, a); + CYBOZU_BENCH_C("G1::mul ", C, G1::mul, Pa, Pa, a); + CYBOZU_BENCH_C("G1::add ", C, G1::add, Pa, Pa, P); + CYBOZU_BENCH_C("G1::dbl ", C, G1::dbl, Pa, Pa); + CYBOZU_BENCH_C("G2::mulCT ", C, G2::mulCT, Qa, Q, a); + CYBOZU_BENCH_C("G2::mul ", C, G2::mul, Qa, Qa, a); + CYBOZU_BENCH_C("G2::add ", C, G2::add, Qa, Qa, Q); + CYBOZU_BENCH_C("G2::dbl ", C, G2::dbl, Qa, Qa); + CYBOZU_BENCH_C("GT::pow ", C, GT::pow, e1, e1, a); + } // CYBOZU_BENCH_C("GT::powGLV ", C, BN::param.glv2.pow, e1, e1, a); G1 PP; G2 QQ; From 01c81c60ca97161dc718832e6336cb3f04f7f261 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 8 Mar 2021 17:08:32 +0900 Subject: [PATCH 5/7] ci test on haswell --- .github/workflows/main.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 201202a..5c2aecc 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -15,3 +15,6 @@ jobs: - run: make test_go - run: sudo apt install openjdk-8-jdk - run: make -C ffi/java test JAVA_INC=-I/usr/lib/jvm/java-8-openjdk-amd64/include + - run: wget https://software.intel.com/content/dam/develop/external/us/en/documents/downloads/sde-external-8.63.0-2021-01-18-lin.tar.bz2 + - run: bzip2 -dc sde-external-8.63.0-2021-01-18-lin.tar.bz2 | tar xvf - + - run: sde-external-8.63.0-2021-01-18-lin/sde64 -hsw -- bin/bn_test.exe From 7d0087df69fa4a2db402f903f990a7013f81a038 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 8 Mar 2021 17:24:27 +0900 Subject: [PATCH 6/7] fix main.yml --- .github/workflows/main.yml | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 5c2aecc..29ef88e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -8,13 +8,15 @@ jobs: steps: - uses: actions/checkout@v2 - run: lscpu - - run: make test_ci DEBUG=1 -j3 || dmesg | tail + - run: wget https://software.intel.com/content/dam/develop/external/us/en/documents/downloads/sde-external-8.63.0-2021-01-18-lin.tar.bz2 + - run: bzip2 -dc sde-external-8.63.0-2021-01-18-lin.tar.bz2 | tar xvf - + - run: make bin/bn_test.exe -j4 + - run: sde-external-8.63.0-2021-01-18-lin/sde64 -hsw -- bin/bn_test.exe + - run: make clean + - run: make test_ci DEBUG=1 -j4 || dmesg | tail - run: make clean - - run: make test_ci DEBUG=1 -j3 CXX=clang++ + - run: make test_ci DEBUG=1 -j4 CXX=clang++ || dmesg | tail - run: make clean - run: make test_go - run: sudo apt install openjdk-8-jdk - run: make -C ffi/java test JAVA_INC=-I/usr/lib/jvm/java-8-openjdk-amd64/include - - run: wget https://software.intel.com/content/dam/develop/external/us/en/documents/downloads/sde-external-8.63.0-2021-01-18-lin.tar.bz2 - - run: bzip2 -dc sde-external-8.63.0-2021-01-18-lin.tar.bz2 | tar xvf - - - run: sde-external-8.63.0-2021-01-18-lin/sde64 -hsw -- bin/bn_test.exe From b28f6088116b0166ddfd042934973b81a573b2d1 Mon Sep 17 00:00:00 2001 From: MITSUNARI Shigeo Date: Mon, 8 Mar 2021 17:30:34 +0900 Subject: [PATCH 7/7] ci test of bn_test with DEBUG=1 --- .github/workflows/main.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 29ef88e..b7c5964 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -10,9 +10,8 @@ jobs: - run: lscpu - run: wget https://software.intel.com/content/dam/develop/external/us/en/documents/downloads/sde-external-8.63.0-2021-01-18-lin.tar.bz2 - run: bzip2 -dc sde-external-8.63.0-2021-01-18-lin.tar.bz2 | tar xvf - - - run: make bin/bn_test.exe -j4 + - run: make bin/bn_test.exe DEBUG=1 -j4 - run: sde-external-8.63.0-2021-01-18-lin/sde64 -hsw -- bin/bn_test.exe - - run: make clean - run: make test_ci DEBUG=1 -j4 || dmesg | tail - run: make clean - run: make test_ci DEBUG=1 -j4 CXX=clang++ || dmesg | tail