This commit is contained in:
mlemanczyk committed 2025-11-25 00:50:18 +01:00
1 parent e8b4c1fc83
commit 47521e327a
3 files changed
+2 -11

No files matched your search

@@ -67,8 +67,8 @@ public class PrimeTesterBenchmarks
primeCount++; primeCount++;
} }
} }
PrimeOrderCalculatorAccelerator.Return(gpu);
PrimeOrderCalculatorAccelerator.Return(gpu);
return primeCount; return primeCount;
} }
@@ -168,16 +168,6 @@ public sealed class HeuristicCombinedPrimeTester
return HeuristicTrialDivisionCpu(n, maxDivisorSquare, nMod10); 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(PrimeOrderCalculatorAccelerator gpu, ulong n) public static bool IsPrimeGpu(PrimeOrderCalculatorAccelerator gpu, ulong n)
{ {
byte nMod10 = (byte)n.Mod10(); byte nMod10 = (byte)n.Mod10();
@@ -180,6 +180,7 @@ public sealed class MersenneNumberTester(
{ {
tmp[i] = (GpuUInt128)qs[offset + i]; tmp[i] = (GpuUInt128)qs[offset + i];
} }
// Copy only the populated elements to the device buffer to avoid overrun on pooled arrays. // Copy only the populated elements to the device buffer to avoid overrun on pooled arrays.
qBuffer.View.CopyFromCPU(stream, ref tmp[0], count); qBuffer.View.CopyFromCPU(stream, ref tmp[0], count);
gpuUInt128Pool.Return(tmp); gpuUInt128Pool.Return(tmp);