Group Atomic Primitives
Portable atomic operations.
Grouped Function Overview
-
TResult atomicAdd(x, y)
Atomically add an integer to another integer. -
TResult atomicCas(x, cmp, y)
Atomic ompare-and-Swap operation. -
TResult atomicDec(x);
Atomically decrement an integer. -
TResult atomicInc(x);
Atomically increment an integer. -
TResult atomicOr(x, y);
Atomically combine two integers with OR operation. -
TResult atomicXor(x, y);
Atomically combine two integers with XOR operation.
Grouped Functions Detail
TResult atomicAdd(x, y)
- Defined in
- <seqan/parallel.h>
Parameters
x
|
Integer, by reference. |
---|---|
y
|
Integer to add to x. |
Returns
TResult |
The old value of x. |
---|
Remarks
This is equivalent to an atomic x += y.
Note that atomic fetch-and-add is limited to 32 bit and 64 bit with MSVC (64 bit is only available on 64 bit Windows).
You are responsible for correctly aligning x such that the atomic increment works on the hardware you target.
Data Races
TResult atomicCas(x, cmp, y)
- Defined in
- <seqan/parallel.h>
Parameters
x
|
Pointer to the integer to swap. |
---|---|
cmp
|
Value to compare x with. |
y
|
Value to set x to if it is equal to cmp. |
Returns
TResult |
Returns the original value of x. |
---|
Remarks
The pseudo code for this is as follows:
atomic { T val = *(&x); if (val == cmp) *(&x) = y; return val; }
On Windows, atomic CAS is only available for 16, 32, and 64 bit integers, 64 bit is only available on 64 bit Windows.
You are responsible for correctly aligning x such that the atomic increment works on the hardware you target.
Data Races
TResult atomicDec(x);
- Defined in
- <seqan/parallel.h>
Parameters
x
|
An integer, by reference. |
---|
Returns
TResult |
The old value of $x$, TResult has the same type as x. |
---|
Remarks
This is equivalent to an atomic --x.
Note that atomic decrements are limited to 32 bit and 64 bit with MSVC (64 bit is only available on 64 bit Windows).
You are responsible for correctly aligning x such that the atomic decrement works on the hardware you target.
Data Races
TResult atomicInc(x);
- Defined in
- <seqan/parallel.h>
Parameters
x
|
An integer, by reference. |
---|
Returns
TResult |
The old value of $x$, TResult has the same type as x. |
---|
Remarks
This is equivalent to an atomic ++x.
Note that atomic increments are limited to 32 bit and 64 bit with MSVC (64 bit is only available on 64 bit Windows).
You are responsible for correctly aligning x such that the atomic increment works on the hardware you target.
Data Races
TResult atomicOr(x, y);
- Defined in
- <seqan/parallel.h>
Parameters
x
|
Integer, by reference. |
---|---|
y
|
Integer to combine with OR operation. |
Returns
TResult |
The old value of x, TResult is the type of x. |
---|
Remarks
This is equivalent to an atomic x |= y.
Atomic fetch-and-or for 64 bit integers is only available on 64 bit processors when targeting Intel.
Atomic fetch-and-or does not work in VS8 on 64 bit Windows, you can only use atomicOr() portably on 32 and 64 bit integers.
You are responsible for correctly aligning x such that the atomic increment works on the hardware you target.
Data Races
TResult atomicXor(x, y);
- Defined in
- <seqan/parallel.h>
Parameters
x
|
Integer, by reference. |
---|---|
y
|
Integer to combine with XOR operation. |
Returns
TResult |
The old value of x, TResult is the type of x. |
---|
Remarks
This is equivalent to an atomic x ^= y.
Atomic fetch-and-xor fxor 64 bit integers is only available on 64 bit processxors when targeting Intel.
Atomic fetch-and-xor does not wxork in VS8 on 64 bit Windows, you can only use atomicXor() pxortably on 32 and 64 bit integers.
You are responsible fxor cxorrectly aligning x such that the atomic increment wxorks on the hardware you target.