Added image processing benchmark

このコミットが含まれているのは:
Sergio Pedri committed 2021-01-05 16:51:49 +01:00
1 親 32b3787b3c
コミット 71ab1950e6
3ファイル変更
+111 -4

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

+6 -4
ファイルの表示
@@ -7,7 +7,7 @@ using BenchmarkDotNet.Engines;
namespace ComputeSharp.Benchmark.Blas
{
/// <summary>
/// A <see langword="class"/> that benchmarks the APIs in the <see cref="Dnn"/> class, on both CPU and GPU.
/// A <see langword="class"/> that benchmarks the APIs in the <see cref="BlasHelpers"/> class, on both CPU and GPU.
/// </summary>
[SimpleJob(RunStrategy.Monitoring)]
public class BlasBenchmark : IDisposable
@@ -105,11 +105,13 @@ namespace ComputeSharp.Benchmark.Blas
BufferW = Gpu.Default.AllocateReadOnlyBuffer(W);
BufferB = Gpu.Default.AllocateReadOnlyBuffer(B);
BufferY = Gpu.Default.AllocateReadWriteBuffer(Y);
Cpu();
GpuWithNoTemporaryBuffers();
GpuWithTemporaryBuffers();
}
/// <summary>
/// Clears the memory from the current session.
/// </summary>
/// <inheritdoc/>
[GlobalCleanup]
public void Dispose()
{
+14
ファイルの表示
@@ -5,8 +5,22 @@
<TargetFramework>net5.0</TargetFramework>
</PropertyGroup>
<ItemGroup>
<Compile Include="..\ComputeSharp.ImageProcessing\Primitives\Complex64.cs" Link="Imaging\Primitives\Complex64.cs" />
<Compile Include="..\ComputeSharp.ImageProcessing\Primitives\ComplexVector4.cs" Link="Imaging\Primitives\ComplexVector4.cs" />
<Compile Include="..\ComputeSharp.ImageProcessing\Processors\HlslBokehBlurProcessor.cs" Link="Imaging\Processors\HlslBokehBlurProcessor.cs" />
<Compile Include="..\ComputeSharp.ImageProcessing\Processors\HlslBokehBlurProcessor{TPixel}.cs" Link="Imaging\Processors\HlslBokehBlurProcessor{TPixel}.cs" />
<Compile Include="..\ComputeSharp.ImageProcessing\Processors\HlslGaussianBlurProcessor.cs" Link="Imaging\Processors\HlslGaussianBlurProcessor.cs" />
<Compile Include="..\ComputeSharp.ImageProcessing\Processors\HlslGaussianBlurProcessor{TPixel}.cs" Link="Imaging\Processors\HlslGaussianBlurProcessor{TPixel}.cs" />
</ItemGroup>
<ItemGroup>
<Content Include="..\ComputeSharp.ImageProcessing\city.jpg" Link="Imaging\city.jpg" CopyToOutputDirectory="PreserveNewest" />
</ItemGroup>
<ItemGroup>
<PackageReference Include="BenchmarkDotNet" Version="0.12.1.1473" />
<PackageReference Include="SixLabors.ImageSharp" Version="1.0.1" />
</ItemGroup>
<ItemGroup>
+91
ファイルの表示
@@ -0,0 +1,91 @@
using System;
using System.IO;
using System.Reflection;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Configs;
using BenchmarkDotNet.Engines;
using ComputeSharp.BokehBlur.Processors;
using SixLabors.ImageSharp;
using SixLabors.ImageSharp.Processing;
using SixLabors.ImageSharp.Processing.Processors.Convolution;
using ImageSharpRgba32 = SixLabors.ImageSharp.PixelFormats.Rgba32;
namespace ComputeSharp.Benchmark.Imaging
{
/// <summary>
/// A <see langword="class"/> that benchmarks the image processors against the reference in ImageSharp.
/// </summary>
[SimpleJob(RunStrategy.Monitoring)]
[CategoriesColumn]
[GroupBenchmarksBy(BenchmarkLogicalGroupRule.ByCategory)]
public class ImagingBenchmark : IDisposable
{
/// <summary>
/// The loaded image.
/// </summary>
private Image<ImageSharpRgba32> image;
/// <summary>
/// Initial setup for a benchmarking session.
/// </summary>
[GlobalSetup]
public void Setup()
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Imaging", "city.jpg");
this.image = Image.Load<ImageSharpRgba32>(path);
Bokeh_Cpu();
Bokeh_Gpu();
Gaussian_Cpu();
Gaussian_Gpu();
}
/// <inheritdoc/>
[GlobalCleanup]
public void Dispose()
{
this.image.Dispose();
}
/// <summary>
/// Runs a bokeh blur effect on the CPU.
/// </summary>
[Benchmark(Baseline = true)]
[BenchmarkCategory("BOKEH")]
public void Bokeh_Cpu()
{
this.image.Mutate(c => c.ApplyProcessor(new BokehBlurProcessor(80, 2, 3)));
}
/// <summary>
/// Runs a bokeh blur effect on the GPU.
/// </summary>
[Benchmark]
[BenchmarkCategory("BOKEH")]
public void Bokeh_Gpu()
{
this.image.Mutate(c => c.ApplyProcessor(new HlslBokehBlurProcessor(80, 2, 3)));
}
/// <summary>
/// Runs a gaussian blur effect on the CPU.
/// </summary>
[Benchmark(Baseline = true)]
[BenchmarkCategory("GAUSSIAN")]
public void Gaussian_Cpu()
{
this.image.Mutate(c => c.ApplyProcessor(new GaussianBlurProcessor(80)));
}
/// <summary>
/// Runs a gaussian blur effect on the GPU.
/// </summary>
[Benchmark]
[BenchmarkCategory("GAUSSIAN")]
public void Gaussian_Gpu()
{
this.image.Mutate(c => c.ApplyProcessor(new HlslGaussianBlurProcessor(80)));
}
}
}