diff --git a/PerfectNumbers.Core/CycleRemainderStepper.cs b/PerfectNumbers.Core/CycleRemainderStepper.cs index cee0594..a0d53d8 100644 --- a/PerfectNumbers.Core/CycleRemainderStepper.cs +++ b/PerfectNumbers.Core/CycleRemainderStepper.cs @@ -1,9 +1,10 @@ using System; using System.Numerics; +using System.Runtime.CompilerServices; namespace PerfectNumbers.Core; -internal struct CycleRemainderStepper +public struct CycleRemainderStepper { private readonly ulong _cycleLength; private ulong _previousPrime; @@ -23,15 +24,16 @@ internal struct CycleRemainderStepper _hasState = false; } - public void Reset() - { - // TODO: Inline this reset at the call sites so the hot loops reuse struct reinitialization - // measured fastest in MersenneDivisorCycleLengthGpuBenchmarks, avoiding the extra - // method call when scanners need to restart stepping. - _previousPrime = 0UL; - _currentRemainder = 0UL; - _hasState = false; - } + [MethodImpl(MethodImplOptions.AggressiveInlining)] + public void Reset() + { + // TODO: Inline this reset at the call sites so the hot loops reuse struct reinitialization + // measured fastest in MersenneDivisorCycleLengthGpuBenchmarks, avoiding the extra + // method call when scanners need to restart stepping. + _previousPrime = 0UL; + _currentRemainder = 0UL; + _hasState = false; + } public ulong Initialize(ulong prime) { diff --git a/PerfectNumbers.Core/PrimeOrderCalculator.Cpu.cs b/PerfectNumbers.Core/PrimeOrderCalculator.Cpu.cs index b537f3a..ee1edf9 100644 --- a/PerfectNumbers.Core/PrimeOrderCalculator.Cpu.cs +++ b/PerfectNumbers.Core/PrimeOrderCalculator.Cpu.cs @@ -1522,4 +1522,4 @@ internal static partial class PrimeOrderCalculator public readonly long Tertiary = tertiary; } } -} + diff --git a/PerfectNumbers.Core/PrimeOrderCalculator.Shared.cs b/PerfectNumbers.Core/PrimeOrderCalculator.Shared.cs index 5459159..7ed841e 100644 --- a/PerfectNumbers.Core/PrimeOrderCalculator.Shared.cs +++ b/PerfectNumbers.Core/PrimeOrderCalculator.Shared.cs @@ -5,6 +5,7 @@ using System.Diagnostics; using System.Numerics; using System.Runtime.CompilerServices; using System.Threading; +using PerfectNumbers.Core.Gpu; namespace PerfectNumbers.Core;