Build props refactoring, enabled TreatWarningsAsErrors

このコミットが含まれているのは:
Sergio Pedri committed 2021-02-20 13:48:02 +01:00
1 親 38084c7548
コミット 2992825e4c
11ファイル変更
+65 -60

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

+10
ファイルの表示
@@ -0,0 +1,10 @@
<Project>
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<TreatWarningsAsErrors>true</TreatWarningsAsErrors>
<Company>Sergio Pedri</Company>
<Copyright>Copyright (c) 2021 Sergio Pedri</Copyright>
</PropertyGroup>
</Project>
+25 -26
ファイルの表示
@@ -1,6 +1,5 @@
using System;
using System.Buffers;
using System.Runtime.CompilerServices;
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Engines;
@@ -35,42 +34,42 @@ namespace ComputeSharp.Benchmark.Blas
/// <summary>
/// The input tensor.
/// </summary>
private float[] X;
private float[]? X;
/// <summary>
/// The weights tensor.
/// </summary>
private float[] W;
private float[]? W;
/// <summary>
/// The bias tensor.
/// </summary>
private float[] B;
private float[]? B;
/// <summary>
/// The result tensor.
/// </summary>
private float[] Y;
private float[]? Y;
/// <summary>
/// The input tensor (GPU).
/// </summary>
private ReadOnlyBuffer<float> BufferX;
private ReadOnlyBuffer<float>? BufferX;
/// <summary>
/// The weights tensor (GPU).
/// </summary>
private ReadOnlyBuffer<float> BufferW;
private ReadOnlyBuffer<float>? BufferW;
/// <summary>
/// The bias tensor (GPU).
/// </summary>
private ReadOnlyBuffer<float> BufferB;
private ReadOnlyBuffer<float>? BufferB;
/// <summary>
/// The result tensor (GPU).
/// </summary>
private ReadWriteBuffer<float> BufferY;
private ReadWriteBuffer<float>? BufferY;
/// <summary>
/// A <see cref="System.Random"/> instance to initialize the tensors.
@@ -87,10 +86,10 @@ namespace ComputeSharp.Benchmark.Blas
float[] CreateRandomArray(int size)
{
float[] array = ArrayPool<float>.Shared.Rent(size);
ref float r = ref array[0];
for (int i = 0; i < size; i++)
foreach (ref float x in array.AsSpan())
{
Unsafe.Add(ref r, i) = (float)Random.NextDouble();
x = (float)Random.NextDouble();
}
return array;
@@ -115,15 +114,15 @@ namespace ComputeSharp.Benchmark.Blas
[GlobalCleanup]
public void Dispose()
{
ArrayPool<float>.Shared.Return(X);
ArrayPool<float>.Shared.Return(W);
ArrayPool<float>.Shared.Return(B);
ArrayPool<float>.Shared.Return(Y);
ArrayPool<float>.Shared.Return(X!);
ArrayPool<float>.Shared.Return(W!);
ArrayPool<float>.Shared.Return(B!);
ArrayPool<float>.Shared.Return(Y!);
BufferX.Dispose();
BufferW.Dispose();
BufferB.Dispose();
BufferY.Dispose();
BufferX!.Dispose();
BufferW!.Dispose();
BufferB!.Dispose();
BufferY!.Dispose();
}
/// <summary>
@@ -132,7 +131,7 @@ namespace ComputeSharp.Benchmark.Blas
[Benchmark(Baseline = true)]
public void Cpu()
{
BlasHelpers.FullyConnectedForwardCpu(C, N, M, P, X, W, B, Y);
BlasHelpers.FullyConnectedForwardCpu(C, N, M, P, X!, W!, B!, Y!);
}
/// <summary>
@@ -141,7 +140,7 @@ namespace ComputeSharp.Benchmark.Blas
[Benchmark]
public void GpuWithNoTemporaryBuffers()
{
BlasHelpers.FullyConnectedForwardGpu(Gpu.Default, C, N, M, P, BufferX, BufferW, BufferB, BufferY);
BlasHelpers.FullyConnectedForwardGpu(Gpu.Default, C, N, M, P, BufferX!, BufferW!, BufferB!, BufferY!);
}
/// <summary>
@@ -150,10 +149,10 @@ namespace ComputeSharp.Benchmark.Blas
[Benchmark]
public void GpuWithTemporaryBuffers()
{
using ReadOnlyBuffer<float> x = Gpu.Default.AllocateReadOnlyBuffer(X);
using ReadOnlyBuffer<float> w = Gpu.Default.AllocateReadOnlyBuffer(W);
using ReadOnlyBuffer<float> b = Gpu.Default.AllocateReadOnlyBuffer(B);
using ReadWriteBuffer<float> y = Gpu.Default.AllocateReadWriteBuffer<float>(Y.Length);
using ReadOnlyBuffer<float> x = Gpu.Default.AllocateReadOnlyBuffer(X!);
using ReadOnlyBuffer<float> w = Gpu.Default.AllocateReadOnlyBuffer(W!);
using ReadOnlyBuffer<float> b = Gpu.Default.AllocateReadOnlyBuffer(B!);
using ReadWriteBuffer<float> y = Gpu.Default.AllocateReadWriteBuffer<float>(Y!.Length);
BlasHelpers.FullyConnectedForwardGpu(Gpu.Default, C, N, M, P, x, w, b, y);
+7 -7
ファイルの表示
@@ -23,7 +23,7 @@ namespace ComputeSharp.Benchmark.Imaging
/// <summary>
/// The loaded image.
/// </summary>
private Image<ImageSharpRgba32> image;
private Image<ImageSharpRgba32>? image;
/// <summary>
/// Initial setup for a benchmarking session.
@@ -31,7 +31,7 @@ namespace ComputeSharp.Benchmark.Imaging
[GlobalSetup]
public void Setup()
{
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "Imaging", "city.jpg");
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "Imaging", "city.jpg");
this.image = Image.Load<ImageSharpRgba32>(path);
@@ -45,7 +45,7 @@ namespace ComputeSharp.Benchmark.Imaging
[GlobalCleanup]
public void Dispose()
{
this.image.Dispose();
this.image!.Dispose();
}
/// <summary>
@@ -55,7 +55,7 @@ namespace ComputeSharp.Benchmark.Imaging
[BenchmarkCategory("BOKEH")]
public void Bokeh_Cpu()
{
this.image.Mutate(c => c.ApplyProcessor(new BokehBlurProcessor(80, 2, 3)));
this.image!.Mutate(c => c.ApplyProcessor(new BokehBlurProcessor(80, 2, 3)));
}
/// <summary>
@@ -65,7 +65,7 @@ namespace ComputeSharp.Benchmark.Imaging
[BenchmarkCategory("BOKEH")]
public void Bokeh_Gpu()
{
this.image.Mutate(c => c.ApplyProcessor(new HlslBokehBlurProcessor(80, 2)));
this.image!.Mutate(c => c.ApplyProcessor(new HlslBokehBlurProcessor(80, 2)));
}
/// <summary>
@@ -75,7 +75,7 @@ namespace ComputeSharp.Benchmark.Imaging
[BenchmarkCategory("GAUSSIAN")]
public void Gaussian_Cpu()
{
this.image.Mutate(c => c.ApplyProcessor(new GaussianBlurProcessor(80)));
this.image!.Mutate(c => c.ApplyProcessor(new GaussianBlurProcessor(80)));
}
/// <summary>
@@ -85,7 +85,7 @@ namespace ComputeSharp.Benchmark.Imaging
[BenchmarkCategory("GAUSSIAN")]
public void Gaussian_Gpu()
{
this.image.Mutate(c => c.ApplyProcessor(new HlslGaussianBlurProcessor(80)));
this.image!.Mutate(c => c.ApplyProcessor(new HlslGaussianBlurProcessor(80)));
}
}
}
+2 -2
ファイルの表示
@@ -14,7 +14,7 @@ namespace ComputeSharp.ImageProcessing
static void Main()
{
Console.WriteLine(">> Loading image");
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "city.jpg");
string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)!, "city.jpg");
using Image<ImageSharpRgba32> image = Image.Load<ImageSharpRgba32>(path);
// Apply a series of processors and save the results
@@ -29,7 +29,7 @@ namespace ComputeSharp.ImageProcessing
Console.WriteLine($">> Saving {effect.Name} to disk");
string targetPath = Path.Combine(
Path.GetRelativePath(Path.GetDirectoryName(path), @"..\..\..\"),
Path.GetRelativePath(Path.GetDirectoryName(path)!, @"..\..\..\"),
$"{Path.GetFileNameWithoutExtension(path)}_{effect.Name}{Path.GetExtension(path)}");
copy.Save(targetPath);
}
+3 -1
ファイルの表示
@@ -1,4 +1,6 @@
namespace ComputeSharp.Shaders.Renderer.Models
#pragma warning disable CS1572, CS1573
namespace ComputeSharp.Shaders.Renderer.Models
{
/// <summary>
/// A model that contains info on a shader field.
+3 -1
ファイルの表示
@@ -1,4 +1,6 @@
namespace ComputeSharp.Shaders.Renderer.Models
#pragma warning disable CS1572, CS1573
namespace ComputeSharp.Shaders.Renderer.Models
{
/// <summary>
/// A model that contains info on a shader typed resource field.
+2 -5
ファイルの表示
@@ -1,14 +1,11 @@
<Project>
<PropertyGroup>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<Company>Sergio Pedri</Company>
<Copyright>Copyright (c) 2021 Sergio Pedri</Copyright>
<AssemblyVersion>2.0.0.0</AssemblyVersion>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="NuGetizer" Version="0.6.0" PrivateAssets="all" />
</ItemGroup>
<Import Project="..\Directory.Build.props" />
</Project>
-1
ファイルの表示
@@ -3,7 +3,6 @@
<PropertyGroup>
<TargetFrameworks>net5.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>9.0</LangVersion>
</PropertyGroup>
<ItemGroup>
@@ -2,7 +2,6 @@
<PropertyGroup>
<TargetFramework>net5.0</TargetFramework>
<LangVersion>9.0</LangVersion>
<IsPackable>false</IsPackable>
</PropertyGroup>
+13 -13
ファイルの表示
@@ -17,11 +17,11 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
[AssemblyInitialize]
public static void Initialize(TestContext _)
{
string path = Path.GetDirectoryName(typeof(NativeLibrariesResolverTests).Assembly.Location);
string path = Path.GetDirectoryName(typeof(NativeLibrariesResolverTests).Assembly.Location)!;
while (Path.GetFileName(path) is not "ComputeSharp")
{
path = Path.GetDirectoryName(path);
path = Path.GetDirectoryName(path)!;
}
SampleProjectDirectory = Path.Combine(path, "samples", "ComputeSharp.Sample.NuGet");
@@ -35,7 +35,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
/// <summary>
/// Gets the directory of the ComputeSharp.Sample.NuGet project.
/// </summary>
private static string SampleProjectDirectory { get; set; }
private static string? SampleProjectDirectory { get; set; }
[TestMethod]
[DataRow(Configuration.Debug, RID.None)]
@@ -46,7 +46,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
{
CleanSampleProject(configuration, rid);
Assert.AreEqual(0, Exec(SampleProjectDirectory, "dotnet", $"run -c {configuration} {ToOption(rid)}"));
Assert.AreEqual(0, Exec(SampleProjectDirectory!, "dotnet", $"run -c {configuration} {ToOption(rid)}"));
}
[TestMethod]
@@ -61,7 +61,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
string realtivePathToDll = Path.Combine("bin", $"{configuration}", "net5.0", $"{ToDirectory(rid)}", "ComputeSharp.Sample.NuGet.dll");
Assert.AreEqual(0, Exec(SampleProjectDirectory, "dotnet", realtivePathToDll));
Assert.AreEqual(0, Exec(SampleProjectDirectory!, "dotnet", realtivePathToDll));
}
[TestMethod]
@@ -74,7 +74,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
CleanSampleProject(configuration, rid);
BuildSampleProject(configuration, rid);
string pathToDllDirectory = Path.Combine(SampleProjectDirectory, "bin", $"{configuration}", "net5.0", $"{ToDirectory(rid)}");
string pathToDllDirectory = Path.Combine(SampleProjectDirectory!, "bin", $"{configuration}", "net5.0", $"{ToDirectory(rid)}");
Assert.AreEqual(0, Exec(pathToDllDirectory, "dotnet", "ComputeSharp.Sample.NuGet.dll"));
}
@@ -91,7 +91,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
string relativePathToAppHost = Path.Combine("bin", $"{configuration}", "net5.0", $"{ToDirectory(rid)}", "ComputeSharp.Sample.NuGet.exe");
Assert.AreEqual(0, Exec(SampleProjectDirectory, relativePathToAppHost, ""));
Assert.AreEqual(0, Exec(SampleProjectDirectory!, relativePathToAppHost, ""));
}
[TestMethod]
@@ -104,7 +104,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
CleanSampleProject(configuration, rid);
BuildSampleProject(configuration, rid);
string pathToAppHostDirectory = Path.Combine(SampleProjectDirectory, "bin", $"{configuration}", "net5.0", $"{ToDirectory(rid)}");
string pathToAppHostDirectory = Path.Combine(SampleProjectDirectory!, "bin", $"{configuration}", "net5.0", $"{ToDirectory(rid)}");
Assert.AreEqual(0, Exec(pathToAppHostDirectory, "ComputeSharp.Sample.NuGet.exe", ""));
}
@@ -123,11 +123,11 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
// Furthermore, only publishing in Release mode is tested.
CleanSampleProject(Configuration.Release, RID.Win_x64);
Exec(SampleProjectDirectory, "dotnet", $"publish -c Release -r win-x64 {ToOption(publishMode)} {ToOption(deploymentMode)} {ToOption(nativeLibsDeploymentMode)} /bl");
Exec(SampleProjectDirectory!, "dotnet", $"publish -c Release -r win-x64 {ToOption(publishMode)} {ToOption(deploymentMode)} {ToOption(nativeLibsDeploymentMode)} /bl");
string pathToAppHost = Path.Combine("bin", $"Release", "net5.0", "win-x64", "publish", "ComputeSharp.Sample.NuGet.exe");
Assert.AreEqual(0, Exec(SampleProjectDirectory, pathToAppHost, ""));
Assert.AreEqual(0, Exec(SampleProjectDirectory!, pathToAppHost, ""));
}
/// <summary>
@@ -139,7 +139,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
/// <param name="rid">The RID for which the output is cleaned.</param>
private static void CleanSampleProject(Configuration configuration, RID rid)
{
Exec(SampleProjectDirectory, "dotnet", $"clean -c {configuration} {ToOption(rid)}");
Exec(SampleProjectDirectory!, "dotnet", $"clean -c {configuration} {ToOption(rid)}");
}
/// <summary>
@@ -149,7 +149,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
/// <param name="rid">The RID to use to build the project.</param>
private static void BuildSampleProject(Configuration configuration, RID rid)
{
Exec(SampleProjectDirectory, "dotnet", $"build -c {configuration} {ToOption(rid)}");
Exec(SampleProjectDirectory!, "dotnet", $"build -c {configuration} {ToOption(rid)}");
}
/// <summary>
@@ -171,7 +171,7 @@ namespace ComputeSharp.Tests.NativeLibrariesResolver
WorkingDirectory = workingDirectory
};
using Process process = Process.Start(startInfo);
using Process process = Process.Start(startInfo)!;
process.WaitForExit();
-3
ファイルの表示
@@ -3,9 +3,6 @@
<PropertyGroup>
<TargetFrameworks>net5.0</TargetFrameworks>
<IsPackable>false</IsPackable>
<LangVersion>9.0</LangVersion>
<Nullable>enable</Nullable>
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
</PropertyGroup>
<ItemGroup>