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
@@ -16,10 +16,10 @@ public static class AcceleratorStreamPool
|
||||
|
||||
public static AcceleratorStream Rent(int acceleratorIndex)
|
||||
{
|
||||
// var streamLock = _locks[acceleratorIndex];
|
||||
var streamLock = _locks[acceleratorIndex];
|
||||
var queue = _streams[acceleratorIndex];
|
||||
|
||||
// streamLock.Wait();
|
||||
streamLock.Wait();
|
||||
|
||||
return queue.TryDequeue(out var stream)
|
||||
? stream
|
||||
@@ -28,10 +28,10 @@ public static class AcceleratorStreamPool
|
||||
|
||||
public static void Return(int acceleratorIndex, AcceleratorStream stream)
|
||||
{
|
||||
// var streamLock = _locks[acceleratorIndex];
|
||||
var streamLock = _locks[acceleratorIndex];
|
||||
var queue = _streams[acceleratorIndex];
|
||||
queue.Enqueue(stream);
|
||||
// streamLock.Release();
|
||||
streamLock.Release();
|
||||
}
|
||||
|
||||
public static void WarmUp(int acceleratorIndex)
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
}
|
||||
@@ -43,6 +43,17 @@ public sealed partial class MersenneNumberDivisorByDivisorGpuTester : IMersenneN
|
||||
set => _minK = value < 1UL ? 1UL : value;
|
||||
}
|
||||
|
||||
public string? StateFilePath { get; set; }
|
||||
|
||||
public void ResetStateTracking()
|
||||
{
|
||||
}
|
||||
|
||||
public void ResumeFromState(ulong lastSavedK)
|
||||
{
|
||||
_minK = lastSavedK + 1UL;
|
||||
}
|
||||
|
||||
public void ConfigureFromMaxPrime(ulong maxPrime)
|
||||
{
|
||||
// EvenPerfectBitScanner configures the GPU tester once before scanning and never mutates the configuration afterwards,
|
||||
|
||||
Reference in new issue
Block a user