Internal accelerator array removed
This commit is contained in:
1 parent
42447c4e43
commit
6cb63b6e73
2 files changed
+3
-5
No files matched your search
@@ -28,7 +28,7 @@ namespace PerfectNumbers.Core.Gpu
|
|||||||
// Intentionally left empty - there's nothing to do here. We're not really renting anything.
|
// Intentionally left empty - there's nothing to do here. We're not really renting anything.
|
||||||
}
|
}
|
||||||
|
|
||||||
public static readonly AcceleratorPool Shared = new(1);
|
public static readonly AcceleratorPool Shared = new(PerfectNumberConstants.RollingAccelerators);
|
||||||
private readonly int Capacity;
|
private readonly int Capacity;
|
||||||
|
|
||||||
public AcceleratorPool(int capacity)
|
public AcceleratorPool(int capacity)
|
||||||
|
|||||||
@@ -13,15 +13,13 @@ public sealed class PrimeOrderCalculatorAccelerator
|
|||||||
[ThreadStatic]
|
[ThreadStatic]
|
||||||
private static Queue<PrimeOrderCalculatorAccelerator>? _pool;
|
private static Queue<PrimeOrderCalculatorAccelerator>? _pool;
|
||||||
|
|
||||||
private static readonly AcceleratorPool _accelerators = new(PerfectNumberConstants.RollingAccelerators);
|
|
||||||
|
|
||||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||||
public static PrimeOrderCalculatorAccelerator Rent(int primeTesterCapacity)
|
public static PrimeOrderCalculatorAccelerator Rent(int primeTesterCapacity)
|
||||||
{
|
{
|
||||||
var pool = _pool ??= [];
|
var pool = _pool ??= [];
|
||||||
if (!pool.TryDequeue(out var gpu))
|
if (!pool.TryDequeue(out var gpu))
|
||||||
{
|
{
|
||||||
Accelerator accelerator = _accelerators.Rent();
|
Accelerator accelerator = AcceleratorPool.Shared.Rent();
|
||||||
gpu = new(accelerator, PerfectNumberConstants.DefaultFactorsBuffer, primeTesterCapacity, PerfectNumberConstants.DefaultSmallPrimeFactorSlotCount, PerfectNumberConstants.DefaultSpecialMaxFactorCapacity);
|
gpu = new(accelerator, PerfectNumberConstants.DefaultFactorsBuffer, primeTesterCapacity, PerfectNumberConstants.DefaultSmallPrimeFactorSlotCount, PerfectNumberConstants.DefaultSpecialMaxFactorCapacity);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
@@ -61,7 +59,7 @@ public sealed class PrimeOrderCalculatorAccelerator
|
|||||||
|
|
||||||
internal static void WarmUp()
|
internal static void WarmUp()
|
||||||
{
|
{
|
||||||
Accelerator[]? accelerators = _accelerators.Accelerators;
|
Accelerator[] accelerators = AcceleratorPool.Shared.Accelerators;
|
||||||
int acceleratorCount = accelerators.Length;
|
int acceleratorCount = accelerators.Length;
|
||||||
for (var i = 0; i < acceleratorCount; i++)
|
for (var i = 0; i < acceleratorCount; i++)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in new issue
Block a user