Remove heuristic hooks from PrimeTester
This commit is contained in:
1 parent
c01abbd03a
commit
9bc8fd5043
2 files changed
-120
No files matched your search
@@ -103,108 +103,6 @@ public sealed class PrimeTester
|
||||
}
|
||||
|
||||
|
||||
internal readonly struct HeuristicDivisorCandidate
|
||||
{
|
||||
private readonly HeuristicPrimeTester.HeuristicDivisorCandidate _inner;
|
||||
|
||||
internal HeuristicDivisorCandidate(HeuristicPrimeTester.HeuristicDivisorCandidate inner)
|
||||
{
|
||||
_inner = inner;
|
||||
}
|
||||
|
||||
public ulong Value => _inner.Value;
|
||||
|
||||
public HeuristicPrimeTester.HeuristicDivisorGroup Group => _inner.Group;
|
||||
|
||||
public byte Ending => _inner.Ending;
|
||||
|
||||
public byte PriorityIndex => _inner.PriorityIndex;
|
||||
|
||||
public ushort WheelResidue => _inner.WheelResidue;
|
||||
|
||||
internal HeuristicPrimeTester.HeuristicDivisorCandidate AsHeuristic() => _inner;
|
||||
}
|
||||
|
||||
internal readonly struct HeuristicDivisorPreparation
|
||||
{
|
||||
private readonly HeuristicPrimeTester.HeuristicDivisorPreparation _inner;
|
||||
|
||||
internal HeuristicDivisorPreparation(HeuristicPrimeTester.HeuristicDivisorPreparation inner)
|
||||
{
|
||||
_inner = inner;
|
||||
}
|
||||
|
||||
public HeuristicDivisorCandidate Candidate => new(_inner.Candidate);
|
||||
|
||||
public MontgomeryDivisorData DivisorData => _inner.DivisorData;
|
||||
|
||||
public ulong CycleLengthHint => _inner.CycleLengthHint;
|
||||
|
||||
public bool HasCycleLengthHint => _inner.HasCycleLengthHint;
|
||||
|
||||
public bool RequiresCycleComputation => _inner.RequiresCycleComputation;
|
||||
|
||||
internal HeuristicPrimeTester.HeuristicDivisorPreparation AsHeuristic() => _inner;
|
||||
}
|
||||
|
||||
internal ref struct MersenneHeuristicDivisorEnumerator
|
||||
{
|
||||
private HeuristicPrimeTester.MersenneHeuristicDivisorEnumerator _inner;
|
||||
|
||||
public MersenneHeuristicDivisorEnumerator(ulong exponent, ulong maxDivisor)
|
||||
{
|
||||
_inner = HeuristicPrimeTester.CreateMersenneDivisorEnumerator(exponent, maxDivisor);
|
||||
}
|
||||
|
||||
public ulong ProcessedCount => _inner.ProcessedCount;
|
||||
|
||||
public ulong LastDivisor => _inner.LastDivisor;
|
||||
|
||||
public bool Exhausted => _inner.Exhausted;
|
||||
|
||||
public bool TryGetNext(out HeuristicDivisorCandidate candidate)
|
||||
{
|
||||
if (_inner.TryGetNext(out var innerCandidate))
|
||||
{
|
||||
candidate = new HeuristicDivisorCandidate(innerCandidate);
|
||||
return true;
|
||||
}
|
||||
|
||||
candidate = default;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static MersenneHeuristicDivisorEnumerator CreateMersenneDivisorEnumerator(ulong exponent, ulong maxDivisor)
|
||||
{
|
||||
return new MersenneHeuristicDivisorEnumerator(exponent, maxDivisor);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static HeuristicDivisorPreparation PrepareHeuristicDivisor(in HeuristicDivisorCandidate candidate)
|
||||
{
|
||||
var innerCandidate = candidate.AsHeuristic();
|
||||
var preparation = HeuristicPrimeTester.PrepareHeuristicDivisor(in innerCandidate);
|
||||
return new HeuristicDivisorPreparation(preparation);
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
internal static ulong ResolveHeuristicCycleLength(
|
||||
ulong exponent,
|
||||
in HeuristicDivisorPreparation preparation,
|
||||
out bool cycleFromHint,
|
||||
out bool cycleComputed,
|
||||
out bool primeOrderFailed)
|
||||
{
|
||||
var innerPreparation = preparation.AsHeuristic();
|
||||
return HeuristicPrimeTester.ResolveHeuristicCycleLength(
|
||||
exponent,
|
||||
in innerPreparation,
|
||||
out cycleFromHint,
|
||||
out cycleComputed,
|
||||
out primeOrderFailed);
|
||||
}
|
||||
public static int GpuBatchSize { get; set; } = 262_144;
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
Reference in new issue
Block a user