diff --git a/samples/ComputeSharp.Benchmark/DnnBenchmark.cs b/samples/ComputeSharp.Benchmark/DnnBenchmark.cs index 45b5a191..186d119f 100644 --- a/samples/ComputeSharp.Benchmark/DnnBenchmark.cs +++ b/samples/ComputeSharp.Benchmark/DnnBenchmark.cs @@ -72,26 +72,6 @@ namespace ComputeSharp.Benchmark /// private ReadWriteBuffer BufferY; - /// - /// The input tensor (CPU). - /// - private ReadOnlyBuffer FallbackBufferX; - - /// - /// The weights tensor (CPU). - /// - private ReadOnlyBuffer FallbackBufferW; - - /// - /// The bias tensor (CPU). - /// - private ReadOnlyBuffer FallbackBufferB; - - /// - /// The result tensor (CPU). - /// - private ReadWriteBuffer FallbackBufferY; - /// /// A instance to initialize the tensors. /// @@ -125,11 +105,6 @@ namespace ComputeSharp.Benchmark BufferW = Gpu.Default.AllocateReadOnlyBuffer(W); BufferB = Gpu.Default.AllocateReadOnlyBuffer(B); BufferY = Gpu.Default.AllocateReadWriteBuffer(Y); - - FallbackBufferX = Gpu.Fallback.AllocateReadOnlyBuffer(X); - FallbackBufferW = Gpu.Fallback.AllocateReadOnlyBuffer(W); - FallbackBufferB = Gpu.Fallback.AllocateReadOnlyBuffer(B); - FallbackBufferY = Gpu.Fallback.AllocateReadWriteBuffer(Y); } /// @@ -147,11 +122,6 @@ namespace ComputeSharp.Benchmark BufferW.Dispose(); BufferB.Dispose(); BufferY.Dispose(); - - FallbackBufferX.Dispose(); - FallbackBufferW.Dispose(); - FallbackBufferB.Dispose(); - FallbackBufferY.Dispose(); } /// @@ -181,27 +151,5 @@ namespace ComputeSharp.Benchmark y.GetData(Y); } - - /// - /// Runs a fully connected forward operation on the fallback device. - /// - [Benchmark] - public void FallbackWithNoTemporaryBuffers() => Dnn.FullyConnectedForwardGpu(Gpu.Fallback, C, N, M, P, FallbackBufferX, FallbackBufferW, FallbackBufferB, FallbackBufferY); - - /// - /// Runs a fully connected forward operation on the fallback device, creating temporary buffers to perform the operations. - /// - [Benchmark] - public void FallbackWithTemporaryBuffers() - { - using ReadOnlyBuffer x = Gpu.Fallback.AllocateReadOnlyBuffer(X); - using ReadOnlyBuffer w = Gpu.Fallback.AllocateReadOnlyBuffer(W); - using ReadOnlyBuffer b = Gpu.Fallback.AllocateReadOnlyBuffer(B); - using ReadWriteBuffer y = Gpu.Fallback.AllocateReadWriteBuffer(Y); - - Dnn.FullyConnectedForwardGpu(Gpu.Fallback, C, N, M, P, x, w, b, y); - - y.GetData(Y); - } } } diff --git a/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs b/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs index 1f9052d9..8af50a6d 100644 --- a/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs +++ b/src/ComputeSharp.Graphics/Helpers/DeviceHelper.cs @@ -23,7 +23,7 @@ namespace ComputeSharp.Graphics.Helpers { DXGI_ADAPTER_DESC1 dxgiDescription1; - return TryGetDefaultDevice(null, &dxgiDescription1); + return TryGetDefaultDevice(null, &dxgiDescription1) || TryGetWarpDevice(null, &dxgiDescription1); } /// @@ -36,7 +36,7 @@ namespace ComputeSharp.Graphics.Helpers { DXGI_ADAPTER_DESC1 dxgiDescription1; - _ = TryGetDefaultDevice(null, &dxgiDescription1); + _ = TryGetDefaultDevice(null, &dxgiDescription1) || TryGetWarpDevice(null, &dxgiDescription1); return Luid.FromLUID(dxgiDescription1.AdapterLuid); } @@ -52,7 +52,8 @@ namespace ComputeSharp.Graphics.Helpers DXGI_ADAPTER_DESC1 dxgiDescription1; - if (TryGetDefaultDevice(d3D12Device.GetAddressOf(), &dxgiDescription1)) + if (TryGetDefaultDevice(d3D12Device.GetAddressOf(), &dxgiDescription1) || + TryGetWarpDevice(d3D12Device.GetAddressOf(), &dxgiDescription1)) { return GetOrCreateDevice(d3D12Device.Move(), &dxgiDescription1); } @@ -60,25 +61,6 @@ namespace ComputeSharp.Graphics.Helpers return ThrowHelper.ThrowNotSupportedException("There isn't a supported GPU device on the current machine"); } - /// - /// Gets the warp instance. - /// - /// The default instance supporting at least DX12.0. - /// Thrown when a default device is not available. - public static unsafe GraphicsDevice GetWarpDevice() - { - using ComPtr d3D12Device = default; - - DXGI_ADAPTER_DESC1 dxgiDescription1; - - if (TryGetWarpDevice(d3D12Device.GetAddressOf(), &dxgiDescription1)) - { - return GetOrCreateDevice(d3D12Device.Move(), &dxgiDescription1); - } - - return ThrowHelper.ThrowNotSupportedException("There isn't a supported device on the current machine"); - } - /// /// Tries to check or create a default object. /// diff --git a/src/ComputeSharp/Gpu.cs b/src/ComputeSharp/Gpu.cs index 10619a36..c138b30b 100644 --- a/src/ComputeSharp/Gpu.cs +++ b/src/ComputeSharp/Gpu.cs @@ -16,11 +16,6 @@ namespace ComputeSharp /// private static readonly Lazy DefaultFactory = new(DeviceHelper.GetDefaultDevice); - /// - /// The instance used to produce the warp device for . - /// - private static readonly Lazy WarpFactory = new(DeviceHelper.GetWarpDevice); - /// /// Gets whether or not the APIs can be used on the /// current machine (ie. if there is at least a supported GPU device). @@ -36,15 +31,6 @@ namespace ComputeSharp /// Make sure to check before accessing this property. public static GraphicsDevice Default => DefaultFactory.Value; - /// - /// Gets the fallback instance for the current machine. - /// This is a software version of a device that can be used when no supported GPU is available. - /// This instance cannot be manually disposed - attempting to do so is safe and it will - /// not cause an exception, but it will simply do nothing and not dispose the device. - /// - /// Thrown when a fallback device is not available. - public static GraphicsDevice Fallback => WarpFactory.Value; - /// /// Enumerates all the currently available DX12.0 devices. Note that creating a device is a relatively /// expensive operation, so consider using to be able to filter the available