PrimeOrderCalculatorAccelerator.Rent is now created outside of the loops and re-used for all calculations.
This commit is contained in:
1 parent
57a50e2a37
commit
b9ca95bf8c
53 files changed
+4639
-4229
No files matched your search
@@ -168,15 +168,15 @@ public sealed class HeuristicCombinedPrimeTester
|
||||
return HeuristicTrialDivisionCpu(n, maxDivisorSquare, nMod10);
|
||||
}
|
||||
|
||||
public static bool IsPrimeGpu(ulong n)
|
||||
{
|
||||
byte nMod10 = (byte)n.Mod10();
|
||||
ulong maxDivisorSquare = ComputeHeuristicDivisorSquareLimit(n);
|
||||
var gpu = PrimeOrderCalculatorAccelerator.Rent(1);
|
||||
bool isPrime = IsPrimeGpu(gpu, n, maxDivisorSquare, nMod10);
|
||||
PrimeOrderCalculatorAccelerator.Return(gpu);
|
||||
return isPrime;
|
||||
}
|
||||
// public static bool IsPrimeGpu(ulong n)
|
||||
// {
|
||||
// byte nMod10 = (byte)n.Mod10();
|
||||
// ulong maxDivisorSquare = ComputeHeuristicDivisorSquareLimit(n);
|
||||
// var gpu = PrimeOrderCalculatorAccelerator.Rent(1);
|
||||
// bool isPrime = IsPrimeGpu(gpu, n, maxDivisorSquare, nMod10);
|
||||
// PrimeOrderCalculatorAccelerator.Return(gpu);
|
||||
// return isPrime;
|
||||
// }
|
||||
|
||||
public static bool IsPrimeGpu(PrimeOrderCalculatorAccelerator gpu, ulong n)
|
||||
{
|
||||
@@ -520,7 +520,7 @@ public sealed class HeuristicCombinedPrimeTester
|
||||
}
|
||||
|
||||
primeOrderFailed = primeOrderFailedLocal || !trySuccess || computedCycle == 0UL;
|
||||
ulong resolvedCycle = MersenneDivisorCycles.CalculateCycleLength(divisor, divisorData, skipPrimeOrderHeuristic: primeOrderFailed);
|
||||
ulong resolvedCycle = MersenneDivisorCycles.CalculateCycleLength(gpu, divisor, divisorData, skipPrimeOrderHeuristic: primeOrderFailed);
|
||||
cycleFromHint = false;
|
||||
cycleComputed = resolvedCycle != 0UL;
|
||||
return resolvedCycle;
|
||||
|
||||
Reference in new issue
Block a user