vecmem 1.14.0
All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Pages
Public Member Functions | List of all members
vecmem::cuda::device_atomic_ref< T, address > Class Template Reference

Custom implementation for atomic operations in CUDA device code. More...

#include <vecmem/memory/details/cuda_device_atomic_ref.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_typepointer
 Pointer to the value in global memory.
 
typedef value_typereference
 Reference to a value given by the user.
 

Public Member Functions

VECMEM_HOST_AND_DEVICE device_atomic_ref (reference ref)
 Constructor, with a pointer to the managed variable.
 
VECMEM_HOST_AND_DEVICE device_atomic_ref (const device_atomic_ref &parent)
 Copy constructor.
 
device_atomic_refoperator= (const device_atomic_ref &)=delete
 Disable the assignment operator.
 
Value setter/getter functions
VECMEM_HOST_AND_DEVICE value_type operator= (value_type data) const
 Assigns a value desired to the referenced object.
 
VECMEM_HOST_AND_DEVICE void store (value_type data, memory_order order=memory_order::seq_cst) const
 Set the variable to the desired value.
 
VECMEM_HOST_AND_DEVICE value_type load (memory_order order=memory_order::seq_cst) const
 Get the value of the variable.
 
VECMEM_HOST_AND_DEVICE value_type exchange (value_type data, memory_order order=memory_order::seq_cst) const
 Exchange the current value of the variable with a different one.
 
VECMEM_HOST_AND_DEVICE bool compare_exchange_strong (reference expected, value_type desired, memory_order success, memory_order failure) const
 Compare against the current value, and exchange only if different.
 
VECMEM_HOST_AND_DEVICE bool compare_exchange_strong (reference expected, value_type desired, memory_order order=memory_order::seq_cst) const
 Compare against the current value, and exchange only if different.
 
Value modifier functions
VECMEM_HOST_AND_DEVICE value_type fetch_add (value_type data, memory_order order=memory_order::seq_cst) const
 Add a chosen value to the stored variable.
 
VECMEM_HOST_AND_DEVICE value_type fetch_sub (value_type data, memory_order order=memory_order::seq_cst) const
 Substitute a chosen value from the stored variable.
 
VECMEM_HOST_AND_DEVICE value_type fetch_and (value_type data, memory_order order=memory_order::seq_cst) const
 Replace the current value with the specified value AND-ed to it.
 
VECMEM_HOST_AND_DEVICE value_type fetch_or (value_type data, memory_order order=memory_order::seq_cst) const
 Replace the current value with the specified value OR-d to it.
 
VECMEM_HOST_AND_DEVICE value_type fetch_xor (value_type data, memory_order order=memory_order::seq_cst) const
 Replace the current value with the specified value XOR-d to it.
 

Detailed Description

template<typename T, device_address_space address = device_address_space::global>
class vecmem::cuda::device_atomic_ref< T, address >

Custom implementation for atomic operations in CUDA device code.

Note
All member functions are declared VECMEM_HOST_DEVICE, because this class may be used from functions that also carry that setup. (Like functions in vecmem::device_vector.) Even though this class cannot be used in host code, CUDA and HIP are sensitive to these sort of declarations being consistent.
Template Parameters
TType to perform atomic operations on
addressThe device address space to use

Member Function Documentation

◆ operator=()

template<typename T , device_address_space address>
VECMEM_HOST_AND_DEVICE auto vecmem::cuda::device_atomic_ref< T, address >::operator= ( value_type  data) const

Assigns a value desired to the referenced object.

See also
vecmem::cuda::atomic_ref::store

The documentation for this class was generated from the following files: