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

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 self_t = GlobRef< T >
 
using const_type = GlobRef< const_value_type >
 

Public Member Functions

 GlobRef ()=delete
 Reference semantics forbid declaration without definition. More...
 
 GlobRef (const GlobRef &other)=delete
 
constexpr GlobRef (dart_gptr_t dart_gptr) noexcept
 Constructor, creates an GlobRef object referencing an element in global memory. More...
 
template<typename _T , long = internal::enable_implicit_copy_ctor<value_type, _T>::value>
constexpr GlobRef (const GlobRef< _T > &gref) noexcept
 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 , int = internal::enable_explicit_copy_ctor<value_type, _T>::value>
constexpr GlobRef (const GlobRef< _T > &gref) noexcept
 Copy constructor, explicit if the following conditions are satisfied. More...
 
template<typename _T , long = internal::enable_implicit_copy_ctor<value_type, _T>::value>
constexpr GlobRef (const GlobAsyncRef< _T > &gref) noexcept
 Constructor to convert GlobAsyncRef to GlobRef. More...
 
template<typename _T , int = internal::enable_explicit_copy_ctor<value_type, _T>::value>
constexpr GlobRef (const GlobAsyncRef< _T > &gref) noexcept
 
 GlobRef (self_t &&other) noexcept
 Move Constructor. More...
 
const self_toperator= (const self_t &other) const
 Copy Assignment. More...
 
self_toperator= (self_t &&other) noexcept
 Move Assignment: Redirects to Copy Assignment. More...
 
const self_toperator= (const value_type &val) const
 Value-assignment operator. More...
 
 operator nonconst_value_type () const
 
template<typename ValueT >
bool operator== (const GlobRef< ValueT > &other) const
 
template<typename ValueT >
bool operator!= (const GlobRef< ValueT > &other) const
 
template<typename ValueT >
constexpr bool operator== (const ValueT &value) const
 
template<typename ValueT >
constexpr bool operator!= (const ValueT &value) const
 
void set (const value_type &val) const
 
nonconst_value_type get () const
 
void get (nonconst_value_type *tptr) const
 
void get (nonconst_value_type &tref) const
 
void put (const_value_type &tref) const
 
void put (const_value_type *tptr) const
 
const self_toperator+= (const nonconst_value_type &ref) const
 
const self_toperator-= (const nonconst_value_type &ref) const
 
const self_toperator++ () const
 
nonconst_value_type operator++ (int) const
 
const self_toperator-- () const
 
nonconst_value_type operator-- (int) const
 
const self_toperator*= (const_value_type &ref) const
 
const self_toperator/= (const_value_type &ref) const
 
const self_toperator^= (const_value_type &ref) const
 
constexpr dart_gptr_t dart_gptr () const noexcept
 
bool is_local () const
 Checks whether the globally referenced element is in the calling unit's local memory. More...
 
template<typename MEMTYPE >
GlobRef< typename internal::add_const_from_type< T, MEMTYPE >::type > member (size_t offs) const
 Get a global ref to a member of a certain type at the specified offset. More...
 
template<class MEMTYPE , class P = T>
GlobRef< typename internal::add_const_from_type< T, MEMTYPE >::type > member (const MEMTYPE P::*mem) const
 Get the member via pointer to member. More...
 
void swap (dash::GlobRef< T > &b) const
 specialization which swappes the values of two global references More...
 

Friends

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

Detailed Description

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

Examples:
ex.03.globref/main.cpp, and ex.06.std-algo/main.cpp.

Definition at line 18 of file GlobAtomicAsyncRef.h.

Constructor & Destructor Documentation

◆ GlobRef() [1/6]

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

Reference semantics forbid declaration without definition.

Referenced by dash::GlobRef< T >::GlobRef(), and dash::GlobRef< dash::Atomic< T > >::GlobRef().

◆ GlobRef() [2/6]

template<typename T>
constexpr dash::GlobRef< T >::GlobRef ( dart_gptr_t  dart_gptr)
inlineexplicitnoexcept

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

Definition at line 69 of file GlobRef.h.

70  : _gptr(dart_gptr)
71  {
72  }

◆ GlobRef() [3/6]

template<typename T>
template<typename _T , long = internal::enable_implicit_copy_ctor<value_type, _T>::value>
constexpr dash::GlobRef< T >::GlobRef ( const GlobRef< _T > &  gref)
inlinenoexcept

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 85 of file GlobRef.h.

86  : GlobRef(gref.dart_gptr())
87  {
88  }
GlobRef()=delete
Reference semantics forbid declaration without definition.

◆ GlobRef() [4/6]

template<typename T>
template<typename _T , int = internal::enable_explicit_copy_ctor<value_type, _T>::value>
constexpr dash::GlobRef< T >::GlobRef ( const GlobRef< _T > &  gref)
inlineexplicitnoexcept

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 99 of file GlobRef.h.

100  : GlobRef(gref.dart_gptr())
101  {
102  }
GlobRef()=delete
Reference semantics forbid declaration without definition.

◆ GlobRef() [5/6]

template<typename T>
template<typename _T , long = internal::enable_implicit_copy_ctor<value_type, _T>::value>
constexpr dash::GlobRef< T >::GlobRef ( const GlobAsyncRef< _T > &  gref)
inlinenoexcept

Constructor to convert GlobAsyncRef to GlobRef.

Set to explicit to avoid unintendet conversion

Definition at line 111 of file GlobRef.h.

References dash::GlobAsyncRef< T >::dart_gptr(), and dash::GlobRef< T >::GlobRef().

112  : _gptr(gref.dart_gptr())
113  {
114  }

◆ GlobRef() [6/6]

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

Move Constructor.

Definition at line 127 of file GlobRef.h.

128  :_gptr(std::move(other._gptr))
129  {
130  DASH_LOG_TRACE("GlobRef.GlobRef(GlobRef &&)", _gptr);
131  }

Member Function Documentation

◆ is_local()

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

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

Examples:
ex.11.halo-stencil/main.cpp, and ex.11.simple-stencil/main.cpp.

Definition at line 356 of file GlobRef.h.

References dart_team_myid(), dart_gptr_t::teamid, and dart_gptr_t::unitid.

356  {
357  dart_team_unit_t luid;
358  dart_team_myid(_gptr.teamid, &luid);
359  return _gptr.unitid == luid.id;
360  }
int16_t teamid
The team associated with the allocation.
Definition: dart_globmem.h:89
dart_ret_t dart_team_myid(dart_team_t teamid, dart_team_unit_t *myid)
Return the unit id of the caller in the specified team.
dart_unit_t unitid
The unit holding the memory element.
Definition: dart_globmem.h:83
Data type for storing a unit ID relative to a team.
Definition: dart_types.h:180

◆ member() [1/2]

template<typename T>
template<typename MEMTYPE >
GlobRef<typename internal::add_const_from_type<T, MEMTYPE>::type> dash::GlobRef< T >::member ( size_t  offs) const
inline

Get a global ref to a member of a certain type at the specified offset.

Definition at line 368 of file GlobRef.h.

368  {
369  dart_gptr_t dartptr = _gptr;
370  DASH_ASSERT_RETURNS(
371  dart_gptr_incaddr(&dartptr, offs),
372  DART_OK);
373  return GlobRef<typename internal::add_const_from_type<T, MEMTYPE>::type>(dartptr);
374  }
Signals success.
Definition: dart_types.h:33
DART Global pointer type.
Definition: dart_globmem.h:77

◆ member() [2/2]

template<typename T>
template<class MEMTYPE , class P = T>
GlobRef<typename internal::add_const_from_type<T, MEMTYPE>::type> dash::GlobRef< T >::member ( const MEMTYPE P::*  mem) const
inline

Get the member via pointer to member.

Definition at line 381 of file GlobRef.h.

382  {
383  // TODO: Thaaaat ... looks hacky.
384  auto offs = (size_t) & (reinterpret_cast<P*>(0)->*mem);
385  return member<typename internal::add_const_from_type<T, MEMTYPE>::type>(offs);
386  }

◆ operator=() [1/3]

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

Copy Assignment.

Definition at line 136 of file GlobRef.h.

References DART_GPTR_EQUAL.

Referenced by dash::GlobRef< T >::operator=(), and dash::GlobRef< dash::Atomic< T > >::operator=().

137  {
138  if (DART_GPTR_EQUAL(_gptr, other._gptr)) {
139  return *this;
140  }
141  set(static_cast<T>(other));
142  return *this;
143  }
#define DART_GPTR_EQUAL(gptr1_, gptr2_)
Compare two global pointers.
Definition: dart_globmem.h:128

◆ operator=() [2/3]

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

Move Assignment: Redirects to Copy Assignment.

Definition at line 148 of file GlobRef.h.

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

148  {
149  DASH_LOG_TRACE("GlobRef.operator=(GlobRef &&)", _gptr);
150  operator=(other);
151  return *this;
152  }
const self_t & operator=(const self_t &other) const
Copy Assignment.
Definition: GlobRef.h:136

◆ operator=() [3/3]

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

Value-assignment operator.

Definition at line 157 of file GlobRef.h.

References dash::Team::All(), dart_fetch_and_op(), dart_flush(), and dash::GlobRef< T >::operator=().

157  {
158  set(val);
159  return *this;
160  }

◆ swap()

template<typename T>
void dash::GlobRef< T >::swap ( dash::GlobRef< T > &  b) const
inline

specialization which swappes the values of two global references

Definition at line 391 of file GlobRef.h.

References dash::typestr().

391  {
392  static_assert(std::is_same<value_type, nonconst_value_type>::value,
393  "Cannot modify value referenced by GlobRef<const T>!");
394  auto tmp = static_cast<T>(*this);
395  *this = b;
396  b = tmp;
397  }

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