computablee / DotMP

A collection of powerful abstractions for parallel programming in .NET with an OpenMP-like API.
https://computablee.github.io/DotMP/
GNU Lesser General Public License v2.1
29 stars 8 forks source link

Features #86

Closed computablee closed 11 months ago

computablee commented 11 months ago

Which issue are you addressing?

Closes #39

How have you addressed the issue?

There has been a significant amount of refactoring done in the inner scheduler code to make this possible. This PR adds the Wrappers.cs file, which contains several new delegates and the ForAction<T> class. The methods in Iter now defer to ForAction<T>.PerformLoop to execute a chunk. The overhead should be negligible for non-collapsed loops. For collapsed loops, new control flow exists to un-flatten the indices from the scheduler into 2D, 3D, 4D, or even higher dimensional loops. This infrastructure exists with both non-reduction and reduction loops. New methods have been implemented into the Parallel class, including ForCollapse, ForReductionCollapse, ParallelForCollapse, and ParallelForReductionCollapse, each with several overloads based on the collapse factor.

How have you tested your patch?

New tests have been written, namely Collapse_works and Reduction_collapse_works. Both of these are passing.

Additional work

This PR also creates the benchmarks/ subfolder, which will be the home for benchmarking DotMP. For a performance-oriented library, I am utterly ashamed at the lack of benchmarking that has happened. I hope to use BenchmarkDotNet to power benchmarks, but it is still a WIP.

I have also changed the access modifier of Lock._lock from internal to private. With the new API, there is no reason for _lock to be internal.

codecov[bot] commented 11 months ago

Codecov Report

All modified lines are covered by tests :white_check_mark:

Comparison is base (26c0fb1) 90.06% compared to head (2d604ef) 93.28%.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #86 +/- ## ========================================== + Coverage 90.06% 93.28% +3.22% ========================================== Files 11 12 +1 Lines 805 1102 +297 Branches 86 101 +15 ========================================== + Hits 725 1028 +303 + Misses 58 54 -4 + Partials 22 20 -2 ``` | [Files](https://app.codecov.io/gh/computablee/DotMP/pull/86?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Phillip+Allen+Lane) | Coverage Δ | | |---|---|---| | [DotMP/Iter.cs](https://app.codecov.io/gh/computablee/DotMP/pull/86?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Phillip+Allen+Lane#diff-RG90TVAvSXRlci5jcw==) | `100.00% <100.00%> (ø)` | | | [DotMP/Lock.cs](https://app.codecov.io/gh/computablee/DotMP/pull/86?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Phillip+Allen+Lane#diff-RG90TVAvTG9jay5jcw==) | `100.00% <ø> (ø)` | | | [DotMP/Parallel.cs](https://app.codecov.io/gh/computablee/DotMP/pull/86?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Phillip+Allen+Lane#diff-RG90TVAvUGFyYWxsZWwuY3M=) | `86.94% <100.00%> (+5.52%)` | :arrow_up: | | [DotMP/Wrappers.cs](https://app.codecov.io/gh/computablee/DotMP/pull/86?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Phillip+Allen+Lane#diff-RG90TVAvV3JhcHBlcnMuY3M=) | `100.00% <100.00%> (ø)` | |

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.