Skip to content

CPU 7. Atomics

Phillip Allen Lane edited this page Nov 27, 2023 · 1 revision

DotMP provides an atomics API. All atomics are static methods in the DotMP.Atomic static class. The following operations are supported:

Operation DotMP Function
a += b DotMP.Atomic.Add(ref a, b)
a -= b DotMP.Atomic.Sub(ref a, b)
a &= b DotMP.Atomic.And(ref a, b)
a |= b DotMP.Atomic.Or(ref a, b)
++a DotMP.Atomic.Inc(ref a)
--a DotMP.Atomic.Dec(ref a)

There are overloads for each of these methods for the int, uint, long, and ulong types. For DotMP versions prior to v1.6.0-pre2, Sub is only implemented for signed types (int and long).