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