Switched to heuristic GPU for a better performance than the standard one.
This commit is contained in:
1 parent
b83bddf49a
commit
0850227881
2 files changed
+49
-40
No files matched your search
@@ -1078,6 +1078,8 @@ internal static partial class PrimeOrderCalculator
|
||||
Stack<ulong>? compositeStack = null;
|
||||
PartialFactorResult result;
|
||||
PrimeTester primeTester = PrimeTester.Exclusive;
|
||||
CancellationToken ct = CancellationToken.None;
|
||||
HeuristicPrimeTester? tester = _tester ??= new();
|
||||
|
||||
if (!gpuFactored)
|
||||
{
|
||||
@@ -1150,7 +1152,7 @@ internal static partial class PrimeOrderCalculator
|
||||
// Console.WriteLine($"Partial factor hits {Volatile.Read(ref _partialFactorHits)}");
|
||||
|
||||
// bool isPrime = PrimeTester.IsPrimeCpu(composite, CancellationToken.None);
|
||||
bool isPrime = PrimeTester.IsPrimeGpu(composite);
|
||||
bool isPrime = tester.IsPrimeGpu(composite);
|
||||
// bool isPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(composite);
|
||||
|
||||
if (isPrime)
|
||||
@@ -1218,7 +1220,7 @@ internal static partial class PrimeOrderCalculator
|
||||
// Console.WriteLine($"Partial factor pending hits {Volatile.Read(ref _partialFactorPendingHits)}");
|
||||
|
||||
// bool isPrime = PrimeTester.IsPrimeCpu(composite, CancellationToken.None);
|
||||
bool isPrime = PrimeTester.IsPrimeGpu(composite);
|
||||
bool isPrime = tester.IsPrimeGpu(composite);
|
||||
// bool isPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(composite);
|
||||
|
||||
entry = entry.WithPrimality(isPrime);
|
||||
@@ -1255,7 +1257,7 @@ internal static partial class PrimeOrderCalculator
|
||||
// Atomic.Add(ref _partialFactorCofactorHits, 1UL);
|
||||
// Console.WriteLine($"Partial factor cofactor hits {Volatile.Read(ref _partialFactorCofactorHits)}");
|
||||
|
||||
cofactorIsPrime = PrimeTester.IsPrimeCpu(cofactor, CancellationToken.None);
|
||||
cofactorIsPrime = tester.IsPrimeGpu(cofactor);
|
||||
// cofactorIsPrime = PrimeTester.IsPrimeGpu(cofactor);
|
||||
// cofactorIsPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(cofactor);
|
||||
}
|
||||
@@ -1777,9 +1779,11 @@ internal static partial class PrimeOrderCalculator
|
||||
{
|
||||
FactorCompletely(value, counts, knownComposite: false);
|
||||
}
|
||||
|
||||
|
||||
// private static ulong _factorCompletelyHits;
|
||||
// private static ulong _factorCompletelyPollardRhoHits;
|
||||
[ThreadStatic]
|
||||
private static HeuristicPrimeTester? _tester;
|
||||
|
||||
private static void FactorCompletely(ulong value, Dictionary<ulong, int> counts, bool knownComposite)
|
||||
{
|
||||
@@ -1790,10 +1794,10 @@ internal static partial class PrimeOrderCalculator
|
||||
|
||||
// Atomic.Add(ref _factorCompletelyHits, 1UL);
|
||||
// Console.WriteLine($"Factor completely hits {Volatile.Read(ref _factorCompletelyHits)}");
|
||||
// PrimeTester primeTester = PrimeTester.Exclusive;
|
||||
HeuristicPrimeTester tester = _tester ??= new();
|
||||
|
||||
// bool isPrime = primeTester.HeuristicIsPrimeGpu(value);
|
||||
bool isPrime = PrimeTester.IsPrimeCpu(value, CancellationToken.None);
|
||||
bool isPrime = tester.IsPrimeGpu(value);
|
||||
// bool isPrime = PrimeTester.IsPrimeGpu(value);
|
||||
// bool isPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(value);
|
||||
if (!knownComposite && isPrime)
|
||||
@@ -1809,7 +1813,7 @@ internal static partial class PrimeOrderCalculator
|
||||
// Console.WriteLine($"Factor completely after PollardRho hits {Volatile.Read(ref _factorCompletelyPollardRhoHits)}");
|
||||
|
||||
// isPrime = primeTester.HeuristicIsPrimeGpu(factor);
|
||||
isPrime = PrimeTester.IsPrimeCpu(factor, CancellationToken.None);
|
||||
isPrime = tester.IsPrimeGpu(factor);
|
||||
// isPrime = PrimeTester.IsPrimeGpu(factor);
|
||||
// isPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(factor);
|
||||
if (isPrime)
|
||||
@@ -1846,7 +1850,7 @@ internal static partial class PrimeOrderCalculator
|
||||
// Atomic.Add(ref _partialFactorCofactorHits, 1UL);
|
||||
// Console.WriteLine($"Partial factor cofactor hits {Volatile.Read(ref _partialFactorCofactorHits)}");
|
||||
|
||||
isPrime = PrimeTester.IsPrimeCpu(quotient, CancellationToken.None);
|
||||
isPrime = tester.IsPrimeGpu(quotient);
|
||||
// isPrime = PrimeTester.IsPrimeGpu(quotient);
|
||||
// isPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(quotient);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user