Various optimizations to separate non-static data between threads and resolve read/write access issue.
This commit is contained in:
1 parent
5a17fa64d5
commit
64d615c402
26 files changed
+1181
-1117
No files matched your search
@@ -1,6 +1,5 @@
|
||||
using ILGPU;
|
||||
using ILGPU.Runtime;
|
||||
using PerfectNumbers.Core;
|
||||
|
||||
namespace PerfectNumbers.Core.Gpu;
|
||||
|
||||
@@ -13,7 +12,7 @@ internal static partial class PrimeOrderGpuHeuristics
|
||||
int factorCount,
|
||||
MontgomeryDivisorData divisor,
|
||||
ArrayView1D<ulong, Stride1D.Dense> candidates,
|
||||
ArrayView1D<ushort, Stride1D.Dense> resultOut)
|
||||
ArrayView1D<ulong, Stride1D.Dense> resultOut)
|
||||
{
|
||||
if (index != 0)
|
||||
{
|
||||
@@ -62,7 +61,7 @@ internal static partial class PrimeOrderGpuHeuristics
|
||||
var stepper = new ExponentRemainderStepperGpu(divisorPartial);
|
||||
if (stepper.InitializeIsUnityGpu(candidates[0]))
|
||||
{
|
||||
resultOut[0] = 0;
|
||||
Atomic.Exchange(ref resultOut[0], 0);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -70,11 +69,11 @@ internal static partial class PrimeOrderGpuHeuristics
|
||||
{
|
||||
if (stepper.ComputeNextIsUnityGpu(candidates[i]))
|
||||
{
|
||||
resultOut[0] = 0;
|
||||
Atomic.Exchange(ref resultOut[0], 0);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
resultOut[0] = 1;
|
||||
Atomic.Exchange(ref resultOut[0], 1);
|
||||
}
|
||||
}
|
||||
@@ -18,19 +18,19 @@ internal static class PrimeTesterKernels
|
||||
{
|
||||
// GPU kernel: small-prime sieve only. Returns 1 if passes sieve (probable prime), 0 otherwise.
|
||||
public static void SmallPrimeSieveKernel(
|
||||
Index1D index,
|
||||
ArrayView<ulong> numbers,
|
||||
ArrayView<uint> smallPrimes,
|
||||
ArrayView<uint> smallPrimesLastOne,
|
||||
ArrayView<uint> smallPrimesLastSeven,
|
||||
ArrayView<uint> smallPrimesLastThree,
|
||||
ArrayView<uint> smallPrimesLastNine,
|
||||
ArrayView<ulong> smallPrimesPow2,
|
||||
ArrayView<ulong> smallPrimesPow2LastOne,
|
||||
ArrayView<ulong> smallPrimesPow2LastSeven,
|
||||
ArrayView<ulong> smallPrimesPow2LastThree,
|
||||
ArrayView<ulong> smallPrimesPow2LastNine,
|
||||
ArrayView<byte> results)
|
||||
Index1D index,
|
||||
ArrayView<ulong> numbers,
|
||||
ArrayView<uint> smallPrimes,
|
||||
ArrayView<uint> smallPrimesLastOne,
|
||||
ArrayView<uint> smallPrimesLastSeven,
|
||||
ArrayView<uint> smallPrimesLastThree,
|
||||
ArrayView<uint> smallPrimesLastNine,
|
||||
ArrayView<ulong> smallPrimesPow2,
|
||||
ArrayView<ulong> smallPrimesPow2LastOne,
|
||||
ArrayView<ulong> smallPrimesPow2LastSeven,
|
||||
ArrayView<ulong> smallPrimesPow2LastThree,
|
||||
ArrayView<ulong> smallPrimesPow2LastNine,
|
||||
ArrayView<byte> results)
|
||||
{
|
||||
ulong n = numbers[index];
|
||||
byte result = 1;
|
||||
|
||||
Reference in new issue
Block a user