PrimeTesterByLastDigitAccelerator integrated into Pow2MontgomeryGpuCalculator for better performance.
This commit is contained in:
1 parent
0de9871529
commit
cf5f78c2ef
11 files changed
+222
-241
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.
|
||||
}
|
||||
|
||||
public static readonly AcceleratorPool Shared = new(PerfectNumberConstants.RollingAccelerators);
|
||||
public static readonly AcceleratorPool Shared = new(1);
|
||||
private readonly int Capacity;
|
||||
|
||||
public AcceleratorPool(int capacity)
|
||||
@@ -38,7 +38,20 @@ namespace PerfectNumbers.Core.Gpu
|
||||
var device = context.GetPreferredDevice(false);
|
||||
Context = context;
|
||||
Device = device;
|
||||
Accelerators = [.. Enumerable.Range(0, capacity).Select(_ => device.CreateAccelerator(context))];
|
||||
int acceleratorsInContext = 0;
|
||||
Accelerators = [.. Enumerable.Range(0, capacity).Select(_ =>
|
||||
{
|
||||
Accelerator accelerator = device.CreateAccelerator(context);
|
||||
acceleratorsInContext++;
|
||||
if (acceleratorsInContext >= 128)
|
||||
{
|
||||
context = Context.CreateDefault();
|
||||
device = context.GetPreferredDevice(false);
|
||||
acceleratorsInContext = 0;
|
||||
}
|
||||
|
||||
return accelerator;
|
||||
})];
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user