From ad1053835f5b894d8a5f8db27c6b375b51643748 Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Sat, 17 Aug 2019 16:31:26 +0200 Subject: [PATCH] Workaround for an HLSL compiler error --- samples/ComputeSharp.Benchmark/Dnn.cs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/samples/ComputeSharp.Benchmark/Dnn.cs b/samples/ComputeSharp.Benchmark/Dnn.cs index 4e5a6c8c..bcf8a938 100644 --- a/samples/ComputeSharp.Benchmark/Dnn.cs +++ b/samples/ComputeSharp.Benchmark/Dnn.cs @@ -22,7 +22,7 @@ namespace ComputeSharp.Benchmark /// The result tensor public static void FullyConnectedForwardCpu(int c, int n, int m, int p, float[] x, float[] w, float[] b, float[] y) { - void Kernel(int s) + Parallel.For(0, c, s => { ref float rx = ref x[s * n * m]; ref float rw = ref w[0]; @@ -43,9 +43,7 @@ namespace ComputeSharp.Benchmark Unsafe.Add(ref ry, i * p + j) = result + Unsafe.Add(ref rb, j); } } - } - - Parallel.For(0, c, Kernel); + }); } /// @@ -66,7 +64,7 @@ namespace ComputeSharp.Benchmark using ReadOnlyBuffer b_gpu = Gpu.Default.AllocateReadOnlyBuffer(b); using ReadWriteBuffer y_gpu = Gpu.Default.AllocateReadWriteBuffer(y); - void Kernel(ThreadIds id) + Gpu.Default.For(c, n, p, id => { float result = 0f; @@ -76,9 +74,7 @@ namespace ComputeSharp.Benchmark } y_gpu[(uint)(id.X * n * p + id.Y * p + id.Z)] = result + b_gpu[id.Z]; - } - - Gpu.Default.For(c, n, p, Kernel); + }); y_gpu.GetData(y); }