|
52 | 52 |
|
53 | 53 | #include <boost/dynamic_bitset.hpp> |
54 | 54 | #include <boost/multiprecision/cpp_int.hpp> |
| 55 | +#include <boost/random.hpp> |
55 | 56 |
|
56 | 57 | #include <pybind11/pybind11.h> |
57 | 58 | #include <pybind11/stl.h> |
@@ -764,8 +765,8 @@ struct Factorizer { |
764 | 765 | ForwardFn forwardFn; |
765 | 766 |
|
766 | 767 | Factorizer(const BigInteger &tfsqr, const BigInteger &tf, const BigInteger &tfsqrt, const BigInteger &range, size_t nodeCount, size_t nodeId, size_t w, size_t spl, size_t bsv, |
767 | | - size_t lm, const std::vector<size_t> &p, ForwardFn fn) |
768 | | - : dis(0U, p.size() - 1U), wordDis(0ULL, -1ULL), toFactorSqr(tfsqr), toFactor(tf), toFactorSqrt(tfsqrt), batchRange(range), batchNumber(0U), batchOffset(nodeId * range), |
| 768 | + size_t lm, size_t bn, const std::vector<size_t> &p, ForwardFn fn) |
| 769 | + : dis(0U, p.size() - 1U), wordDis(0ULL, -1ULL), toFactorSqr(tfsqr), toFactor(tf), toFactorSqrt(tfsqrt), batchRange(range), batchNumber(bn), batchOffset(nodeId * range), |
769 | 770 | batchTotal(nodeCount * range), wheelRadius(1U), wheelEntryCount(w), smoothBatchLimit(spl), batchSizeVariance(bsv), ladderMultiple(lm), isIncomplete(true), primes(p), forwardFn(fn) |
770 | 771 | { |
771 | 772 | for (size_t i = 0U; i < primes.size(); ++i) { |
@@ -805,7 +806,7 @@ struct Factorizer { |
805 | 806 | return 1U; |
806 | 807 | } |
807 | 808 |
|
808 | | - BigInteger monteCarlo(std::mt19937_64& gen) { |
| 809 | + BigInteger monteCarlo(boost::random::taus88& gen) { |
809 | 810 | // This function enters only once per thread. |
810 | 811 | size_t batchPower = 0U; |
811 | 812 |
|
@@ -1108,18 +1109,20 @@ std::string find_a_factor(std::string toFactorStr, size_t method, size_t nodeCou |
1108 | 1109 | gearFactorizationPrimes.clear(); |
1109 | 1110 |
|
1110 | 1111 | // Range per parallel node |
1111 | | - const BigInteger nodeRange = (((backward(SMALLEST_WHEEL)(fullMaxBase) + nodeCount - 1U) / nodeCount) + wheelEntryCount - 1U) / wheelEntryCount; |
| 1112 | + const auto backwardFn = backward(SMALLEST_WHEEL); |
| 1113 | + const BigInteger nodeRange = (((backwardFn(fullMaxBase) + nodeCount - 1U) / nodeCount) + wheelEntryCount - 1U) / wheelEntryCount; |
| 1114 | + const size_t batchStart = ((size_t)backwardFn(trialDivisionLevel)) / wheelEntryCount; |
1112 | 1115 | // This manages the work of all threads. |
1113 | 1116 | Factorizer worker(toFactor * toFactor, toFactor, fullMaxBase, |
1114 | 1117 | nodeRange, nodeCount, nodeId, |
1115 | 1118 | wheelEntryCount, (size_t)(batchSizeMultiplier * smoothPrimes.size() * log(smoothPrimes.size())), batchSizeVariance, |
1116 | | - ladderMultiple, smoothPrimes, forward(SMALLEST_WHEEL)); |
| 1119 | + ladderMultiple, batchStart, smoothPrimes, forward(SMALLEST_WHEEL)); |
1117 | 1120 | // Square of count of smooth primes, for FACTOR_FINDER batch multiplier base unit, was suggested by Lyra (OpenAI GPT) |
1118 | 1121 |
|
1119 | 1122 | std::vector<std::future<BigInteger>> futures; |
1120 | 1123 | futures.reserve(CpuCount); |
1121 | 1124 |
|
1122 | | - std::vector<std::mt19937_64> gen; |
| 1125 | + std::vector<boost::random::taus88> gen; |
1123 | 1126 | if (isFactorFinder) { |
1124 | 1127 | std::default_random_engine rng{}; |
1125 | 1128 | gen.reserve(CpuCount); |
|
0 commit comments