DASH  0.3.0
dash::GlobSharedRef< T, GlobalPointerType > Class Template Reference

Classes

struct  rebind
 Convert GlobSharedRef<T, GlobalPointer<T>> to GlobSharedRef<U, GlobalPointer<U>>. More...
 

Public Types

typedef GlobalPointerType global_pointer
 
typedef GlobalPointerType const_global_pointer
 
typedef T * local_pointer
 
typedef const T * const_local_pointer
 

Public Member Functions

 GlobSharedRef ()
 Default constructor, creates an GlobSharedRef object referencing an element in global memory. More...
 
 GlobSharedRef (dart_gptr_t gptr, local_pointer lptr)
 Constructor, creates an GlobSharedRef object referencing an element in global memory. More...
 
template<class GlobalType >
 GlobSharedRef (GlobalType &gptr, local_pointer lptr=nullptr)
 Constructor, creates an GlobSharedRef object referencing an element in global memory. More...
 
 GlobSharedRef (local_pointer lptr)
 Constructor, creates an GlobSharedRef object referencing an element in global memory. More...
 
 GlobSharedRef (dart_gptr_t dart_gptr)
 Constructor, creates an GlobSharedRef object referencing an element in global memory. More...
 
 GlobSharedRef (const self_t &other)
 Copy constructor. More...
 
self_toperator= (const self_t &other)
 Assignment operator. More...
 
bool operator== (const self_t &other) const noexcept
 
bool operator!= (const self_t &other) const noexcept
 
 operator T () const
 
get () const
 
void put (T &val) const
 
self_toperator= (const T val)
 
GlobSharedRef< T, GlobalPointerType > & operator+= (const T &ref)
 
self_toperator-= (const T &ref)
 
self_toperator++ ()
 
self_t operator++ (int)
 
self_toperator-- ()
 
self_t operator-- (int)
 
self_toperator*= (const T &ref)
 
self_toperator/= (const T &ref)
 
self_toperator^= (const T &ref)
 
dart_gptr_t dart_gptr () const
 
local_pointer local () const
 
bool is_local () const
 Checks whether the globally referenced element is in the calling unit's local memory. More...
 

Friends

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

Detailed Description

template<typename T, typename GlobalPointerType>
class dash::GlobSharedRef< T, GlobalPointerType >

Definition at line 18 of file GlobSharedRef.h.

Constructor & Destructor Documentation

◆ GlobSharedRef() [1/6]

template<typename T, typename GlobalPointerType>
dash::GlobSharedRef< T, GlobalPointerType >::GlobSharedRef ( )
inline

Default constructor, creates an GlobSharedRef object referencing an element in global memory.

Definition at line 58 of file GlobSharedRef.h.

Referenced by dash::GlobSharedRef< T, GlobalPointerType >::GlobSharedRef().

59  : _gptr(DART_GPTR_NULL),
60  _lptr(nullptr)
61  { }
#define DART_GPTR_NULL
A NULL global pointer.
Definition: dart_globmem.h:105

◆ GlobSharedRef() [2/6]

template<typename T, typename GlobalPointerType>
dash::GlobSharedRef< T, GlobalPointerType >::GlobSharedRef ( dart_gptr_t  gptr,
local_pointer  lptr 
)
inlineexplicit

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

Parameters
gptrPointer to referenced object in global memory

Definition at line 67 of file GlobSharedRef.h.

71  : _gptr(gptr),
72  _lptr(lptr)
73  {
74  DASH_LOG_TRACE_VAR("GlobSharedRef(gptr,lptr)", gptr);
75  DASH_LOG_TRACE_VAR("GlobSharedRef(gptr,lptr)", lptr);
76  }

◆ GlobSharedRef() [3/6]

template<typename T, typename GlobalPointerType>
template<class GlobalType >
dash::GlobSharedRef< T, GlobalPointerType >::GlobSharedRef ( GlobalType &  gptr,
local_pointer  lptr = nullptr 
)
inline

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

Parameters
gptrPointer to referenced object in global memory

Definition at line 83 of file GlobSharedRef.h.

87  : _gptr(gptr.dart_gptr()),
88  _lptr(lptr)
89  {
90  DASH_LOG_TRACE_VAR("GlobSharedRef(gptr,lptr)", gptr);
91  DASH_LOG_TRACE_VAR("GlobSharedRef(gptr,lptr)", lptr);
92  }

◆ GlobSharedRef() [4/6]

template<typename T, typename GlobalPointerType>
dash::GlobSharedRef< T, GlobalPointerType >::GlobSharedRef ( local_pointer  lptr)
inline

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

Parameters
lptrPointer to referenced object in global memory

Definition at line 98 of file GlobSharedRef.h.

101  : _gptr(DART_GPTR_NULL),
102  _lptr(lptr)
103  {
104  DASH_LOG_TRACE_VAR("GlobSharedRef(lptr)", lptr);
105  }
#define DART_GPTR_NULL
A NULL global pointer.
Definition: dart_globmem.h:105

◆ GlobSharedRef() [5/6]

template<typename T, typename GlobalPointerType>
dash::GlobSharedRef< T, GlobalPointerType >::GlobSharedRef ( dart_gptr_t  dart_gptr)
inlineexplicit

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

Definition at line 111 of file GlobSharedRef.h.

112  : _gptr(dart_gptr),
113  _lptr(nullptr)
114  {
115  DASH_LOG_TRACE_VAR("GlobSharedRef(dart_gptr_t)", dart_gptr);
116  }

◆ GlobSharedRef() [6/6]

template<typename T, typename GlobalPointerType>
dash::GlobSharedRef< T, GlobalPointerType >::GlobSharedRef ( const self_t other)
inline

Copy constructor.

Parameters
otherGlobSharedRef instance to copy.

Definition at line 121 of file GlobSharedRef.h.

References dash::GlobSharedRef< T, GlobalPointerType >::GlobSharedRef().

124  : _gptr(other._gptr),
125  _lptr(other._lptr)
126  { }

Member Function Documentation

◆ is_local()

template<typename T, typename GlobalPointerType>
bool dash::GlobSharedRef< T, GlobalPointerType >::is_local ( ) const
inline

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

Definition at line 327 of file GlobSharedRef.h.

References dart_gptr_t::addr_or_offs, dart_team_myid(), dart_gptr_t::flags, dart_gptr_t::segid, dart_gptr_t::teamid, and dart_gptr_t::unitid.

328  {
329  if (_lptr == nullptr) {
330  return false;
331  }
332  dart_team_unit_t luid;
333  dart_team_myid(_gptr.teamid, &luid);
334  return _gptr.unitid == luid.id;
335  }
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

◆ operator=()

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

Assignment operator.

Definition at line 141 of file GlobSharedRef.h.

References dash::Team::All(), dart_fetch_and_op(), dart_flush(), DART_GPTR_ISNULL, dash::local(), and dash::swap().

142  {
143  DASH_LOG_TRACE_VAR("GlobSharedRef.=()", other);
144  // This results in a dart_put, required for STL algorithms like
145  // std::copy to work on global ranges.
146  // TODO: Not well-defined:
147  // This violates copy semantics:
148  // GlobSharedRef(const GlobSharedRef & other)
149  // copies the GlobSharedRef instance while
150  // GlobSharedRef=(const GlobSharedRef & other)
151  // puts the value.
152  return *this = static_cast<T>(other);
153 // _gptr = other._gptr;
154 // return *this;
155  }

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