Tasks will now save calculations progress and resume calculation upon restart.
This commit is contained in:
1 parent
941733905b
commit
f43c67c86f
9 files changed
+199
-34
No files matched your search
@@ -1,12 +1,15 @@
|
||||
using PerfectNumbers.Core;
|
||||
|
||||
namespace PerfectNumbers.Core.Gpu;
|
||||
|
||||
public static class GpuPrimeWorkLimiter
|
||||
{
|
||||
private static SemaphoreSlim _semaphore = new(1, int.MaxValue);
|
||||
private static readonly TimeSpan _pauseBetweenChecks = TimeSpan.FromSeconds(2);
|
||||
private static PollingSemaphore _semaphore = new(1, _pauseBetweenChecks);
|
||||
private static int _currentLimit = 1;
|
||||
|
||||
public static void Acquire() { } // => _semaphore.Wait();
|
||||
public static void Release() { }// => _semaphore.Release();
|
||||
public static void Acquire() => _semaphore.Wait();
|
||||
public static void Release() => _semaphore.Release();
|
||||
|
||||
public static void SetLimit(int value)
|
||||
{
|
||||
@@ -18,13 +21,13 @@ public static class GpuPrimeWorkLimiter
|
||||
if (value == _currentLimit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: Switch to a shared limiter implementation with GpuWorkLimiter so we can coordinate CPU/GPU prime work using
|
||||
// the same semaphore pool without reallocating per adjustment.
|
||||
var previous = _semaphore;
|
||||
_semaphore = new SemaphoreSlim(value, value);
|
||||
// var previous = _semaphore;
|
||||
_semaphore = new PollingSemaphore(value, _pauseBetweenChecks);
|
||||
_currentLimit = value;
|
||||
previous.Dispose();
|
||||
// previous.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user