GPU accelerator recycled for better performance.

This commit is contained in:
mlemanczyk committed 2025-11-12 07:39:52 +01:00
1 parent fdc2da7dae
commit 735bfa1557
2 files changed
+9 -3

No files matched your search

@@ -3,6 +3,7 @@ using System.Threading;
using System.Threading.Tasks;
using System.Globalization;
using System.Runtime.InteropServices;
using PerfectNumbers.Core.Gpu.Accelerators;
namespace PerfectNumbers.Core;
@@ -302,10 +303,12 @@ public static class MersenneNumberDivisorByDivisorTester
}
Console.WriteLine($"Task finished for range {rangeStart}");
Pow2MontgomeryAccelerator.DisposeAll();
},
CancellationToken.None,
TaskCreationOptions.DenyChildAttach,
scheduler);
}
startGate.Set();
+6 -3
View File
@@ -125,7 +125,8 @@ public sealed class PrimeTester
outputView.CopyToCPU(stream, ref flag, 1);
stream.Synchronize();
gpu.Dispose();
// gpu.Dispose();
Pow2MontgomeryAccelerator.Return(gpu);
GpuPrimeWorkLimiter.Release();
return flag != 0;
@@ -240,7 +241,8 @@ public sealed class PrimeTester
}
stream.Synchronize();
gpu.Dispose();
Pow2MontgomeryAccelerator.Return(gpu);
// gpu.Dispose();
GpuPrimeWorkLimiter.Release();
}
@@ -303,7 +305,8 @@ public sealed class PrimeTester
pool.Return(temp, clearArray: false);
resultBuffer.Dispose();
inputBuffer.Dispose();
gpu.Dispose();
Pow2MontgomeryAccelerator.Return(gpu);
// gpu.Dispose();
}
private static Action<AcceleratorStream, Index1D, ArrayView<ulong>, ArrayView<byte>> GetSharesFactorKernel(Accelerator accelerator)