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

Add Atomics Support #3

Closed computablee closed 1 year ago

computablee commented 1 year ago

Some sort of atomic support would be really nice. I realize that it's difficult to implement in the way OpenMP does:

int x = 0;
#pragma omp parallel
{
    #pragma omp atomic
    ++x;
}

However, some sort of wrapper around System.Interlocked would be really nice! This would also be a great excuse to add an OpenMP.Atomic namespace, since this seems like a reasonable amount of added code. This code should go into Atomic.cs.

computablee commented 1 year ago

Implemented with https://github.com/computablee/OpenMP.NET/commit/ec051568ce4ca6b4e2be9dd63177fb2d3db3a335