Restore per-lease kernel containers
This commit is contained in:
1 parent
dbde6337ea
commit
5a17fa64d5
3 files changed
+12
-18
No files matched your search
@@ -13,14 +13,13 @@ public static class GpuContextPool
|
||||
{
|
||||
public readonly Context Context;
|
||||
public readonly Accelerator Accelerator;
|
||||
public readonly KernelContainer Kernels;
|
||||
|
||||
public PooledContext(KernelContainer kernels)
|
||||
{
|
||||
Context = SharedGpuContext.Context;
|
||||
Accelerator = SharedGpuContext.Accelerator;
|
||||
Kernels = kernels;
|
||||
GpuStaticTableInitializer.EnsureStaticTables(kernels, Accelerator);
|
||||
kernels.Dispose();
|
||||
// NOTE: Avoid loading/compiling any kernel here to prevent implicit
|
||||
// CL stream/queue creation during accelerator construction.
|
||||
// Some OpenCL drivers are fragile when a queue is created immediately
|
||||
@@ -35,7 +34,6 @@ public static class GpuContextPool
|
||||
// Clear any per-accelerator cached resources to avoid releasing
|
||||
// after the accelerator is destroyed.
|
||||
PrimeTester.ClearGpuCaches(Accelerator);
|
||||
Kernels.Dispose();
|
||||
|
||||
// These resources are shared between GPU leases
|
||||
// Accelerator.Dispose();
|
||||
@@ -55,9 +53,7 @@ public static class GpuContextPool
|
||||
}
|
||||
|
||||
// Create a new accelerator when the pool does not have one available.
|
||||
KernelContainer kernels = GpuKernelPool.GetKernels();
|
||||
var context = new PooledContext(kernels);
|
||||
return new GpuContextLease(context);
|
||||
return new GpuContextLease(new PooledContext(GpuKernelPool.GetKernels()));
|
||||
}
|
||||
|
||||
|
||||
@@ -115,8 +111,6 @@ public static class GpuContextPool
|
||||
public Context Context => _ctx!.Context;
|
||||
public Accelerator Accelerator => _ctx!.Accelerator;
|
||||
|
||||
public KernelContainer Kernels => _ctx!.Kernels;
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
if (_disposed)
|
||||
|
||||
Reference in new issue
Block a user