Cleanup. Classes & structs extracted to their own files.
This commit is contained in:
1 parent
119690086a
commit
7c035239b4
5 files changed
+116
-91
No files matched your search
@@ -5,97 +5,6 @@ using static PerfectNumbers.Core.Gpu.GpuContextPool;
|
||||
|
||||
namespace PerfectNumbers.Core.Gpu;
|
||||
|
||||
public readonly struct ResidueAutomatonArgs
|
||||
{
|
||||
public readonly ulong Q0M10;
|
||||
public readonly ulong Step10;
|
||||
public readonly ulong Q0M8;
|
||||
public readonly ulong Step8;
|
||||
public readonly ulong Q0M3;
|
||||
public readonly ulong Step3;
|
||||
public readonly ulong Q0M5;
|
||||
public readonly ulong Step5;
|
||||
|
||||
public ResidueAutomatonArgs(ulong q0m10, ulong step10, ulong q0m8, ulong step8, ulong q0m3, ulong step3, ulong q0m5, ulong step5)
|
||||
{
|
||||
Q0M10 = q0m10; Step10 = step10; Q0M8 = q0m8; Step8 = step8; Q0M3 = q0m3; Step3 = step3; Q0M5 = q0m5; Step5 = step5;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
public sealed class KernelContainer : IDisposable
|
||||
{
|
||||
// Serializes first-time initialization of kernels/buffers per accelerator.
|
||||
public Action<AcceleratorStream, Index1D, ulong, ulong, ArrayView<GpuUInt128>, ArrayView<ulong>>? Order;
|
||||
public Action<AcceleratorStream, Index1D, ulong, GpuUInt128, GpuUInt128, byte, ulong,
|
||||
ulong, ulong, ulong, ulong, ArrayView<ulong>, ArrayView1D<ulong, Stride1D.Dense>>? Incremental;
|
||||
public Action<AcceleratorStream, Index1D, ulong, GpuUInt128, GpuUInt128, byte, ulong,
|
||||
ResidueAutomatonArgs, ArrayView<ulong>, ArrayView1D<ulong, Stride1D.Dense>,
|
||||
ArrayView1D<uint, Stride1D.Dense>, ArrayView1D<uint, Stride1D.Dense>,
|
||||
ArrayView1D<ulong, Stride1D.Dense>, ArrayView1D<ulong, Stride1D.Dense>>? Pow2Mod;
|
||||
public Action<AcceleratorStream, Index1D, ulong, GpuUInt128, GpuUInt128, byte, ulong,
|
||||
ResidueAutomatonArgs, ArrayView<int>, ArrayView1D<ulong, Stride1D.Dense>>? IncrementalOrder;
|
||||
public Action<AcceleratorStream, Index1D, ulong, GpuUInt128, GpuUInt128, byte, ulong,
|
||||
ResidueAutomatonArgs, ArrayView<int>, ArrayView1D<ulong, Stride1D.Dense>>? Pow2ModOrder;
|
||||
public Action<AcceleratorStream, Index1D, ulong, uint, ArrayView1D<uint, Stride1D.Dense>, ArrayView1D<ulong, Stride1D.Dense>, int, ArrayView1D<ulong, Stride1D.Dense>, ArrayView1D<int, Stride1D.Dense>, ArrayView1D<int, Stride1D.Dense>, ArrayView1D<ulong, Stride1D.Dense>>? SmallPrimeFactor;
|
||||
public Action<AcceleratorStream, Index1D, ulong, ArrayView1D<ulong, Stride1D.Dense>, int, MontgomeryDivisorData, ArrayView1D<ulong, Stride1D.Dense>, ArrayView1D<ulong, Stride1D.Dense>>? SpecialMax;
|
||||
|
||||
// Optional device buffer with small divisor cycles (<= 4M). Index = divisor, value = cycle length.
|
||||
public MemoryBuffer1D<ulong, Stride1D.Dense>? SmallCycles;
|
||||
|
||||
public MemoryBuffer1D<uint, Stride1D.Dense>? SmallPrimesLastOne;
|
||||
public MemoryBuffer1D<uint, Stride1D.Dense>? SmallPrimesLastSeven;
|
||||
public MemoryBuffer1D<ulong, Stride1D.Dense>? SmallPrimesPow2LastOne;
|
||||
public MemoryBuffer1D<ulong, Stride1D.Dense>? SmallPrimesPow2LastSeven;
|
||||
|
||||
public MemoryBuffer1D<uint, Stride1D.Dense>? SmallPrimeFactorsPrimes;
|
||||
public MemoryBuffer1D<ulong, Stride1D.Dense>? SmallPrimeFactorsSquares;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Order = null;
|
||||
// Incremental = null;
|
||||
// Pow2Mod = null;
|
||||
// IncrementalOrder = null;
|
||||
// Pow2ModOrder = null;
|
||||
// SmallPrimeFactor = null;
|
||||
// SpecialMax = null;
|
||||
|
||||
// SmallCycles?.Dispose();
|
||||
// SmallPrimesLastOne?.Dispose();
|
||||
// SmallPrimesLastSeven?.Dispose();
|
||||
// SmallPrimesPow2LastOne?.Dispose();
|
||||
// SmallPrimesPow2LastSeven?.Dispose();
|
||||
// SmallPrimeFactorsPrimes?.Dispose();
|
||||
// SmallPrimeFactorsSquares?.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
public readonly struct ResiduePrimeViews(
|
||||
ArrayView1D<uint, Stride1D.Dense> lastOne,
|
||||
ArrayView1D<uint, Stride1D.Dense> lastSeven,
|
||||
ArrayView1D<ulong, Stride1D.Dense> lastOnePow2,
|
||||
ArrayView1D<ulong, Stride1D.Dense> lastSevenPow2)
|
||||
{
|
||||
public readonly ArrayView1D<uint, Stride1D.Dense> LastOne = lastOne;
|
||||
public readonly ArrayView1D<uint, Stride1D.Dense> LastSeven = lastSeven;
|
||||
public readonly ArrayView1D<ulong, Stride1D.Dense> LastOnePow2 = lastOnePow2;
|
||||
public readonly ArrayView1D<ulong, Stride1D.Dense> LastSevenPow2 = lastSevenPow2;
|
||||
}
|
||||
|
||||
public readonly struct SmallPrimeFactorViews(
|
||||
MemoryBuffer1D<uint, Stride1D.Dense> primes,
|
||||
MemoryBuffer1D<ulong, Stride1D.Dense> squares,
|
||||
int count)
|
||||
{
|
||||
public readonly MemoryBuffer1D<uint, Stride1D.Dense> Primes = primes;
|
||||
public readonly MemoryBuffer1D<ulong, Stride1D.Dense> Squares = squares;
|
||||
public readonly int Count = count;
|
||||
|
||||
public ArrayView1D<uint, Stride1D.Dense> PrimesView => Primes.View;
|
||||
public ArrayView1D<ulong, Stride1D.Dense> SquaresView => Squares.View;
|
||||
}
|
||||
|
||||
public class GpuKernelPool
|
||||
{
|
||||
private static readonly ConcurrentDictionary<Accelerator, KernelContainer> _kernels = new();
|
||||
|
||||
Reference in new issue
Block a user