Skip to content

Commit 6bf5408

Browse files
committed
add a static_assert to experimental montgomery two pow
1 parent fd1060d commit 6bf5408

File tree

2 files changed

+13
-12
lines changed

2 files changed

+13
-12
lines changed

montgomery_arithmetic/include/hurchalla/montgomery_arithmetic/detail/experimental/montgomery_two_pow/experimental_montgomery_two_pow.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4183,6 +4183,7 @@ if HURCHALLA_CPP17_CONSTEXPR (CODE_SECTION == 0) {
41834183
}
41844184

41854185
while (shift >= P) {
4186+
static_assert(P > 0, "");
41864187
shift -= P;
41874188

41884189
if HURCHALLA_CPP17_CONSTEXPR (USE_SQUARING_VALUE_OPTIMIZATION) {

montgomery_arithmetic/include/hurchalla/montgomery_arithmetic/detail/experimental/montgomery_two_pow/testbench_montgomery_two_pow.cpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -941,11 +941,11 @@ using namespace hurchalla;
941941
constexpr int NUM_TEST_REPETITIONS = 10;
942942

943943

944-
#if 1
944+
#if 0
945945
std::cout << "\nbegin benchmarks - array two_pow\n";
946946

947947
// warm up call
948-
bench_array_two_pow<5, 8, 8, MontType, false>(static_cast<U>(maxU - range), range, dummy, max_modulus_bits_reduce, seed, exponent_bits_reduce);
948+
bench_array_two_pow<1, 8, 8, MontType, false>(static_cast<U>(maxU - range), range, dummy, max_modulus_bits_reduce, seed, exponent_bits_reduce);
949949

950950
// format is bench_array_two_pow<TABLE_BITS, CODE_SECTION, ARRAY_SIZE, MontType, USE_SQUARING_VALUE_OPTIMIZATION>(...)
951951

@@ -955,17 +955,17 @@ using namespace hurchalla;
955955
for (size_t j=0; j<timingA[i].size(); ++j) {
956956

957957
timingA[i][j].push_back(
958-
bench_array_two_pow<0, 30, 3, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
958+
bench_array_two_pow<1, 8, 3, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
959959
timingA[i][j].push_back(
960-
bench_array_two_pow<0, 30, 4, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
960+
bench_array_two_pow<1, 8, 4, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
961961
timingA[i][j].push_back(
962-
bench_array_two_pow<0, 30, 5, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
962+
bench_array_two_pow<1, 8, 5, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
963963
timingA[i][j].push_back(
964-
bench_array_two_pow<0, 30, 6, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
964+
bench_array_two_pow<1, 8, 6, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
965965
timingA[i][j].push_back(
966-
bench_array_two_pow<0, 30, 7, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
966+
bench_array_two_pow<1, 8, 7, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
967967
timingA[i][j].push_back(
968-
bench_array_two_pow<0, 30, 8, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
968+
bench_array_two_pow<1, 8, 8, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
969969

970970

971971
#if 0
@@ -1779,12 +1779,12 @@ std::cout << "Timings By Test Type:\n";
17791779

17801780

17811781

1782-
#if 0
1782+
#if 1
17831783
std::cout << "\nbegin benchmarks - scalar two_pow\n";
17841784

17851785
// warm up to get cpu boost (or throttle) going
1786-
for (size_t i=0; i<2; ++i)
1787-
bench_range<0, true , 0, MontType, false>(static_cast<U>(maxU - range), range, dummy, max_modulus_bits_reduce, seed, exponent_bits_reduce);
1786+
for (size_t i=0; i<1; ++i)
1787+
bench_range<1, false, 0, MontType, false>(static_cast<U>(maxU - range), range, dummy, max_modulus_bits_reduce, seed, exponent_bits_reduce);
17881788

17891789
// std::array<std::vector<Timing>, 4> timings;
17901790

@@ -1796,7 +1796,7 @@ std::cout << "Timings By Test Type:\n";
17961796
// format is bench_range<TABLE_BITS, USE_SLIDING_WINDOW_OPTIMIZATION, CODE_SECTION,
17971797
// MontType, USE_SQUARING_VALUE_OPTIMIZATION>
17981798
timings[i][j].push_back(
1799-
bench_range<0, false, 34, MontType, true>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
1799+
bench_range<1, false, 0, MontType, false>(static_cast<U>(maxU - range), range, dummy, mmbr[i], seed, ebr[i]));
18001800

18011801
#if 0
18021802
// This is a copy/paste of the "best of best" code sections from further below (nothing is new here).

0 commit comments

Comments
 (0)