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 7 forks source link

Create `DotMP-Builder` #36

Closed computablee closed 1 year ago

computablee commented 1 year ago

I am interested on working on a DotMP-Builder program that is capable of turning pragma-based C# programs parallelized with DotMP into programs that can actually be compiled by the .NET C# compiler.

It would be intended to resemble the pragma-based approach of C and C++ OpenMP as close as possible. For instance:

#pragma dmp parallel for num_threads(8) schedule(static) chunk_size(128)
for (int i = 0; i < 1_000_000; i++)
{
    y[i] += a * x[i];
}

would be transformed into:

DotMP.Parallel.ParallelFor(
    0, 1_000_000,
    num_threads: 8,
    schedule: DotMP.Schedule.Static,
    chunk_size: 128,
    action: i =>
{
    y[i] += a * x[i];
});

Furthermore, it would work as a command line application that would fully replace the dotnet CLI package. In essence, if you had a .NET Core solution with C# code resembling this pragma-based paradigm, you could call:

mpbuild run -c Release arg1 arg2 arg3

and mpbuild would take the following steps:

  1. Read the contents of the current directory
  2. Copy the contents into a .mptemp subdirectory
  3. Parse all of the *.cs files, replacing pragmas with DotMP function calls
  4. Run dotnet run -c Release arg1 arg2 arg3

This would allow the user to replace their workflow with mpbuild instead of dotnet to seamlessly implement pragma-based parallel programming in C#.

This issue serves for now as a way for me to gather interest and potential collaborators. Since this would involve a fair bit of parsing C# source code, and since I am not a compilers expert, I would love to see if anyone actually cares about this or would want to help before pouring tons of effort into this.