diff --git a/DotMP-Tests/ParallelTests.cs b/DotMP-Tests/ParallelTests.cs index 3b7f933b..29d5430f 100644 --- a/DotMP-Tests/ParallelTests.cs +++ b/DotMP-Tests/ParallelTests.cs @@ -18,13 +18,10 @@ using System.Collections.Generic; using System.Diagnostics; using System.Linq; -using System.Net.Http.Headers; -using System.Text.Json.Serialization; using System.Threading; using DotMP; using FluentAssertions; using Xunit; -using Xunit.Abstractions; namespace DotMPTests { @@ -1294,7 +1291,7 @@ public void Task_dependencies_work() [Fact] public void Non_parallel_for_should_except() { - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.For(0, 10, action: i => { }); }); @@ -1306,7 +1303,7 @@ public void Non_parallel_for_should_except() [Fact] public void Nested_parallelism_should_except() { - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelRegion(num_threads: 4, action: () => { @@ -1321,7 +1318,7 @@ public void Nested_parallelism_should_except() [Fact] public void Non_parallel_sections_should_except() { - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.Sections(() => { }, () => { }); }); @@ -1333,7 +1330,7 @@ public void Non_parallel_sections_should_except() [Fact] public void Non_parallel_barrier_should_except() { - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.Barrier(); }); @@ -1345,7 +1342,7 @@ public void Non_parallel_barrier_should_except() [Fact] public void Non_parallel_master_should_except() { - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.Master(() => { }); }); @@ -1357,7 +1354,7 @@ public void Non_parallel_master_should_except() [Fact] public void Non_parallel_single_should_except() { - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.Single(0, () => { }); }); @@ -1369,7 +1366,7 @@ public void Non_parallel_single_should_except() [Fact] public void Non_parallel_critical_should_except() { - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.Critical(0, () => { }); }); @@ -1381,7 +1378,7 @@ public void Non_parallel_critical_should_except() [Fact] public void Nested_worksharing_should_except() { - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelFor(0, 10, num_threads: 4, action: i => { @@ -1389,7 +1386,7 @@ public void Nested_worksharing_should_except() }); }); - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelRegion(num_threads: 4, action: () => { @@ -1400,7 +1397,7 @@ public void Nested_worksharing_should_except() }); }); - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelFor(0, 10, num_threads: 4, action: i => { @@ -1415,7 +1412,7 @@ public void Nested_worksharing_should_except() [Fact] public void Non_for_ordered_should_except() { - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.Ordered(0, () => { }); }); @@ -1427,7 +1424,7 @@ public void Non_for_ordered_should_except() [Fact] public void Non_parallel_GetThreadNum_should_except() { - Assert.Throws(() => + Assert.Throws(() => { int tid = DotMP.Parallel.GetThreadNum(); }); @@ -1460,47 +1457,47 @@ public void Absent_params_shouldnt_except() [Fact] public void Invalid_params_should_except() { - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelFor(10, 0, i => { }); }); - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelFor(-1, 10, i => { }); }); - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelFor(10, -5, i => { }); }); - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelFor(0, 10, chunk_size: 0, action: i => { }); }); - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelFor(0, 10, schedule: new Serial(), action: i => { }); }); - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelRegion(num_threads: 0, action: () => { }); }); - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelMasterTaskloop(10, 0, i => { }); }); - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelMasterTaskloop(0, 10, grainsize: 0, action: i => { }); }); - Assert.Throws(() => + Assert.Throws(() => { DotMP.Parallel.ParallelMasterTaskloop(0, 10, num_tasks: 0, action: i => { }); }); diff --git a/DotMP/Exceptions.cs b/DotMP/Exceptions.cs index 166b0456..2332cba7 100644 --- a/DotMP/Exceptions.cs +++ b/DotMP/Exceptions.cs @@ -5,18 +5,18 @@ * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser * General Public License as published by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. - + * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. - + * * You should have received a copy of the GNU Lesser General Public License along with this library; if not, * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ using System; -namespace DotMP +namespace DotMP.Exceptions { /// /// Exception thrown if a parallel-only construct is used outside of a parallel region. diff --git a/DotMP/Parallel.cs b/DotMP/Parallel.cs index 1197028b..d1a47eb5 100644 --- a/DotMP/Parallel.cs +++ b/DotMP/Parallel.cs @@ -17,6 +17,8 @@ using System; using System.Collections.Generic; using System.Threading; +using DotMP.Exceptions; +using DotMP.Schedulers; namespace DotMP { diff --git a/DotMP/Schedule.cs b/DotMP/Schedule.cs index 9f51598e..0e0080ec 100644 --- a/DotMP/Schedule.cs +++ b/DotMP/Schedule.cs @@ -5,11 +5,11 @@ * This library is free software; you can redistribute it and/or modify it under the terms of the GNU Lesser * General Public License as published by the Free Software Foundation; either version 2.1 of the License, or * (at your option) any later version. - + * * This library is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public * License for more details. - + * * You should have received a copy of the GNU Lesser General Public License along with this library; if not, * write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. */ @@ -57,23 +57,23 @@ public abstract class Schedule : IScheduler /// /// Internal holder for StaticScheduler object. /// - private static StaticScheduler static_scheduler = new StaticScheduler(); + private static Schedulers.StaticScheduler static_scheduler = new Schedulers.StaticScheduler(); /// /// Internal holder for the DynamicScheduler object. /// - private static DynamicScheduler dynamic_scheduler = new DynamicScheduler(); + private static Schedulers.DynamicScheduler dynamic_scheduler = new Schedulers.DynamicScheduler(); /// /// Internal holder for the GuidedScheduler object. /// - private static GuidedScheduler guided_scheduler = new GuidedScheduler(); + private static Schedulers.GuidedScheduler guided_scheduler = new Schedulers.GuidedScheduler(); /// /// Internal holder for the RuntimeScheduler object. /// - private static RuntimeScheduler runtime_scheduler = new RuntimeScheduler(); + private static Schedulers.RuntimeScheduler runtime_scheduler = new Schedulers.RuntimeScheduler(); /// /// Internal holder for the WorkStealingScheduler object. /// - private static WorkStealingScheduler workstealing_scheduler = new WorkStealingScheduler(); + private static Schedulers.WorkStealingScheduler workstealing_scheduler = new Schedulers.WorkStealingScheduler(); /// /// The static scheduling strategy. @@ -161,6 +161,8 @@ public abstract class Schedule : IScheduler #endregion #region Schedulers + namespace Schedulers + { /// /// Implementation of static scheduling. /// @@ -528,5 +530,6 @@ private bool DoSteal(int thread_id) return true; } } + } #endregion }