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

[FEATURE] Implement `ForCollapse` on `release/v2.0.0` branch #96

Closed computablee closed 10 months ago

computablee commented 11 months ago

Currently there is no support for hierarchical GPU parallelism. There is a ForCollapse method in the CPU API, so it makes sense to add ForCollapse for the upcoming GPU API as an elegant way to support hierarchical parallelism.

The following code should implement a hierarchical matmul:

DotMP.GPU.DataTo(b);
DotMP.GPU.DataToFrom(a);
DotMP.GPU.ParallelForCollapse((0, M), (0, N), (i, j, b, a) =>
{
    int total = 0;
    for (int k = 0; k < K; i++)
        total += a[i, k] * b[k, j];
    a[i, j] = total;
});

Additional context Self-assigning this issue.