Reduce allocations for ComputeContext async execution

このコミットが含まれているのは:
Sergio Pedri committed 2021-12-30 19:20:33 +01:00
1 親 c03006aa67
コミット ff59d3f5ad
4ファイル変更
+132 -31

検索条件に一致するファイルはありません

+28
ファイルの表示
@@ -1,4 +1,5 @@
using System;
using System.Threading.Tasks;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
@@ -8,6 +9,7 @@ namespace ComputeSharp.Benchmark.Blas;
/// A <see langword="class"/> that benchmarks the shader dispatch times.
/// </summary>
[GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)]
[MemoryDiagnoser]
public partial class DispatchingBenchmark : IDisposable
{
/// <summary>
@@ -53,6 +55,18 @@ public partial class DispatchingBenchmark : IDisposable
context.For(64, new TestShader(Buffer!));
}
/// <summary>
/// Invokes a single shader through a compute context, asynchronously.
/// </summary>
[Benchmark]
[BenchmarkCategory("SINGLE")]
public async Task Compute_Single_WithContext_Async()
{
await using var context = GraphicsDevice.Default.CreateComputeContext();
context.For(64, new TestShader(Buffer!));
}
/// <summary>
/// Invokes two empty compute shaders one by one.
/// </summary>
@@ -78,6 +92,20 @@ public partial class DispatchingBenchmark : IDisposable
context.For(64, new TestShader(Buffer!));
}
/// <summary>
/// Invokes two empty compute shaders in a batch, asynchronously.
/// </summary>
[Benchmark]
[BenchmarkCategory("MULTIPLE")]
public async Task Compute_Multiple_WithContext_Async()
{
await using var context = GraphicsDevice.Default.CreateComputeContext();
context.For(64, new TestShader(Buffer!));
context.Barrier(Buffer!);
context.For(64, new TestShader(Buffer!));
}
[AutoConstructor]
internal readonly partial struct TestShader : IComputeShader
{