Tie GPU scratch buffers to context leases
This commit is contained in:
1 parent
4c4d4243fb
commit
dbde6337ea
3 files changed
+18
-12
No files matched your search
@@ -12,23 +12,22 @@ public sealed class GpuKernelLease
|
||||
private static readonly ConcurrentQueue<GpuKernelLease> Pool = new();
|
||||
|
||||
private GpuContextLease? _gpu;
|
||||
public KernelContainer Kernels;
|
||||
public KernelContainer Kernels = null!;
|
||||
private AcceleratorStream? _stream;
|
||||
|
||||
private GpuKernelLease(KernelContainer kernels)
|
||||
private GpuKernelLease()
|
||||
{
|
||||
Kernels = kernels;
|
||||
}
|
||||
|
||||
internal static GpuKernelLease Rent(GpuContextLease gpu, KernelContainer kernels)
|
||||
internal static GpuKernelLease Rent(GpuContextLease gpu)
|
||||
{
|
||||
if (!Pool.TryDequeue(out var lease))
|
||||
{
|
||||
lease = new GpuKernelLease(kernels);
|
||||
lease = new GpuKernelLease();
|
||||
}
|
||||
|
||||
lease._gpu = gpu;
|
||||
lease.Kernels = kernels;
|
||||
lease.Kernels = gpu.Kernels;
|
||||
lease._stream = null;
|
||||
return lease;
|
||||
}
|
||||
@@ -156,9 +155,9 @@ public sealed class GpuKernelLease
|
||||
|
||||
_gpu?.Dispose();
|
||||
_gpu = null;
|
||||
Kernels = null!;
|
||||
|
||||
Kernels?.Dispose();
|
||||
GpuPrimeWorkLimiter.Release();
|
||||
GpuPrimeWorkLimiter.Release();
|
||||
Pool.Enqueue(this);
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user