|
vecmem 1.22.0
|
Class providing atomic operations for the VecMem code. More...
#include <vecmem/memory/atomic.hpp>
Public Types | |
Type definitions | |
| typedef T | value_type |
| Type managed by the object. | |
| typedef value_type | difference_type |
| Difference between two objects. | |
| typedef value_type * | pointer |
| Pointer to the value in global memory. | |
| typedef value_type & | reference |
| Reference to a value given by the user. | |
Public Member Functions | |
| VECMEM_HOST_AND_DEVICE | atomic (pointer ptr) |
| Constructor, with a pointer to the managed variable. | |
Value setter/getter functions | |
| VECMEM_HOST_AND_DEVICE void | store (value_type data) |
| Set the variable to the desired value. | |
| VECMEM_HOST_AND_DEVICE value_type | load () const |
| Get the value of the variable. | |
| VECMEM_HOST_AND_DEVICE value_type | exchange (value_type data) |
| Exchange the current value of the variable with a different one. | |
| VECMEM_HOST_AND_DEVICE bool | compare_exchange_strong (reference expected, value_type desired) |
| Compare against the current value, and exchange only if different. | |
Value modifier functions | |
| VECMEM_HOST_AND_DEVICE value_type | fetch_add (value_type data) |
| Add a chosen value to the stored variable. | |
| VECMEM_HOST_AND_DEVICE value_type | fetch_sub (value_type data) |
| Substitute a chosen value from the stored variable. | |
| VECMEM_HOST_AND_DEVICE value_type | fetch_and (value_type data) |
| Replace the current value with the specified value AND-ed to it. | |
| VECMEM_HOST_AND_DEVICE value_type | fetch_or (value_type data) |
| Replace the current value with the specified value OR-d to it. | |
| VECMEM_HOST_AND_DEVICE value_type | fetch_xor (value_type data) |
| Replace the current value with the specified value XOR-d to it. | |
Class providing atomic operations for the VecMem code.
It is only meant to be used with primitive types. Ones that CUDA, HIP and SYCL built-in functions exist for. So no structs, or even pointers.
Note that it does not perform atomic operations in host code! That may be implemented with std::atomic_ref in C++20 when VecMem switches to that standard. But for now all operations in host code are performed as "regular" operations.