DASH  0.3.0
dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType > Class Template Reference

Classes

struct  local_index
 

Public Types

typedef map_t::value_type value_type
 
typedef dash::default_index_t index_type
 
typedef dash::default_size_t size_type
 
typedef map_t::pointer pointer
 
typedef map_t::const_pointer const_pointer
 
typedef map_t::reference reference
 
typedef map_t::const_reference const_reference
 
typedef value_type * raw_pointer
 
typedef const value_type * const_raw_pointer
 
typedef std::conditional< std::is_const< value_type >::value, typename map_t::const_local_iterator, typename map_t::local_iterator >::type local_pointer
 

Public Member Functions

 UnorderedMapGlobIter ()
 Default constructor. More...
 
 UnorderedMapGlobIter (map_t *map, index_type position)
 Constructor, creates iterator at specified global position. More...
 
 UnorderedMapGlobIter (map_t *map, team_unit_t unit, index_type local_index)
 Constructor, creates iterator at local position relative to the specified unit's local iteration space. More...
 
 UnorderedMapGlobIter (const self_t &other)=default
 Copy constructor. More...
 
self_toperator= (const self_t &other)=default
 Assignment operator. More...
 
 UnorderedMapGlobIter (std::nullptr_t)
 Null-pointer constructor. More...
 
self_toperator= (std::nullptr_t) noexcept
 Null-pointer assignment operator. More...
 
constexpr bool operator== (std::nullptr_t) const noexcept
 
constexpr bool operator!= (std::nullptr_t) const noexcept
 
reference operator[] (index_type offset)
 Random access operator. More...
 
constexpr operator pointer () const
 Type conversion operator to global pointer. More...
 
constexpr dart_gptr_t dart_gptr () const
 Explicit conversion to dart_gptr_t. More...
 
reference operator* ()
 Dereference operator. More...
 
const_reference operator* () const
 Dereference operator. More...
 
constexpr bool is_local () const noexcept
 Checks whether the element referenced by this global iterator is in the calling unit's local memory. More...
 
local_iterator local ()
 Conversion to local bucket iterator. More...
 
const_local_iterator local () const
 Conversion to local bucket iterator. More...
 
local_index lpos () const noexcept
 Unit and local offset at the iterator's position. More...
 
constexpr self_t global () const noexcept
 Map iterator to global index domain. More...
 
constexpr index_type pos () const noexcept
 Position of the iterator in global index space. More...
 
constexpr index_type gpos () const noexcept
 Position of the iterator in global index range. More...
 
self_toperator++ ()
 Prefix increment operator. More...
 
self_toperator-- ()
 Prefix decrement operator. More...
 
self_t operator++ (int)
 Postfix increment operator. More...
 
self_t operator-- (int)
 Postfix decrement operator. More...
 
template<typename K_ , typename M_ , typename H_ , typename P_ , typename A_ >
constexpr bool operator== (const UnorderedMapGlobIter< K_, M_, H_, P_, A_ > &other) const noexcept
 
template<typename K_ , typename M_ , typename H_ , typename P_ , typename A_ >
constexpr bool operator!= (const UnorderedMapGlobIter< K_, M_, H_, P_, A_ > &other) const noexcept
 
self_toperator+= (index_type offset)
 
self_toperator-= (index_type offset)
 
self_t operator+ (index_type offset) const
 
self_t operator- (index_type offset) const
 
constexpr index_type operator+ (const self_t &other) const noexcept
 
constexpr index_type operator- (const self_t &other) const noexcept
 
template<typename K_ , typename M_ , typename H_ , typename P_ , typename A_ >
constexpr bool operator< (const UnorderedMapGlobIter< K_, M_, H_, P_, A_ > &other) const noexcept
 
template<typename K_ , typename M_ , typename H_ , typename P_ , typename A_ >
constexpr bool operator<= (const UnorderedMapGlobIter< K_, M_, H_, P_, A_ > &other) const noexcept
 
template<typename K_ , typename M_ , typename H_ , typename P_ , typename A_ >
constexpr bool operator> (const UnorderedMapGlobIter< K_, M_, H_, P_, A_ > &other) const noexcept
 
template<typename K_ , typename M_ , typename H_ , typename P_ , typename A_ >
constexpr bool operator>= (const UnorderedMapGlobIter< K_, M_, H_, P_, A_ > &other) const noexcept
 

Friends

template<typename K_ , typename M_ , typename H_ , typename P_ , typename G_ >
std::ostream & dash::operator<< (std::ostream &os, const dash::UnorderedMapGlobIter< K_, M_, H_, P_, G_ > &it)
 

Detailed Description

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
class dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >

Definition at line 41 of file UnorderedMapGlobIter.h.

Constructor & Destructor Documentation

◆ UnorderedMapGlobIter() [1/5]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::UnorderedMapGlobIter ( )
inline

Default constructor.

Definition at line 99 of file UnorderedMapGlobIter.h.

100  : UnorderedMapGlobIter(nullptr)
101  { }
UnorderedMapGlobIter()
Default constructor.

◆ UnorderedMapGlobIter() [2/5]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::UnorderedMapGlobIter ( map_t map,
index_type  position 
)
inline

Constructor, creates iterator at specified global position.

Definition at line 106 of file UnorderedMapGlobIter.h.

109  : _map(map),
110  _idx(0),
111  _myid(map->team().myid()),
112  _idx_unit_id(0),
113  _idx_local_idx(0)
114  {
115  DASH_LOG_TRACE_VAR("UnorderedMapGlobIter(map,pos)", _idx);
116  increment(position);
117  DASH_LOG_TRACE("UnorderedMapGlobIter(map,pos) >");
118  }
constexpr Team & team() const noexcept
The team containing all units accessing this map.

◆ UnorderedMapGlobIter() [3/5]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::UnorderedMapGlobIter ( map_t map,
team_unit_t  unit,
index_type  local_index 
)
inline

Constructor, creates iterator at local position relative to the specified unit's local iteration space.

Definition at line 124 of file UnorderedMapGlobIter.h.

128  : _map(map),
129  _idx(0),
130  _myid(map->team().myid()),
131  _idx_unit_id(unit),
132  _idx_local_idx(local_index)
133  {
134  DASH_LOG_TRACE("UnorderedMapGlobIter(map,unit,lidx)()");
135  DASH_LOG_TRACE_VAR("UnorderedMapGlobIter(map,unit,lidx)", unit);
136  DASH_LOG_TRACE_VAR("UnorderedMapGlobIter(map,unit,lidx)", local_index);
137  // Unit and local offset to global position:
138  size_type unit_l_cumul_size_prev = 0;
139  if (unit > 0) {
140  unit_l_cumul_size_prev = _map->_local_cumul_sizes[unit-1];
141  }
142  _idx = unit_l_cumul_size_prev + _idx_local_idx;
143  DASH_LOG_TRACE_VAR("UnorderedMapGlobIter(map,unit,lidx)", _idx);
144  DASH_LOG_TRACE("UnorderedMapGlobIter(map,unit,lidx) >");
145  }
constexpr Team & team() const noexcept
The team containing all units accessing this map.

◆ UnorderedMapGlobIter() [4/5]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::UnorderedMapGlobIter ( const self_t other)
default

Copy constructor.

◆ UnorderedMapGlobIter() [5/5]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::UnorderedMapGlobIter ( std::nullptr_t  )
inline

Null-pointer constructor.

Definition at line 162 of file UnorderedMapGlobIter.h.

163  : _map(nullptr)
164  , _myid(DART_UNDEFINED_UNIT_ID)
165  , _idx_unit_id(DART_UNDEFINED_UNIT_ID)
166  , _is_nullptr(true)
167  {
168  DASH_LOG_TRACE("UnorderedMapGlobIter(nullptr)");
169  }
#define DART_UNDEFINED_UNIT_ID
Undefined unit ID.
Definition: dart_types.h:160

Member Function Documentation

◆ dart_gptr()

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
constexpr dart_gptr_t dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::dart_gptr ( ) const
inline

Explicit conversion to dart_gptr_t.

Returns
A DART global pointer to the element at the iterator's position

Definition at line 216 of file UnorderedMapGlobIter.h.

Referenced by dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator pointer(), and dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator*().

217  {
218  return _map->globmem().at(
219  _idx_unit_id,
220  _idx_local_idx
221  ).dart_gptr();
222  }
const glob_mem_type & globmem() const
Reference to instance of DashGlobalMemoryConcept used for underlying memory management of this contai...
dart_gptr_t dart_gptr() const
Explicit conversion to dart_gptr_t.
Definition: GlobHeapPtr.h:236
pointer at(team_unit_t unit, IndexT local_index)
Resolve the global iterator referencing an element position in a unit&#39;s local memory.
Definition: GlobHeapMem.h:913

◆ global()

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
constexpr self_t dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::global ( ) const
inlinenoexcept

Map iterator to global index domain.

Definition at line 321 of file UnorderedMapGlobIter.h.

322  {
323  return *this;
324  }

◆ gpos()

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
constexpr index_type dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::gpos ( ) const
inlinenoexcept

Position of the iterator in global index range.

Definition at line 337 of file UnorderedMapGlobIter.h.

338  {
339  return _idx;
340  }

◆ is_local()

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
constexpr bool dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::is_local ( ) const
inlinenoexcept

Checks whether the element referenced by this global iterator is in the calling unit's local memory.

Definition at line 278 of file UnorderedMapGlobIter.h.

Referenced by dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator*().

279  {
280  return (_myid == _idx_unit_id);
281  }

◆ local() [1/2]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
local_iterator dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::local ( )
inline

Conversion to local bucket iterator.

Definition at line 286 of file UnorderedMapGlobIter.h.

Referenced by dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator*().

287  {
288  if (_myid != _idx_unit_id) {
289  // Iterator position does not point to local element
290  return local_iterator(nullptr);
291  }
292  return (_map->lbegin() + _idx_local_idx);
293  }
local_iterator & lbegin() noexcept
Local iterator to the local beginning of the map.

◆ local() [2/2]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
const_local_iterator dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::local ( ) const
inline

Conversion to local bucket iterator.

Definition at line 298 of file UnorderedMapGlobIter.h.

299  {
300  if (_myid != _idx_unit_id) {
301  // Iterator position does not point to local element
302  return local_iterator(nullptr);
303  }
304  return (_map->lbegin() + _idx_local_idx);
305  }
local_iterator & lbegin() noexcept
Local iterator to the local beginning of the map.

◆ lpos()

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
local_index dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::lpos ( ) const
inlinenoexcept

Unit and local offset at the iterator's position.

Definition at line 310 of file UnorderedMapGlobIter.h.

311  {
312  local_index local_pos;
313  local_pos.unit = _idx_unit_id;
314  local_pos.index = _idx_local_idx;
315  return local_pos;
316  }

◆ operator pointer()

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
constexpr dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator pointer ( ) const
inline

Type conversion operator to global pointer.

Returns
A global reference to the element at the iterator's position

Definition at line 205 of file UnorderedMapGlobIter.h.

References dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::dart_gptr().

206  {
207  return pointer(dart_gptr());
208  }
constexpr dart_gptr_t dart_gptr() const
Explicit conversion to dart_gptr_t.

◆ operator*() [1/2]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
reference dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator* ( )
inline

Dereference operator.

Returns
A global reference to the element at the iterator's position.

Definition at line 229 of file UnorderedMapGlobIter.h.

References dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::dart_gptr(), dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::is_local(), and dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::local().

230  {
231  if (is_local()) {
232  // To local map iterator:
233  auto l_map_it = local();
234  DASH_ASSERT_MSG(l_map_it != nullptr,
235  "Converting global iterator at local position to "
236  "local iterator failed");
237  // To native pointer via conversion:
238  return reference(static_cast<raw_pointer>(l_map_it));
239  } else {
240  return reference(dart_gptr());
241  }
242  }
constexpr dart_gptr_t dart_gptr() const
Explicit conversion to dart_gptr_t.
constexpr bool is_local() const noexcept
Checks whether the element referenced by this global iterator is in the calling unit&#39;s local memory...
local_iterator local()
Conversion to local bucket iterator.

◆ operator*() [2/2]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
const_reference dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator* ( ) const
inline

Dereference operator.

Returns
A global reference to the element at the iterator's position.

Definition at line 249 of file UnorderedMapGlobIter.h.

References dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::dart_gptr(), dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::is_local(), and dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::local().

250  {
251  if (is_local()) {
252  // To local map iterator:
253  auto l_map_it = local();
254  DASH_ASSERT_MSG(l_map_it != nullptr,
255  "Converting global iterator at local position to "
256  "local iterator failed");
257  // To native pointer via conversion:
258  return reference(static_cast<raw_pointer>(l_map_it));
259  } else {
260  return reference(dart_gptr());
261  }
262  }
constexpr dart_gptr_t dart_gptr() const
Explicit conversion to dart_gptr_t.
constexpr bool is_local() const noexcept
Checks whether the element referenced by this global iterator is in the calling unit&#39;s local memory...
local_iterator local()
Conversion to local bucket iterator.

◆ operator++() [1/2]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
self_t& dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator++ ( )
inline

Prefix increment operator.

Definition at line 345 of file UnorderedMapGlobIter.h.

346  {
347  increment(1);
348  return *this;
349  }

◆ operator++() [2/2]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
self_t dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator++ ( int  )
inline

Postfix increment operator.

Definition at line 363 of file UnorderedMapGlobIter.h.

364  {
365  auto result = *this;
366  increment(1);
367  return result;
368  }

◆ operator--() [1/2]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
self_t& dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator-- ( )
inline

Prefix decrement operator.

Definition at line 354 of file UnorderedMapGlobIter.h.

355  {
356  decrement(1);
357  return *this;
358  }

◆ operator--() [2/2]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
self_t dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator-- ( int  )
inline

Postfix decrement operator.

Definition at line 373 of file UnorderedMapGlobIter.h.

References dash::operator<(), dash::operator<=(), dash::operator>(), and dash::operator>=().

374  {
375  auto result = *this;
376  decrement(1);
377  return result;
378  }

◆ operator=() [1/2]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
self_t& dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator= ( const self_t other)
default

Assignment operator.

◆ operator=() [2/2]

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
self_t& dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator= ( std::nullptr_t  )
inlinenoexcept

Null-pointer assignment operator.

Definition at line 174 of file UnorderedMapGlobIter.h.

175  {
176  _is_nullptr = true;
177  return *this;
178  }

◆ operator[]()

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
reference dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::operator[] ( index_type  offset)
inline

Random access operator.

Definition at line 193 of file UnorderedMapGlobIter.h.

194  {
195  auto res = *this;
196  res += offset;
197  return *this;
198  }

◆ pos()

template<typename Key, typename Mapped, typename Hash, typename Pred, typename GlobMemType>
constexpr index_type dash::UnorderedMapGlobIter< Key, Mapped, Hash, Pred, GlobMemType >::pos ( ) const
inlinenoexcept

Position of the iterator in global index space.

Definition at line 329 of file UnorderedMapGlobIter.h.

330  {
331  return _idx;
332  }

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