DASH  0.3.0
dash::atomic Namespace Reference

Routines to perform atomic operations on atomics residing in the global address space. More...

Functions

template<typename T >
load (const dash::GlobRef< dash::Atomic< T >> &ref)
 Get the value of the shared atomic. More...
 
template<typename T >
void store (const dash::GlobRef< dash::Atomic< T >> &ref, const T &value)
 Set the value of the atomic reference. More...
 
template<typename T >
exchange (const dash::GlobRef< dash::Atomic< T >> &ref, const T &value)
 Atomically sets the value of the atomic reference and returns the old value. More...
 
template<typename T >
bool compare_exchange (const dash::GlobRef< dash::Atomic< T >> &ref, const T &expected, const T &desired)
 Atomically compares the value with the value of expected and if those are bitwise-equal, replaces the former with desired. More...
 
template<typename T , typename BinaryOp >
void op (const dash::GlobRef< dash::Atomic< T >> &ref, const BinaryOp binary_op, const T &value)
 Atomically executes specified operation on the referenced shared value. More...
 
template<typename T , typename BinaryOp >
fetch_op (const dash::GlobRef< dash::Atomic< T >> &ref, const BinaryOp binary_op, const T &value)
 Atomic fetch-and-op operation on the referenced shared value. More...
 
template<typename T >
std::enable_if< std::is_integral< T >::value, void >::type add (const dash::GlobRef< dash::Atomic< T >> &ref, const T &value)
 Atomic add operation on the referenced shared value. More...
 
template<typename T >
std::enable_if< std::is_integral< T >::value, void >::type sub (const dash::GlobRef< dash::Atomic< T >> &ref, const T &value)
 Atomic subtract operation on the referenced shared value. More...
 
template<typename T >
std::enable_if< std::is_integral< T >::value, void >::type multiply (const dash::GlobRef< dash::Atomic< T >> &ref, const T &value)
 Atomic multiply operation on the referenced shared value. More...
 
template<typename T >
std::enable_if< std::is_integral< T >::value, T >::type fetch_add (const dash::GlobRef< dash::Atomic< T >> &ref, const T &value)
 Atomic fetch-and-add operation on the referenced shared value. More...
 
template<typename T >
std::enable_if< std::is_integral< T >::value, T >::type fetch_sub (const dash::GlobRef< dash::Atomic< T >> &ref, const T &value)
 Atomic fetch-and-sub operation on the referenced shared value. More...
 

Detailed Description

Routines to perform atomic operations on atomics residing in the global address space.

int N = dash::size();
dash::fill(array.begin(), array.end(), 0);
// each unit adds 1 to each array position
for(auto & el : array){
}
// postcondition:
// array = {N,N,N,N,...}

Function Documentation

◆ add()

template<typename T >
std::enable_if< std::is_integral<T>::value, void>::type dash::atomic::add ( const dash::GlobRef< dash::Atomic< T >> &  ref,
const T &  value 
)

Atomic add operation on the referenced shared value.

Definition at line 114 of file Operation.h.

117 {
118  ref.add(value);
119 }

◆ compare_exchange()

template<typename T >
bool dash::atomic::compare_exchange ( const dash::GlobRef< dash::Atomic< T >> &  ref,
const T &  expected,
const T &  desired 
)

Atomically compares the value with the value of expected and if those are bitwise-equal, replaces the former with desired.

Returns
True if value is exchanged

Definition at line 66 of file Operation.h.

70 {
71  return ref.compare_exchange(expected, desired);
72 }

◆ exchange()

template<typename T >
T dash::atomic::exchange ( const dash::GlobRef< dash::Atomic< T >> &  ref,
const T &  value 
)

Atomically sets the value of the atomic reference and returns the old value.

Definition at line 53 of file Operation.h.

55 {
56  return ref.exchange(value);
57 }

◆ fetch_add()

template<typename T >
std::enable_if< std::is_integral<T>::value, T>::type dash::atomic::fetch_add ( const dash::GlobRef< dash::Atomic< T >> &  ref,
const T &  value 
)

Atomic fetch-and-add operation on the referenced shared value.

Returns
The value of the referenced shared variable before the operation.
Parameters
valueValue to be added to global atomic variable.

Definition at line 160 of file Operation.h.

164 {
165  return ref.fetch_add(value);
166 }

◆ fetch_op()

template<typename T , typename BinaryOp >
T dash::atomic::fetch_op ( const dash::GlobRef< dash::Atomic< T >> &  ref,
const BinaryOp  binary_op,
const T &  value 
)

Atomic fetch-and-op operation on the referenced shared value.

Returns
The value of the referenced shared variable before the operation.
Parameters
valueValue to be added to global atomic variable.

Definition at line 98 of file Operation.h.

103 {
104  return ref.fetch_op(binary_op, value);
105 }

◆ fetch_sub()

template<typename T >
std::enable_if< std::is_integral<T>::value, T>::type dash::atomic::fetch_sub ( const dash::GlobRef< dash::Atomic< T >> &  ref,
const T &  value 
)

Atomic fetch-and-sub operation on the referenced shared value.

Returns
The value of the referenced shared variable before the operation.
Parameters
valueValue to be subtracted from global atomic variable.

Definition at line 178 of file Operation.h.

182 {
183  return ref.fetch_sub(value);
184 }

◆ load()

template<typename T >
T dash::atomic::load ( const dash::GlobRef< dash::Atomic< T >> &  ref)

Get the value of the shared atomic.

Definition at line 34 of file Operation.h.

34  {
35  return ref.load();
36 }

◆ multiply()

template<typename T >
std::enable_if< std::is_integral<T>::value, void>::type dash::atomic::multiply ( const dash::GlobRef< dash::Atomic< T >> &  ref,
const T &  value 
)

Atomic multiply operation on the referenced shared value.

Definition at line 142 of file Operation.h.

145 {
146  ref.multiply(value);
147 }

◆ op()

template<typename T , typename BinaryOp >
void dash::atomic::op ( const dash::GlobRef< dash::Atomic< T >> &  ref,
const BinaryOp  binary_op,
const T &  value 
)

Atomically executes specified operation on the referenced shared value.

Parameters
valueValue to be added to global atomic variable.

Definition at line 80 of file Operation.h.

85 {
86  ref.op(binary_op, value);
87 }

◆ store()

template<typename T >
void dash::atomic::store ( const dash::GlobRef< dash::Atomic< T >> &  ref,
const T &  value 
)

Set the value of the atomic reference.

Definition at line 42 of file Operation.h.

44 {
45  ref.store(value);
46 }

◆ sub()

template<typename T >
std::enable_if< std::is_integral<T>::value, void>::type dash::atomic::sub ( const dash::GlobRef< dash::Atomic< T >> &  ref,
const T &  value 
)

Atomic subtract operation on the referenced shared value.

Definition at line 128 of file Operation.h.

131 {
132  ref.sub(value);
133 }