Merge pull request #152 from mlemanczyk/codex/optimize-accelerator-allocation-for-mersennedivisorcycles
Remove GPU fallback from context pool
This commit is contained in:
3 files changed
+13
-7
No files matched your search
@@ -145,8 +145,7 @@ public static class GpuContextPool
|
||||
|
||||
public object ExecutionLock => _ctx.ExecutionLock;
|
||||
|
||||
|
||||
public void Dispose()
|
||||
internal void ReturnToPool()
|
||||
{
|
||||
if (disposed)
|
||||
{
|
||||
@@ -156,6 +155,10 @@ public static class GpuContextPool
|
||||
Return(_ctx);
|
||||
disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
ReturnToPool();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -396,7 +396,10 @@ public ref struct GpuKernelLease(IDisposable limiter, GpuContextLease gpu, Kerne
|
||||
_stream?.Dispose();
|
||||
_stream = null;
|
||||
|
||||
_gpu?.Dispose();
|
||||
if (_gpu.HasValue)
|
||||
{
|
||||
_gpu.Value.ReturnToPool();
|
||||
}
|
||||
_gpu = null;
|
||||
|
||||
_executionLock = null;
|
||||
|
||||
@@ -1715,10 +1715,10 @@ internal static partial class PrimeOrderGpuHeuristics
|
||||
GpuUInt128[]? rentedExponents = null;
|
||||
GpuUInt128[]? rentedResults = null;
|
||||
var lease = GpuKernelPool.GetKernel(useGpuOrder: true);
|
||||
var execution = lease.EnterExecutionScope();
|
||||
|
||||
try
|
||||
{
|
||||
var execution = lease.EnterExecutionScope();
|
||||
Accelerator accelerator = lease.Accelerator;
|
||||
AcceleratorStream stream = lease.Stream;
|
||||
var kernel = GetPow2ModWideKernel(accelerator);
|
||||
@@ -1755,7 +1755,6 @@ internal static partial class PrimeOrderGpuHeuristics
|
||||
|
||||
exponentBuffer.Dispose();
|
||||
remainderBuffer.Dispose();
|
||||
execution.Dispose();
|
||||
return true;
|
||||
}
|
||||
catch (Exception)
|
||||
@@ -1775,6 +1774,7 @@ internal static partial class PrimeOrderGpuHeuristics
|
||||
ArrayPool<GpuUInt128>.Shared.Return(rentedResults, clearArray: false);
|
||||
}
|
||||
|
||||
execution.Dispose();
|
||||
lease.Dispose();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user