Skip to content

Commit

Permalink
segment into some namespaces
Browse files Browse the repository at this point in the history
  • Loading branch information
computablee committed Nov 21, 2023
1 parent f3cc30e commit 4e1172f
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 34 deletions.
45 changes: 21 additions & 24 deletions DotMP-Tests/ParallelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -1294,7 +1291,7 @@ public void Task_dependencies_work()
[Fact]
public void Non_parallel_for_should_except()
{
Assert.Throws<DotMP.NotInParallelRegionException>(() =>
Assert.Throws<DotMP.Exceptions.NotInParallelRegionException>(() =>
{
DotMP.Parallel.For(0, 10, action: i => { });
});
Expand All @@ -1306,7 +1303,7 @@ public void Non_parallel_for_should_except()
[Fact]
public void Nested_parallelism_should_except()
{
Assert.Throws<DotMP.CannotPerformNestedParallelismException>(() =>
Assert.Throws<DotMP.Exceptions.CannotPerformNestedParallelismException>(() =>
{
DotMP.Parallel.ParallelRegion(num_threads: 4, action: () =>
{
Expand All @@ -1321,7 +1318,7 @@ public void Nested_parallelism_should_except()
[Fact]
public void Non_parallel_sections_should_except()
{
Assert.Throws<DotMP.NotInParallelRegionException>(() =>
Assert.Throws<DotMP.Exceptions.NotInParallelRegionException>(() =>
{
DotMP.Parallel.Sections(() => { }, () => { });
});
Expand All @@ -1333,7 +1330,7 @@ public void Non_parallel_sections_should_except()
[Fact]
public void Non_parallel_barrier_should_except()
{
Assert.Throws<DotMP.NotInParallelRegionException>(() =>
Assert.Throws<DotMP.Exceptions.NotInParallelRegionException>(() =>
{
DotMP.Parallel.Barrier();
});
Expand All @@ -1345,7 +1342,7 @@ public void Non_parallel_barrier_should_except()
[Fact]
public void Non_parallel_master_should_except()
{
Assert.Throws<DotMP.NotInParallelRegionException>(() =>
Assert.Throws<DotMP.Exceptions.NotInParallelRegionException>(() =>
{
DotMP.Parallel.Master(() => { });
});
Expand All @@ -1357,7 +1354,7 @@ public void Non_parallel_master_should_except()
[Fact]
public void Non_parallel_single_should_except()
{
Assert.Throws<DotMP.NotInParallelRegionException>(() =>
Assert.Throws<DotMP.Exceptions.NotInParallelRegionException>(() =>
{
DotMP.Parallel.Single(0, () => { });
});
Expand All @@ -1369,7 +1366,7 @@ public void Non_parallel_single_should_except()
[Fact]
public void Non_parallel_critical_should_except()
{
Assert.Throws<DotMP.NotInParallelRegionException>(() =>
Assert.Throws<DotMP.Exceptions.NotInParallelRegionException>(() =>
{
DotMP.Parallel.Critical(0, () => { });
});
Expand All @@ -1381,15 +1378,15 @@ public void Non_parallel_critical_should_except()
[Fact]
public void Nested_worksharing_should_except()
{
Assert.Throws<DotMP.CannotPerformNestedWorksharingException>(() =>
Assert.Throws<DotMP.Exceptions.CannotPerformNestedWorksharingException>(() =>
{
DotMP.Parallel.ParallelFor(0, 10, num_threads: 4, action: i =>
{
DotMP.Parallel.Single(0, () => { });
});
});

Assert.Throws<DotMP.CannotPerformNestedWorksharingException>(() =>
Assert.Throws<DotMP.Exceptions.CannotPerformNestedWorksharingException>(() =>
{
DotMP.Parallel.ParallelRegion(num_threads: 4, action: () =>
{
Expand All @@ -1400,7 +1397,7 @@ public void Nested_worksharing_should_except()
});
});

Assert.Throws<DotMP.CannotPerformNestedWorksharingException>(() =>
Assert.Throws<DotMP.Exceptions.CannotPerformNestedWorksharingException>(() =>
{
DotMP.Parallel.ParallelFor(0, 10, num_threads: 4, action: i =>
{
Expand All @@ -1415,7 +1412,7 @@ public void Nested_worksharing_should_except()
[Fact]
public void Non_for_ordered_should_except()
{
Assert.Throws<DotMP.NotInParallelRegionException>(() =>
Assert.Throws<DotMP.Exceptions.NotInParallelRegionException>(() =>
{
DotMP.Parallel.Ordered(0, () => { });
});
Expand All @@ -1427,7 +1424,7 @@ public void Non_for_ordered_should_except()
[Fact]
public void Non_parallel_GetThreadNum_should_except()
{
Assert.Throws<DotMP.NotInParallelRegionException>(() =>
Assert.Throws<DotMP.Exceptions.NotInParallelRegionException>(() =>
{
int tid = DotMP.Parallel.GetThreadNum();
});
Expand Down Expand Up @@ -1460,47 +1457,47 @@ public void Absent_params_shouldnt_except()
[Fact]
public void Invalid_params_should_except()
{
Assert.Throws<DotMP.InvalidArgumentsException>(() =>
Assert.Throws<DotMP.Exceptions.InvalidArgumentsException>(() =>
{
DotMP.Parallel.ParallelFor(10, 0, i => { });
});

Assert.Throws<DotMP.InvalidArgumentsException>(() =>
Assert.Throws<DotMP.Exceptions.InvalidArgumentsException>(() =>
{
DotMP.Parallel.ParallelFor(-1, 10, i => { });
});

Assert.Throws<DotMP.InvalidArgumentsException>(() =>
Assert.Throws<DotMP.Exceptions.InvalidArgumentsException>(() =>
{
DotMP.Parallel.ParallelFor(10, -5, i => { });
});

Assert.Throws<DotMP.InvalidArgumentsException>(() =>
Assert.Throws<DotMP.Exceptions.InvalidArgumentsException>(() =>
{
DotMP.Parallel.ParallelFor(0, 10, chunk_size: 0, action: i => { });
});

Assert.Throws<DotMP.InvalidArgumentsException>(() =>
Assert.Throws<DotMP.Exceptions.InvalidArgumentsException>(() =>
{
DotMP.Parallel.ParallelFor(0, 10, schedule: new Serial(), action: i => { });
});

Assert.Throws<DotMP.InvalidArgumentsException>(() =>
Assert.Throws<DotMP.Exceptions.InvalidArgumentsException>(() =>
{
DotMP.Parallel.ParallelRegion(num_threads: 0, action: () => { });
});

Assert.Throws<DotMP.InvalidArgumentsException>(() =>
Assert.Throws<DotMP.Exceptions.InvalidArgumentsException>(() =>
{
DotMP.Parallel.ParallelMasterTaskloop(10, 0, i => { });
});

Assert.Throws<DotMP.InvalidArgumentsException>(() =>
Assert.Throws<DotMP.Exceptions.InvalidArgumentsException>(() =>
{
DotMP.Parallel.ParallelMasterTaskloop(0, 10, grainsize: 0, action: i => { });
});

Assert.Throws<DotMP.InvalidArgumentsException>(() =>
Assert.Throws<DotMP.Exceptions.InvalidArgumentsException>(() =>
{
DotMP.Parallel.ParallelMasterTaskloop(0, 10, num_tasks: 0, action: i => { });
});
Expand Down
6 changes: 3 additions & 3 deletions DotMP/Exceptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
/// <summary>
/// Exception thrown if a parallel-only construct is used outside of a parallel region.
Expand Down
2 changes: 2 additions & 0 deletions DotMP/Parallel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
using System;
using System.Collections.Generic;
using System.Threading;
using DotMP.Exceptions;
using DotMP.Schedulers;

namespace DotMP
{
Expand Down
17 changes: 10 additions & 7 deletions DotMP/Schedule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
*/
Expand Down Expand Up @@ -57,23 +57,23 @@ public abstract class Schedule : IScheduler
/// <summary>
/// Internal holder for StaticScheduler object.
/// </summary>
private static StaticScheduler static_scheduler = new StaticScheduler();
private static Schedulers.StaticScheduler static_scheduler = new Schedulers.StaticScheduler();
/// <summary>
/// Internal holder for the DynamicScheduler object.
/// </summary>
private static DynamicScheduler dynamic_scheduler = new DynamicScheduler();
private static Schedulers.DynamicScheduler dynamic_scheduler = new Schedulers.DynamicScheduler();
/// <summary>
/// Internal holder for the GuidedScheduler object.
/// </summary>
private static GuidedScheduler guided_scheduler = new GuidedScheduler();
private static Schedulers.GuidedScheduler guided_scheduler = new Schedulers.GuidedScheduler();
/// <summary>
/// Internal holder for the RuntimeScheduler object.
/// </summary>
private static RuntimeScheduler runtime_scheduler = new RuntimeScheduler();
private static Schedulers.RuntimeScheduler runtime_scheduler = new Schedulers.RuntimeScheduler();
/// <summary>
/// Internal holder for the WorkStealingScheduler object.
/// </summary>
private static WorkStealingScheduler workstealing_scheduler = new WorkStealingScheduler();
private static Schedulers.WorkStealingScheduler workstealing_scheduler = new Schedulers.WorkStealingScheduler();

/// <summary>
/// The static scheduling strategy.
Expand Down Expand Up @@ -161,6 +161,8 @@ public abstract class Schedule : IScheduler
#endregion

#region Schedulers
namespace Schedulers
{
/// <summary>
/// Implementation of static scheduling.
/// </summary>
Expand Down Expand Up @@ -528,5 +530,6 @@ private bool DoSteal(int thread_id)
return true;
}
}
}
#endregion
}

0 comments on commit 4e1172f

Please sign in to comment.