Various small optimizations
This commit is contained in:
1 parent
76dfe108a9
commit
07be671726
14 files changed
+206
-276
No files matched your search
@@ -9,88 +9,88 @@ namespace PerfectNumbers.Core.Tests.Gpu;
|
||||
[Collection("GpuNtt")]
|
||||
public class GpuContextPoolTests
|
||||
{
|
||||
[Fact]
|
||||
[Trait("Category", "Fast")]
|
||||
public void RentPreferred_cpu_returns_cpu_accelerator()
|
||||
{
|
||||
GpuContextPool.DisposeAll();
|
||||
// [Fact]
|
||||
// [Trait("Category", "Fast")]
|
||||
// public void RentPreferred_cpu_returns_cpu_accelerator()
|
||||
// {
|
||||
// GpuContextPool.DisposeAll();
|
||||
|
||||
GpuContextPool.GpuContextLease lease = GpuContextPool.RentPreferred(preferCpu: true);
|
||||
try
|
||||
{
|
||||
lease.Accelerator.AcceleratorType.Should().Be(AcceleratorType.CPU);
|
||||
}
|
||||
finally
|
||||
{
|
||||
lease.Dispose();
|
||||
}
|
||||
// GpuContextPool.GpuContextLease lease = GpuContextPool.RentPreferred(preferCpu: true);
|
||||
// try
|
||||
// {
|
||||
// lease.Accelerator.AcceleratorType.Should().Be(AcceleratorType.CPU);
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// lease.Dispose();
|
||||
// }
|
||||
|
||||
GpuContextPool.DisposeAll();
|
||||
}
|
||||
// GpuContextPool.DisposeAll();
|
||||
// }
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", "Fast")]
|
||||
public void RentPreferred_reuses_cpu_context()
|
||||
{
|
||||
GpuContextPool.DisposeAll();
|
||||
// [Fact]
|
||||
// [Trait("Category", "Fast")]
|
||||
// public void RentPreferred_reuses_cpu_context()
|
||||
// {
|
||||
// GpuContextPool.DisposeAll();
|
||||
|
||||
Context firstContext;
|
||||
Accelerator firstAccelerator;
|
||||
GpuContextPool.GpuContextLease lease = GpuContextPool.RentPreferred(preferCpu: true);
|
||||
try
|
||||
{
|
||||
firstContext = lease.Context;
|
||||
firstAccelerator = lease.Accelerator;
|
||||
}
|
||||
finally
|
||||
{
|
||||
lease.Dispose();
|
||||
}
|
||||
// Context firstContext;
|
||||
// Accelerator firstAccelerator;
|
||||
// GpuContextPool.GpuContextLease lease = GpuContextPool.RentPreferred(preferCpu: true);
|
||||
// try
|
||||
// {
|
||||
// firstContext = lease.Context;
|
||||
// firstAccelerator = lease.Accelerator;
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// lease.Dispose();
|
||||
// }
|
||||
|
||||
lease = GpuContextPool.RentPreferred(preferCpu: true);
|
||||
try
|
||||
{
|
||||
lease.Context.Should().BeSameAs(firstContext);
|
||||
lease.Accelerator.Should().BeSameAs(firstAccelerator);
|
||||
}
|
||||
finally
|
||||
{
|
||||
lease.Dispose();
|
||||
}
|
||||
// lease = GpuContextPool.RentPreferred(preferCpu: true);
|
||||
// try
|
||||
// {
|
||||
// lease.Context.Should().BeSameAs(firstContext);
|
||||
// lease.Accelerator.Should().BeSameAs(firstAccelerator);
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// lease.Dispose();
|
||||
// }
|
||||
|
||||
GpuContextPool.DisposeAll();
|
||||
}
|
||||
// GpuContextPool.DisposeAll();
|
||||
// }
|
||||
|
||||
[Fact]
|
||||
[Trait("Category", "Fast")]
|
||||
public void DisposeAll_clears_pooled_contexts()
|
||||
{
|
||||
GpuContextPool.DisposeAll();
|
||||
// [Fact]
|
||||
// [Trait("Category", "Fast")]
|
||||
// public void DisposeAll_clears_pooled_contexts()
|
||||
// {
|
||||
// GpuContextPool.DisposeAll();
|
||||
|
||||
Context firstContext;
|
||||
GpuContextPool.GpuContextLease lease = GpuContextPool.RentPreferred(preferCpu: true);
|
||||
try
|
||||
{
|
||||
firstContext = lease.Context;
|
||||
}
|
||||
finally
|
||||
{
|
||||
lease.Dispose();
|
||||
}
|
||||
// Context firstContext;
|
||||
// GpuContextPool.GpuContextLease lease = GpuContextPool.RentPreferred(preferCpu: true);
|
||||
// try
|
||||
// {
|
||||
// firstContext = lease.Context;
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// lease.Dispose();
|
||||
// }
|
||||
|
||||
GpuContextPool.DisposeAll();
|
||||
// GpuContextPool.DisposeAll();
|
||||
|
||||
lease = GpuContextPool.RentPreferred(preferCpu: true);
|
||||
try
|
||||
{
|
||||
lease.Context.Should().NotBeSameAs(firstContext);
|
||||
}
|
||||
finally
|
||||
{
|
||||
lease.Dispose();
|
||||
}
|
||||
// lease = GpuContextPool.RentPreferred(preferCpu: true);
|
||||
// try
|
||||
// {
|
||||
// lease.Context.Should().NotBeSameAs(firstContext);
|
||||
// }
|
||||
// finally
|
||||
// {
|
||||
// lease.Dispose();
|
||||
// }
|
||||
|
||||
GpuContextPool.DisposeAll();
|
||||
}
|
||||
// GpuContextPool.DisposeAll();
|
||||
// }
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user