GPU calculations frequency adjusted
This commit is contained in:
1 parent
5cac51479e
commit
54fdff0a4e
2 files changed
+11
-10
No files matched your search
@@ -8,11 +8,12 @@ public static class PerfectNumberConstants
|
||||
public const int DefaultSmallPrimeFactorSlotCount = 64;
|
||||
public const int DefaultSpecialMaxFactorCapacity = 1024;
|
||||
public const ulong ExtraDivisorCycleSearchLimit = 64UL;
|
||||
public const int GpuFrequency = 768 - 1;
|
||||
public const int MaxQForDivisorCycles = 4_000_000;
|
||||
public static readonly uint PrimesLimit = 1_000_000; //(ulong)Array.MaxLength;// 1_000_000;
|
||||
public const int MaxOddPowersCount = 128;
|
||||
public const int PooledArrayThreshold = 64;
|
||||
public static readonly int RollingAccelerators = 298; //SharedGpuContext.Device.MaxNumThreadsPerGroup;
|
||||
public static readonly int RollingAccelerators = 298; //SharedGpuContext.Device.MaxNumThreadsPerGroup;
|
||||
public const int ThreadsByAccelerator = 1;
|
||||
// TODO: Load these limits from the benchmark-driven configuration so CPU and GPU scans stay aligned with the optimal
|
||||
// divisor-cycle datasets we generate offline.
|
||||
|
||||
@@ -1177,7 +1177,7 @@ internal static partial class PrimeOrderCalculator
|
||||
// bool isPrime = HeuristicCombinedPrimeTester.IsPrimeGpu(gpu, composite);
|
||||
bool runOnGpu = RunOnGpu();
|
||||
|
||||
bool isPrime = runOnGpu ? PrimeTester.IsPrime(composite) : HeuristicCombinedPrimeTester.IsPrimeGpu(gpu, composite);
|
||||
bool isPrime = !runOnGpu ? PrimeTester.IsPrime(composite) : HeuristicCombinedPrimeTester.IsPrimeGpu(gpu, composite);
|
||||
// bool isPrime = PrimeTester.IsPrime(composite);
|
||||
// bool isPrime = Open.Numeric.Primes.Prime.Numbers.IsPrime(composite);
|
||||
|
||||
@@ -1375,19 +1375,19 @@ internal static partial class PrimeOrderCalculator
|
||||
|
||||
private static bool RunOnGpu()
|
||||
{
|
||||
const int GpuFrequency = 1024 - 1;
|
||||
|
||||
int cpuCount = Atomic.Add(target: ref _cpuCount, 1);
|
||||
if (cpuCount == GpuFrequency)
|
||||
// return true;
|
||||
int cpuCount = Atomic.Add(ref _cpuCount, 1);
|
||||
// return (cpuCount % GpuFrequency) == 0;
|
||||
if (cpuCount == PerfectNumberConstants.GpuFrequency)
|
||||
{
|
||||
Atomic.Add(ref _cpuCount, -GpuFrequency);
|
||||
Atomic.Add(ref _cpuCount, -PerfectNumberConstants.GpuFrequency);
|
||||
}
|
||||
else if (cpuCount > GpuFrequency)
|
||||
else if (cpuCount > PerfectNumberConstants.GpuFrequency)
|
||||
{
|
||||
cpuCount -= GpuFrequency;
|
||||
cpuCount -= PerfectNumberConstants.GpuFrequency;
|
||||
}
|
||||
|
||||
return cpuCount != GpuFrequency;
|
||||
return cpuCount == PerfectNumberConstants.GpuFrequency;
|
||||
}
|
||||
|
||||
private static void PopulateSmallPrimeFactorsCpu(
|
||||
|
||||
Reference in new issue
Block a user