DASH  0.3.0
dash::GlobRef< dash::Atomic< T > > Class Template Reference

Specialization for atomic values. More...

#include <GlobAtomicRef.h>

Public Types

using value_type = T
 
using const_value_type = typename std::add_const< T >::type
 
using nonconst_value_type = typename std::remove_const< T >::type
 
using atomic_t = dash::Atomic< T >
 
using const_atomic_t = typename dash::Atomic< const_value_type >
 
using nonconst_atomic_t = typename dash::Atomic< nonconst_value_type >
 
using self_t = GlobRef< atomic_t >
 
using const_type = GlobRef< const_atomic_t >
 
using nonconst_type = GlobRef< dash::Atomic< nonconst_value_type > >
 

Public Member Functions

 GlobRef ()=delete
 Reference semantics forbid declaration without definition. More...
 
 GlobRef (dart_gptr_t dart_gptr)
 Constructor: Create an atomic reference to a element in global memory. More...
 
template<typename PatternT >
 GlobRef (const GlobPtr< const_atomic_t, PatternT > &gptr)
 Constructor, creates an GlobRef object referencing an element in global memory. More...
 
template<typename PatternT >
 GlobRef (const GlobPtr< nonconst_atomic_t, PatternT > &gptr)
 
template<typename _T , int = internal::enable_implicit_copy_ctor<value_type, _T>::value>
 GlobRef (const GlobRef< dash::Atomic< _T >> &gref)
 Copy constructor: Implicit if at least one of the following conditions is satisfied: 1) value_type and _T are exactly the same types (including const and volatile qualifiers 2) value_type and _T are the same types after removing const and volatile qualifiers and value_type itself is const. More...
 
template<typename _T , long = internal::enable_explicit_copy_ctor<value_type, _T>::value>
 GlobRef (const GlobRef< dash::Atomic< _T >> &gref)
 Copy constructor: Explicit if the following conditions are satisfied. More...
 
template<typename _T , int = internal::enable_implicit_copy_ctor<value_type, _T>::value>
 GlobRef (const GlobAsyncRef< dash::Atomic< _T >> &gref)
 Copy constructor: Implicit if at least one of the following conditions is satisfied: 1) value_type and _T are exactly the same types (including const and volatile qualifiers 2) value_type and _T are the same types after removing const and volatile qualifiers and value_type itself is const. More...
 
template<typename _T , long = internal::enable_explicit_copy_ctor<value_type, _T>::value>
 GlobRef (const GlobAsyncRef< dash::Atomic< _T >> &gref)
 Copy constructor: Explicit if the following conditions are satisfied. More...
 
 GlobRef (self_t &&other)=default
 Move Constructor. More...
 
self_toperator= (const self_t &other) const
 Copy Assignment: Copies atomically the value from other. More...
 
self_toperator= (self_t &&other)
 Move Assignment: Redirects to Copy Assignment. More...
 
 operator T () const
 
dart_gptr_t dart_gptr () const
 
bool is_local () const
 Checks whether the globally referenced element is in the calling unit's local memory. More...
 
operator= (const T &value) const
 atomically assigns value More...
 
void set (const T &value) const
 Set the value of the shared atomic variable. More...
 
void store (const T &value) const
 Set the value of the shared atomic variable. More...
 
get () const
 atomically fetches value More...
 
load () const
 Get the value of the shared atomic variable. More...
 
template<typename BinaryOp >
void op (BinaryOp binary_op, const T &value) const
 Atomically executes specified operation on the referenced shared value. More...
 
template<typename BinaryOp >
fetch_op (BinaryOp binary_op, const T &value) const
 Atomic fetch-and-op operation on the referenced shared value. More...
 
exchange (const T &value) const
 Atomically exchanges value. More...
 
bool compare_exchange (const T &expected, const T &desired) const
 Atomically compares the value with the value of expected and if thosei are bitwise-equal, replaces the former with desired. More...
 
void add (const T &value) const
 DASH specific variant which is faster than fetch_add but does not return value. More...
 
fetch_add (const T &value) const
 Atomic fetch-and-add operation on the referenced shared value. More...
 
void sub (const T &value) const
 DASH specific variant which is faster than fetch_sub but does not return value. More...
 
fetch_sub (const T &value) const
 Atomic fetch-and-sub operation on the referenced shared value. More...
 
void multiply (const T &value) const
 DASH specific variant which is faster than fetch_multiply but does not return value. More...
 
fetch_multiply (const T &value) const
 Atomic fetch-and-multiply operation on the referenced shared value. More...
 
operator++ () const
 prefix atomically increment value by one More...
 
operator++ (int) const
 postfix atomically increment value by one More...
 
operator-- () const
 prefix atomically decrement value by one More...
 
operator-- (int) const
 postfix atomically decrement value by one More...
 
operator+= (const T &value) const
 atomically increment value by ref More...
 
operator-= (const T &value) const
 atomically decrement value by ref More...
 

Friends

template<typename U >
std::ostream & operator<< (std::ostream &os, const GlobRef< U > &gref)
 

Detailed Description

template<typename T>
class dash::GlobRef< dash::Atomic< T > >

Specialization for atomic values.

All atomic operations are const as the GlobRef does not own the atomic values.

Definition at line 23 of file GlobAtomicRef.h.

Constructor & Destructor Documentation

◆ GlobRef() [1/9]

template<typename T >
dash::GlobRef< dash::Atomic< T > >::GlobRef ( )
delete

Reference semantics forbid declaration without definition.

◆ GlobRef() [2/9]

template<typename T >
dash::GlobRef< dash::Atomic< T > >::GlobRef ( dart_gptr_t  dart_gptr)
inlineexplicit

Constructor: Create an atomic reference to a element in global memory.

Definition at line 63 of file GlobAtomicRef.h.

64  : _gptr(dart_gptr)
65  {
66  DASH_LOG_TRACE_VAR("GlobRef(dart_gptr_t)", dart_gptr);
67  }

◆ GlobRef() [3/9]

template<typename T >
template<typename PatternT >
dash::GlobRef< dash::Atomic< T > >::GlobRef ( const GlobPtr< const_atomic_t, PatternT > &  gptr)
inlineexplicit

Constructor, creates an GlobRef object referencing an element in global memory.

Parameters
gptrPointer to referenced object in global memory

Definition at line 74 of file GlobAtomicRef.h.

77  : GlobRef(gptr.dart_gptr())
78  {
79  static_assert(
80  std::is_same<value_type, const_value_type>::value,
81  "Cannot create GlobRef<Atomic<T>> from GlobPtr<Atomic<const T>>!");
82  }
GlobRef()=delete
Reference semantics forbid declaration without definition.

◆ GlobRef() [4/9]

template<typename T >
template<typename PatternT >
dash::GlobRef< dash::Atomic< T > >::GlobRef ( const GlobPtr< nonconst_atomic_t, PatternT > &  gptr)
inlineexplicit
Parameters
gptrPointer to referenced object in global memory

Definition at line 85 of file GlobAtomicRef.h.

88  : GlobRef(gptr.dart_gptr())
89  {
90  }
GlobRef()=delete
Reference semantics forbid declaration without definition.

◆ GlobRef() [5/9]

template<typename T >
template<typename _T , int = internal::enable_implicit_copy_ctor<value_type, _T>::value>
dash::GlobRef< dash::Atomic< T > >::GlobRef ( const GlobRef< dash::Atomic< _T >> &  gref)
inline

Copy constructor: Implicit if at least one of the following conditions is satisfied: 1) value_type and _T are exactly the same types (including const and volatile qualifiers 2) value_type and _T are the same types after removing const and volatile qualifiers and value_type itself is const.

Definition at line 103 of file GlobAtomicRef.h.

104  : GlobRef(gref.dart_gptr())
105  {
106  }
GlobRef()=delete
Reference semantics forbid declaration without definition.

◆ GlobRef() [6/9]

template<typename T >
template<typename _T , long = internal::enable_explicit_copy_ctor<value_type, _T>::value>
dash::GlobRef< dash::Atomic< T > >::GlobRef ( const GlobRef< dash::Atomic< _T >> &  gref)
inlineexplicit

Copy constructor: Explicit if the following conditions are satisfied.

1) value_type and _T are the same types after excluding const and volatile qualifiers 2) value_type is const and _T is non-const

Definition at line 117 of file GlobAtomicRef.h.

118  : GlobRef(gref.dart_gptr())
119  {
120  }
GlobRef()=delete
Reference semantics forbid declaration without definition.

◆ GlobRef() [7/9]

template<typename T >
template<typename _T , int = internal::enable_implicit_copy_ctor<value_type, _T>::value>
dash::GlobRef< dash::Atomic< T > >::GlobRef ( const GlobAsyncRef< dash::Atomic< _T >> &  gref)
inline

Copy constructor: Implicit if at least one of the following conditions is satisfied: 1) value_type and _T are exactly the same types (including const and volatile qualifiers 2) value_type and _T are the same types after removing const and volatile qualifiers and value_type itself is const.

Definition at line 133 of file GlobAtomicRef.h.

134  : GlobRef(gref.dart_gptr())
135  {
136  }
GlobRef()=delete
Reference semantics forbid declaration without definition.

◆ GlobRef() [8/9]

template<typename T >
template<typename _T , long = internal::enable_explicit_copy_ctor<value_type, _T>::value>
dash::GlobRef< dash::Atomic< T > >::GlobRef ( const GlobAsyncRef< dash::Atomic< _T >> &  gref)
inlineexplicit

Copy constructor: Explicit if the following conditions are satisfied.

1) value_type and _T are the same types after excluding const and volatile qualifiers 2) value_type is const and _T is non-const

Definition at line 147 of file GlobAtomicRef.h.

References dash::GlobRef< T >::GlobRef().

148  : GlobRef(gref.dart_gptr())
149  {
150  }
GlobRef()=delete
Reference semantics forbid declaration without definition.

◆ GlobRef() [9/9]

template<typename T >
dash::GlobRef< dash::Atomic< T > >::GlobRef ( self_t &&  other)
default

Move Constructor.

Member Function Documentation

◆ add()

template<typename T >
void dash::GlobRef< dash::Atomic< T > >::add ( const T &  value) const
inline

DASH specific variant which is faster than fetch_add but does not return value.

Definition at line 399 of file GlobAtomicRef.h.

400  {
401  static_assert(
402  std::is_same<value_type, nonconst_value_type>::value,
403  "Cannot modify value referenced by GlobRef<const T>!");
404  op(dash::plus<T>(), value);
405  }
Reduce operands to their sum.
Definition: Operation.h:163
void op(BinaryOp binary_op, const T &value) const
Atomically executes specified operation on the referenced shared value.

◆ compare_exchange()

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

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

Returns
True if value is exchanged
See also
dash::atomic::compare_exchange

Definition at line 364 of file GlobAtomicRef.h.

365  {
366  static_assert(
367  dash::dart_punned_datatype<T>::value != DART_TYPE_UNDEFINED,
368  "Integral type or type smaller than 64bit required for "
369  "compare_exchange!");
370  static_assert(
371  !std::is_floating_point<T>::value,
372  "compare_exchange not available for floating point!");
373  static_assert(
374  std::is_same<value_type, nonconst_value_type>::value,
375  "Cannot modify value referenced by GlobRef<const T>!");
376  DASH_LOG_DEBUG_VAR("GlobRef<Atomic>.compare_exchange()", desired);
377  DASH_LOG_TRACE_VAR("GlobRef<Atomic>.compare_exchange", _gptr);
378  DASH_LOG_TRACE_VAR("GlobRef<Atomic>.compare_exchange", expected);
379  DASH_LOG_TRACE_VAR(
380  "GlobRef<Atomic>.compare_exchange", typeid(desired).name());
381  nonconst_value_type result;
383  _gptr,
384  &desired,
385  &expected,
386  &result,
388  dart_flush(_gptr);
389  DASH_ASSERT_EQ(DART_OK, ret, "dart_compare_and_swap failed");
390  DASH_LOG_DEBUG_VAR(
391  "GlobRef<Atomic>.compare_exchange >", (expected == result));
392  return (expected == result);
393  }
Signals success.
Definition: dart_types.h:33
Type trait for mapping to punned DART data type for reduce operations.
Definition: Types.h:104
dart_ret_t dart_compare_and_swap(dart_gptr_t gptr, const void *value, const void *compare, void *result, dart_datatype_t dtype)
Atomically replace the single value pointed to by gptr with the the value in value if it is equal to ...
dart_ret_t
Return values of functions in the DART interface.
Definition: dart_types.h:30
dart_ret_t dart_flush(dart_gptr_t gptr)
Guarantee completion of all outstanding operations involving a segment on a certain unit...

◆ exchange()

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::exchange ( const T &  value) const
inline

Atomically exchanges value.

Definition at line 351 of file GlobAtomicRef.h.

352  {
353  return fetch_op(dash::second<T>(), value);
354  }
Returns second operand.
Definition: Operation.h:218
T fetch_op(BinaryOp binary_op, const T &value) const
Atomic fetch-and-op operation on the referenced shared value.

◆ fetch_add()

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::fetch_add ( const T &  value) const
inline

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 413 of file GlobAtomicRef.h.

416  {
417  return fetch_op(dash::plus<T>(), value);
418  }
Reduce operands to their sum.
Definition: Operation.h:163
T fetch_op(BinaryOp binary_op, const T &value) const
Atomic fetch-and-op operation on the referenced shared value.

◆ fetch_multiply()

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::fetch_multiply ( const T &  value) const
inline

Atomic fetch-and-multiply 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 457 of file GlobAtomicRef.h.

460  {
461  return fetch_op(dash::multiply<T>(), value);
462  }
Reduce operands to their product.
Definition: Operation.h:182
T fetch_op(BinaryOp binary_op, const T &value) const
Atomic fetch-and-op operation on the referenced shared value.

◆ fetch_op()

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

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 316 of file GlobAtomicRef.h.

320  {
321  static_assert(
322  dash::dart_punned_datatype<T>::value != DART_TYPE_UNDEFINED,
323  "Basic type or type smaller than 64bit required for "
324  "atomic fetch_op!");
325  static_assert(
326  dash::dart_datatype<T>::value != DART_TYPE_UNDEFINED ||
327  binary_op.op_kind() != dash::internal::OpKind::ARITHMETIC,
328  "Atomic arithmetic operations only valid on basic types!");
329  static_assert(
330  std::is_same<value_type, nonconst_value_type>::value,
331  "Cannot modify value referenced by GlobRef<Atomic<const T>>!");
332  DASH_LOG_DEBUG_VAR("GlobRef<Atomic>.fetch_op()", value);
333  DASH_LOG_TRACE_VAR("GlobRef<Atomic>.fetch_op", _gptr);
334  DASH_LOG_TRACE_VAR("GlobRef<Atomic>.fetch_op", typeid(value).name());
335  nonconst_value_type res;
337  _gptr,
338  &value,
339  &res,
341  binary_op.dart_operation());
342  dart_flush(_gptr);
343  DASH_ASSERT_EQ(DART_OK, ret, "dart_fetch_op failed");
344  DASH_LOG_DEBUG_VAR("GlobRef<Atomic>.fetch_op >", res);
345  return res;
346  }
Signals success.
Definition: dart_types.h:33
Type trait for mapping to punned DART data type for reduce operations.
Definition: Types.h:104
Type trait for mapping to DART data types.
Definition: Types.h:96
dart_ret_t
Return values of functions in the DART interface.
Definition: dart_types.h:30
dart_ret_t dart_fetch_and_op(dart_gptr_t gptr, const void *value, void *result, dart_datatype_t dtype, dart_operation_t op)
Perform an element-wise atomic update on the value of type dtype pointed to by gptr by applying the o...
dart_ret_t dart_flush(dart_gptr_t gptr)
Guarantee completion of all outstanding operations involving a segment on a certain unit...

◆ fetch_sub()

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::fetch_sub ( const T &  value) const
inline

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 435 of file GlobAtomicRef.h.

438  {
439  return fetch_op(dash::plus<T>(), -value);
440  }
Reduce operands to their sum.
Definition: Operation.h:163
T fetch_op(BinaryOp binary_op, const T &value) const
Atomic fetch-and-op operation on the referenced shared value.

◆ get()

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::get ( ) const
inline

atomically fetches value

Definition at line 243 of file GlobAtomicRef.h.

244  {
245  static_assert(
246  dash::dart_punned_datatype<T>::value != DART_TYPE_UNDEFINED,
247  "Basic type or type smaller than 64bit required for "
248  "atomic get!");
249  DASH_LOG_DEBUG("GlobRef<Atomic>.load()");
250  DASH_LOG_TRACE_VAR("GlobRef<Atomic>.load", _gptr);
251  nonconst_value_type nothing;
252  nonconst_value_type result;
254  _gptr,
255  &nothing,
256  &result,
258  DART_OP_NO_OP);
259  dart_flush_local(_gptr);
260  DASH_ASSERT_EQ(DART_OK, ret, "dart_accumulate failed");
261  DASH_LOG_DEBUG_VAR("GlobRef<Atomic>.get >", result);
262  return result;
263  }
Signals success.
Definition: dart_types.h:33
No operation.
Definition: dart_types.h:97
dart_ret_t dart_flush_local(dart_gptr_t gptr)
Guarantee local completion of all outstanding operations involving a segment on a certain unit...
Type trait for mapping to punned DART data type for reduce operations.
Definition: Types.h:104
dart_ret_t
Return values of functions in the DART interface.
Definition: dart_types.h:30
dart_ret_t dart_fetch_and_op(dart_gptr_t gptr, const void *value, void *result, dart_datatype_t dtype, dart_operation_t op)
Perform an element-wise atomic update on the value of type dtype pointed to by gptr by applying the o...

◆ is_local()

template<typename T >
bool dash::GlobRef< dash::Atomic< T > >::is_local ( ) const
inline

Checks whether the globally referenced element is in the calling unit's local memory.

Definition at line 188 of file GlobAtomicRef.h.

189  {
190  return dash::internal::is_local(_gptr);
191  }
bool is_local() const
Checks whether the globally referenced element is in the calling unit&#39;s local memory.
Definition: GlobRef.h:356

◆ load()

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::load ( ) const
inline

Get the value of the shared atomic variable.

Definition at line 268 of file GlobAtomicRef.h.

269  {
270  return get();
271  }

◆ multiply()

template<typename T >
void dash::GlobRef< dash::Atomic< T > >::multiply ( const T &  value) const
inline

DASH specific variant which is faster than fetch_multiply but does not return value.

Definition at line 446 of file GlobAtomicRef.h.

447  {
448  op(dash::multiply<T>(), value);
449  }
Reduce operands to their product.
Definition: Operation.h:182
void op(BinaryOp binary_op, const T &value) const
Atomically executes specified operation on the referenced shared value.

◆ op()

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

Atomically executes specified operation on the referenced shared value.

Parameters
binary_opBinary operation to be performed on global atomic variable
valueValue to be used in binary op on global atomic variable.

Definition at line 277 of file GlobAtomicRef.h.

282  {
283  static_assert(
284  dash::dart_punned_datatype<T>::value != DART_TYPE_UNDEFINED,
285  "Basic type or type smaller than 64bit required for "
286  "atomic operation!");
287  static_assert(
288  dash::dart_datatype<T>::value != DART_TYPE_UNDEFINED ||
289  binary_op.op_kind() != dash::internal::OpKind::ARITHMETIC,
290  "Atomic arithmetic operations only valid on basic types");
291  static_assert(
292  std::is_same<value_type, nonconst_value_type>::value,
293  "Cannot modify value referenced by GlobRef<Atomic<const T>>!");
294  DASH_LOG_DEBUG_VAR("GlobRef<Atomic>.op()", value);
295  DASH_LOG_TRACE_VAR("GlobRef<Atomic>.op", _gptr);
296  nonconst_value_type acc = value;
297  DASH_LOG_TRACE("GlobRef<Atomic>.op", "dart_accumulate");
299  _gptr,
300  &acc,
301  1,
303  binary_op.dart_operation());
304  dart_flush(_gptr);
305  DASH_ASSERT_EQ(DART_OK, ret, "dart_accumulate failed");
306  DASH_LOG_DEBUG_VAR("GlobRef<Atomic>.op >", acc);
307  }
Signals success.
Definition: dart_types.h:33
dart_ret_t dart_accumulate(dart_gptr_t gptr, const void *values, size_t nelem, dart_datatype_t dtype, dart_operation_t op)
Perform an element-wise atomic update on the values pointed to by gptr by applying the operation op w...
Type trait for mapping to punned DART data type for reduce operations.
Definition: Types.h:104
Type trait for mapping to DART data types.
Definition: Types.h:96
dart_ret_t
Return values of functions in the DART interface.
Definition: dart_types.h:30
dart_ret_t dart_flush(dart_gptr_t gptr)
Guarantee completion of all outstanding operations involving a segment on a certain unit...

◆ operator++() [1/2]

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::operator++ ( ) const
inline

prefix atomically increment value by one

Returns
The value of the referenced shared variable after the operation.
Note
This operator does not return a reference but a copy of the value in order to ensure atomicity. This is consistent with the C++ std::atomic operator++, see http://en.cppreference.com/w/cpp/atomic/atomic/operator_arith.

Definition at line 475 of file GlobAtomicRef.h.

476  {
477  return fetch_add(1) + 1;
478  }
T fetch_add(const T &value) const
Atomic fetch-and-add operation on the referenced shared value.

◆ operator++() [2/2]

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::operator++ ( int  ) const
inline

postfix atomically increment value by one

Returns
The value of the referenced shared variable before the operation.

Definition at line 486 of file GlobAtomicRef.h.

487  {
488  return fetch_add(1);
489  }
T fetch_add(const T &value) const
Atomic fetch-and-add operation on the referenced shared value.

◆ operator+=()

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::operator+= ( const T &  value) const
inline

atomically increment value by ref

Returns
The value of the referenced shared variable after the operation.
Note
This operator does not return a reference but a copy of the value in order to ensure atomicity. This is consistent with the C++ std::atomic operator+=, see http://en.cppreference.com/w/cpp/atomic/atomic/operator_arith2.

Definition at line 529 of file GlobAtomicRef.h.

530  {
531  return fetch_add(value) + value;
532  }
T fetch_add(const T &value) const
Atomic fetch-and-add operation on the referenced shared value.

◆ operator--() [1/2]

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::operator-- ( ) const
inline

prefix atomically decrement value by one

Returns
The value of the referenced shared variable after the operation.
Note
This operator does not return a reference but a copy of the value in order to ensure atomicity. This is consistent with the C++ std::atomic operator--, see http://en.cppreference.com/w/cpp/atomic/atomic/operator_arith.

Definition at line 502 of file GlobAtomicRef.h.

503  {
504  return fetch_sub(1) - 1;
505  }
T fetch_sub(const T &value) const
Atomic fetch-and-sub operation on the referenced shared value.

◆ operator--() [2/2]

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::operator-- ( int  ) const
inline

postfix atomically decrement value by one

Returns
The value of the referenced shared variable before the operation.

Definition at line 513 of file GlobAtomicRef.h.

514  {
515  return fetch_sub(1);
516  }
T fetch_sub(const T &value) const
Atomic fetch-and-sub operation on the referenced shared value.

◆ operator-=()

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::operator-= ( const T &  value) const
inline

atomically decrement value by ref

Returns
The value of the referenced shared variable after the operation.

Note that this operator does not return a reference but a copy of the value in order to ensure atomicity. This is consistent with the C++ std::atomic operator-=, see http://en.cppreference.com/w/cpp/atomic/atomic/operator_arith2.

Definition at line 545 of file GlobAtomicRef.h.

546  {
547  return fetch_sub(value) - value;
548  }
T fetch_sub(const T &value) const
Atomic fetch-and-sub operation on the referenced shared value.

◆ operator=() [1/3]

template<typename T >
self_t& dash::GlobRef< dash::Atomic< T > >::operator= ( const self_t other) const
inline

Copy Assignment: Copies atomically the value from other.

Definition at line 160 of file GlobAtomicRef.h.

161  {
162  store(static_cast<atomic_t>(other));
163  return *this;
164  }
void store(const T &value) const
Set the value of the shared atomic variable.

◆ operator=() [2/3]

template<typename T >
self_t& dash::GlobRef< dash::Atomic< T > >::operator= ( self_t &&  other)
inline

Move Assignment: Redirects to Copy Assignment.

Definition at line 169 of file GlobAtomicRef.h.

References dash::GlobRef< T >::operator=().

169  {
170  operator=(other);
171  return *this;
172  }
self_t & operator=(const self_t &other) const
Copy Assignment: Copies atomically the value from other.

◆ operator=() [3/3]

template<typename T >
T dash::GlobRef< dash::Atomic< T > >::operator= ( const T &  value) const
inline

atomically assigns value

Returns
The assigned value.
Note
This operator does not return a reference but a copy of the value in order to ensure atomicity. This is consistent with the C++ std::atomic operator=, see http://en.cppreference.com/w/cpp/atomic/atomic/operator%3D.

Definition at line 203 of file GlobAtomicRef.h.

204  {
205  store(value);
206  return value;
207  }
void store(const T &value) const
Set the value of the shared atomic variable.

◆ set()

template<typename T >
void dash::GlobRef< dash::Atomic< T > >::set ( const T &  value) const
inline

Set the value of the shared atomic variable.

Definition at line 212 of file GlobAtomicRef.h.

213  {
214  static_assert(
215  dash::dart_punned_datatype<T>::value != DART_TYPE_UNDEFINED,
216  "Basic type or type smaller than 64bit required for "
217  "atomic set!");
218  static_assert(
219  std::is_same<value_type, nonconst_value_type>::value,
220  "Cannot modify value referenced by GlobRef<Atomic<const T>>!");
221  DASH_LOG_DEBUG_VAR("GlobRef<Atomic>.store()", value);
222  DASH_LOG_TRACE_VAR("GlobRef<Atomic>.store", _gptr);
224  _gptr,
225  &value,
226  1,
229  dart_flush(_gptr);
230  DASH_ASSERT_EQ(DART_OK, ret, "dart_accumulate failed");
231  DASH_LOG_DEBUG("GlobRef<Atomic>.store >");
232  }
Signals success.
Definition: dart_types.h:33
dart_ret_t dart_accumulate(dart_gptr_t gptr, const void *values, size_t nelem, dart_datatype_t dtype, dart_operation_t op)
Perform an element-wise atomic update on the values pointed to by gptr by applying the operation op w...
Type trait for mapping to punned DART data type for reduce operations.
Definition: Types.h:104
dart_ret_t
Return values of functions in the DART interface.
Definition: dart_types.h:30
Replace Value.
Definition: dart_types.h:95
dart_ret_t dart_flush(dart_gptr_t gptr)
Guarantee completion of all outstanding operations involving a segment on a certain unit...

◆ store()

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

Set the value of the shared atomic variable.

Definition at line 237 of file GlobAtomicRef.h.

238  {
239  set(value);
240  }

◆ sub()

template<typename T >
void dash::GlobRef< dash::Atomic< T > >::sub ( const T &  value) const
inline

DASH specific variant which is faster than fetch_sub but does not return value.

Definition at line 424 of file GlobAtomicRef.h.

425  {
426  op(dash::plus<T>(), -value);
427  }
Reduce operands to their sum.
Definition: Operation.h:163
void op(BinaryOp binary_op, const T &value) const
Atomically executes specified operation on the referenced shared value.

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