From f4459ed7ebed8e61d986d1ccd8723408e54a5f1d Mon Sep 17 00:00:00 2001 From: Sergio Pedri Date: Fri, 31 Dec 2021 13:13:04 +0100 Subject: [PATCH] Add synchronous parallel unit tests for ComputeContext --- .../ComputeSharp.Tests/ComputeContextTests.cs | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/tests/ComputeSharp.Tests/ComputeContextTests.cs b/tests/ComputeSharp.Tests/ComputeContextTests.cs index de3d1a04..a2e30dee 100644 --- a/tests/ComputeSharp.Tests/ComputeContextTests.cs +++ b/tests/ComputeSharp.Tests/ComputeContextTests.cs @@ -434,6 +434,36 @@ public partial class ComputeContextTests } } + [CombinatorialTestMethod] + [AllDevices] + public void ForAndForEach_Batched_Parallel_WithParallelFor(Device device) + { + void Test(Device device) + { + for (int i = 0; i < 20; i++) + { + ForAndForEach_Batched(device); + } + } + + Parallel.For(0, 64, _ => Test(device)); + } + + [CombinatorialTestMethod] + [AllDevices] + public async Task ForAndForEach_Batched_Parallel_WithTaskRun(Device device) + { + void Test(Device device) + { + for (int i = 0; i < 20; i++) + { + ForAndForEach_Batched(device); + } + } + + await Task.Run(() => Test(device)); + } + [CombinatorialTestMethod] [AllDevices] public async Task ForAndForEach_Async_Batched(Device device)