DASH  0.3.0
dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType > Class Template Reference

Global iterator on an index set specified by a view modifier. More...

#include <GlobViewIter.h>

Public Types

typedef ElementType value_type
 
typedef ReferenceType reference
 
typedef ReferenceType::const_type const_reference
 
typedef PointerType pointer
 
typedef PointerType::const_type const_pointer
 
typedef pointer::local_type local_type
 
typedef pointer::const_local_type const_local_type
 
typedef PatternType pattern_type
 
typedef PatternType::index_type index_type
 
typedef PatternType::size_type size_type
 
typedef std::integral_constant< bool, true > has_view
 

Public Member Functions

constexpr GlobViewIter ()
 Default constructor. More...
 
template<class GlobStaticMemT_ >
constexpr GlobViewIter (GlobStaticMemT_ *gmem, const PatternType &pat, const ViewSpecType &viewspec, IndexType position=0, IndexType view_index_offset=0)
 Constructor, creates a global iterator on global memory following the element order specified by the given pattern and view spec. More...
 
template<class GlobStaticMemT_ >
constexpr GlobViewIter (GlobStaticMemT_ *gmem, const PatternType &pat, IndexType position=0, IndexType view_index_offset=0)
 Constructor, creates a global iterator on global memory following the element order specified by the given pattern and view spec. More...
 
template<class P_ , class GM_ , class Ptr_ , class Ref_ >
constexpr GlobViewIter (const GlobIter< nonconst_value_type, P_, GM_, Ptr_, Ref_ > &other, const ViewSpecType &viewspec, IndexType view_offs=0)
 Constructor, creates a global view iterator from a global iterator. More...
 
template<typename T_ , class P_ , class GM_ , class Ptr_ , class Ref_ >
constexpr GlobViewIter (const GlobViewIter< T_, P_, GM_, Ptr_, Ref_ > &other)
 Copy constructor. More...
 
template<typename T_ , class P_ , class GM_ , class Ptr_ , class Ref_ >
constexpr GlobViewIter (GlobViewIter< T_, P_, GM_, Ptr_, Ref_ > &&other)
 Move constructor. More...
 
template<typename T_ , class P_ , class GM_ , class Ptr_ , class Ref_ >
self_toperator= (const GlobViewIter< T_, P_, GM_, Ptr_, Ref_ > &other)
 Assignment operator. More...
 
template<typename T_ , class P_ , class GM_ , class Ptr_ , class Ref_ >
self_toperator= (GlobViewIter< T_, P_, GM_, Ptr_, Ref_ > &&other)
 Move-assignment operator. More...
 
 operator const_pointer () const
 Type conversion operator to GlobPtr. More...
 
 operator pointer ()
 Type conversion operator to GlobPtr. More...
 
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...
 
reference operator[] (index_type g_index)
 Subscript operator, returns global reference to element at given global index. More...
 
const_reference operator[] (index_type g_index) const
 Subscript operator, returns global reference to element at given global index. More...
 
constexpr bool is_local () const
 Checks whether the element referenced by this global iterator is in the calling unit's local memory. More...
 
local_type local () const
 Convert global iterator to native pointer. More...
 
const_global_type global () const
 Map iterator to global index domain by projecting the iterator's view. More...
 
global_type global ()
 Map iterator to global index domain by projecting the iterator's view. More...
 
constexpr index_type pos () const noexcept
 Position of the iterator in its view's iteration space and the view's offset in global index space. More...
 
index_type rpos () const noexcept
 Position of the iterator in its view's iteration space, disregarding the view's offset in global index space. More...
 
index_type gpos () const
 Position of the iterator in global index range. More...
 
pattern_type::local_index_t lpos () const
 Unit and local offset at the iterator's position. More...
 
bool is_relative () const noexcept
 Whether the iterator's position is relative to a view. More...
 
ViewSpecType viewspec () const
 The view that specifies this iterator's index range. More...
 
constexpr const GlobMemType & globmem () const noexcept
 The instance of GlobStaticMem used by this iterator to resolve addresses in global memory. More...
 
GlobMemType & globmem () noexcept
 The instance of GlobStaticMem used by this iterator to resolve addresses in global memory. More...
 
self_toperator++ () noexcept
 Prefix increment operator. More...
 
self_t operator++ (int) noexcept
 Postfix increment operator. More...
 
self_toperator-- () noexcept
 Prefix decrement operator. More...
 
self_t operator-- (int) noexcept
 Postfix decrement operator. More...
 
self_toperator+= (index_type n) noexcept
 
self_toperator-= (index_type n) noexcept
 
self_t operator+ (index_type n) const noexcept
 
self_t operator- (index_type n) const noexcept
 
index_type operator+ (const self_t &other) const noexcept
 
index_type operator- (const self_t &other) const
 
bool operator< (const self_t &other) const noexcept
 
bool operator<= (const self_t &other) const noexcept
 
bool operator> (const self_t &other) const noexcept
 
bool operator>= (const self_t &other) const noexcept
 
bool operator== (const self_t &other) const noexcept
 
bool operator!= (const self_t &other) const noexcept
 
constexpr const PatternType & pattern () const noexcept
 
constexpr dash::Teamteam () const noexcept
 

Static Public Member Functions

static dim_t ndim ()
 The number of dimensions of the iterator's underlying pattern. More...
 

Friends

template<typename T_ , class P_ , class GM_ , class Ptr_ , class Ref_ >
std::ostream & operator<< (std::ostream &os, const GlobViewIter< T_, P_, GM_, Ptr_, Ref_ > &it)
 

Detailed Description

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
class dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >

Global iterator on an index set specified by a view modifier.

Implemented concept:
Global Iterator Concept

Definition at line 40 of file GlobViewIter.h.

Constructor & Destructor Documentation

◆ GlobViewIter() [1/6]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
constexpr dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::GlobViewIter ( )
inline

Default constructor.

Definition at line 162 of file GlobViewIter.h.

163  : _globmem(nullptr)
164  , _pattern(nullptr)
165  , _viewspec(nullptr)
166  , _idx(0)
167  , _view_idx_offset(0)
168  , _max_idx(0)
169  , _myid(dash::Team::All().myid())
170  { }
global_unit_t myid()
Shortcut to query the global unit ID of the calling unit.
static Team & All()
The invariant Team instance containing all available units.
Definition: Team.h:213

◆ GlobViewIter() [2/6]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
template<class GlobStaticMemT_ >
constexpr dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::GlobViewIter ( GlobStaticMemT_ *  gmem,
const PatternType &  pat,
const ViewSpecType &  viewspec,
IndexType  position = 0,
IndexType  view_index_offset = 0 
)
inline

Constructor, creates a global iterator on global memory following the element order specified by the given pattern and view spec.

Definition at line 177 of file GlobViewIter.h.

183  : _globmem(reinterpret_cast<GlobMemType *>(gmem))
184  , _pattern(&pat)
185  , _viewspec(&viewspec)
186  , _idx(position)
187  , _view_idx_offset(view_index_offset)
188  , _max_idx(viewspec.size() - 1)
189  , _myid(pat.team().myid())
190  { }
ViewSpecType viewspec() const
The view that specifies this iterator&#39;s index range.
Definition: GlobViewIter.h:719

◆ GlobViewIter() [3/6]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
template<class GlobStaticMemT_ >
constexpr dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::GlobViewIter ( GlobStaticMemT_ *  gmem,
const PatternType &  pat,
IndexType  position = 0,
IndexType  view_index_offset = 0 
)
inline

Constructor, creates a global iterator on global memory following the element order specified by the given pattern and view spec.

Definition at line 197 of file GlobViewIter.h.

202  : _globmem(reinterpret_cast<GlobMemType *>(gmem))
203  , _pattern(&pat)
204  , _viewspec(nullptr)
205  , _idx(position)
206  , _view_idx_offset(view_index_offset)
207  , _max_idx(pat.size() - 1)
208  , _myid(dash::Team::GlobalUnitID())
209  { }
static global_unit_t GlobalUnitID()
The invariant unit ID in dash::Team::All().
Definition: Team.h:221

◆ GlobViewIter() [4/6]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
template<class P_ , class GM_ , class Ptr_ , class Ref_ >
constexpr dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::GlobViewIter ( const GlobIter< nonconst_value_type, P_, GM_, Ptr_, Ref_ > &  other,
const ViewSpecType &  viewspec,
IndexType  view_offs = 0 
)
inline

Constructor, creates a global view iterator from a global iterator.

Definition at line 219 of file GlobViewIter.h.

223  : _globmem(other._globmem)
224  , _pattern(other._pattern)
225  , _viewspec(&viewspec)
226  , _idx(other._idx)
227  , _view_idx_offset(view_offs)
228  , _max_idx(other._max_idx)
229  , _myid(other._myid)
230  { }
ViewSpecType viewspec() const
The view that specifies this iterator&#39;s index range.
Definition: GlobViewIter.h:719

◆ GlobViewIter() [5/6]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
template<typename T_ , class P_ , class GM_ , class Ptr_ , class Ref_ >
constexpr dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::GlobViewIter ( const GlobViewIter< T_, P_, GM_, Ptr_, Ref_ > &  other)
inline

Copy constructor.

Definition at line 241 of file GlobViewIter.h.

244  : _globmem (other._globmem)
245  , _pattern (other._pattern)
246  , _viewspec (other._viewspec)
247  , _idx (other._idx)
248  , _view_idx_offset(other._view_idx_offset)
249  , _max_idx (other._max_idx)
250  , _myid (other._myid)
251  { }

◆ GlobViewIter() [6/6]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
template<typename T_ , class P_ , class GM_ , class Ptr_ , class Ref_ >
constexpr dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::GlobViewIter ( GlobViewIter< T_, P_, GM_, Ptr_, Ref_ > &&  other)
inline

Move constructor.

Definition at line 262 of file GlobViewIter.h.

265  : _globmem (std::move(other._globmem))
266  , _pattern (std::move(other._pattern))
267  , _viewspec (std::move(other._viewspec))
268  , _idx (std::move(other._idx))
269  , _view_idx_offset(std::move(other._view_idx_offset))
270  , _max_idx (std::move(other._max_idx))
271  , _myid (std::move(other._myid))
272  { }

Member Function Documentation

◆ dart_gptr()

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
dart_gptr_t dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::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 419 of file GlobViewIter.h.

Referenced by dash::GlobViewIter< ElementT, PatternT, GlobMemT >::operator--().

420  {
421  DASH_LOG_TRACE_VAR("GlobViewIter.dart_gptr()", _idx);
422  typedef typename pattern_type::local_index_t
423  local_pos_t;
424  IndexType idx = _idx;
425  IndexType offset = 0;
426  // Convert iterator position (_idx) to local index and unit.
427  if (_idx > _max_idx) {
428  // Global iterator pointing past the range indexed by the pattern
429  // which is the case for .end() iterators.
430  idx = _max_idx;
431  offset += _idx - _max_idx;
432  DASH_LOG_TRACE_VAR("GlobViewIter.dart_gptr", _max_idx);
433  DASH_LOG_TRACE_VAR("GlobViewIter.dart_gptr", idx);
434  DASH_LOG_TRACE_VAR("GlobViewIter.dart_gptr", offset);
435  }
436  // Global index to local index and unit:
437  local_pos_t local_pos;
438  if (_viewspec == nullptr) {
439  // No viewspec mapping required:
440  local_pos = _pattern->local(idx);
441  } else {
442  // Viewspec projection required:
443  DASH_LOG_TRACE_VAR("GlobViewIter.dart_gptr", _viewspec);
444  auto glob_coords = coords(idx);
445  local_pos = _pattern->local_index(glob_coords);
446  }
447  DASH_LOG_TRACE("GlobViewIter.dart_gptr",
448  "unit:", local_pos.unit,
449  "local index:", local_pos.index);
450  // Global pointer to element at given position:
451  auto const dart_pointer = _get_pointer_at(local_pos);
452  const_pointer gptr(dart_pointer);
453  DASH_LOG_TRACE_VAR("GlobIter.dart_gptr >", gptr);
454  return (gptr + offset).dart_gptr();
455  }

◆ global() [1/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
const_global_type dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::global ( ) const
inline

Map iterator to global index domain by projecting the iterator's view.

Definition at line 594 of file GlobViewIter.h.

595  {
596  auto g_idx = gpos();
597  return const_global_type(
598  _globmem,
599  *_pattern,
600  g_idx
601  );
602  }
index_type gpos() const
Position of the iterator in global index range.
Definition: GlobViewIter.h:638

◆ global() [2/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
global_type dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::global ( )
inline

Map iterator to global index domain by projecting the iterator's view.

Definition at line 607 of file GlobViewIter.h.

608  {
609  return global_type(
610  _globmem,
611  *_pattern,
612  gpos()
613  );
614  }
index_type gpos() const
Position of the iterator in global index range.
Definition: GlobViewIter.h:638

◆ globmem() [1/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
constexpr const GlobMemType& dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::globmem ( ) const
inlinenoexcept

The instance of GlobStaticMem used by this iterator to resolve addresses in global memory.

Definition at line 731 of file GlobViewIter.h.

732  {
733  return *_globmem;
734  }

◆ globmem() [2/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
GlobMemType& dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::globmem ( )
inlinenoexcept

The instance of GlobStaticMem used by this iterator to resolve addresses in global memory.

Definition at line 740 of file GlobViewIter.h.

741  {
742  return *_globmem;
743  }

◆ gpos()

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
index_type dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::gpos ( ) const
inline

Position of the iterator in global index range.

Projects iterator position from its view spec to global index domain.

Definition at line 638 of file GlobViewIter.h.

Referenced by dash::GlobViewIter< ElementT, PatternT, GlobMemT >::global().

639  {
640  DASH_LOG_TRACE_VAR("GlobViewIter.gpos()", _idx);
641  if (_viewspec == nullptr) {
642  // No viewspec mapping required:
643  DASH_LOG_TRACE_VAR("GlobViewIter.gpos >", _idx);
644  return _idx;
645  } else {
646  IndexType idx = _idx;
647  IndexType offset = 0;
648  DASH_LOG_TRACE_VAR("GlobViewIter.gpos", *_viewspec);
649  DASH_LOG_TRACE_VAR("GlobViewIter.gpos", _max_idx);
650  // Convert iterator position (_idx) to local index and unit.
651  if (_idx > _max_idx) {
652  // Global iterator pointing past the range indexed by the pattern
653  // which is the case for .end() iterators.
654  idx = _max_idx;
655  offset = _idx - _max_idx;
656  }
657  // Viewspec projection required:
658  auto g_coords = coords(idx);
659  DASH_LOG_TRACE_VAR("GlobViewIter.gpos", _idx);
660  DASH_LOG_TRACE_VAR("GlobViewIter.gpos", g_coords);
661  auto g_idx = _pattern->global_at(g_coords);
662  DASH_LOG_TRACE_VAR("GlobViewIter.gpos", g_idx);
663  g_idx += offset;
664  DASH_LOG_TRACE_VAR("GlobViewIter.gpos >", g_idx);
665  return g_idx;
666  }
667  }

◆ is_local()

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
constexpr bool dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::is_local ( ) const
inline

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

Definition at line 539 of file GlobViewIter.h.

540  {
541  return (_myid == lpos().unit);
542  }
pattern_type::local_index_t lpos() const
Unit and local offset at the iterator&#39;s position.
Definition: GlobViewIter.h:673

◆ is_relative()

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
bool dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::is_relative ( ) const
inlinenoexcept

Whether the iterator's position is relative to a view.

Definition at line 711 of file GlobViewIter.h.

712  {
713  return _viewspec != nullptr;
714  }

◆ local()

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
local_type dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::local ( ) const
inline

Convert global iterator to native pointer.

Definition at line 547 of file GlobViewIter.h.

548  {
549  DASH_LOG_TRACE_VAR("GlobViewIter.local=()", _idx);
550  typedef typename pattern_type::local_index_t
551  local_pos_t;
552  IndexType idx = _idx;
553  IndexType offset = 0;
554  DASH_LOG_TRACE_VAR("GlobViewIter.local=", _max_idx);
555  // Convert iterator position (_idx) to local index and unit.
556  if (_idx > _max_idx) {
557  // Global iterator pointing past the range indexed by the pattern
558  // which is the case for .end() iterators.
559  idx = _max_idx;
560  offset += _idx - _max_idx;
561  }
562  DASH_LOG_TRACE_VAR("GlobViewIter.local=", idx);
563  DASH_LOG_TRACE_VAR("GlobViewIter.local=", offset);
564 
565  // Global index to local index and unit:
566  local_pos_t local_pos;
567  if (_viewspec == nullptr) {
568  // No viewspec mapping required:
569  local_pos = _pattern->local(idx);
570  } else {
571  DASH_LOG_TRACE_VAR("GlobViewIter.local=", *_viewspec);
572  // Viewspec projection required:
573  auto glob_coords = coords(idx);
574  local_pos = _pattern->local_index(glob_coords);
575  }
576  DASH_LOG_TRACE_VAR("GlobViewIter.local= >", local_pos.unit);
577  DASH_LOG_TRACE_VAR("GlobViewIter.local= >", local_pos.index);
578  if (_myid != local_pos.unit) {
579  // Iterator position does not point to local element
580  return nullptr;
581  }
582 
583  auto* lbegin = dash::local_begin(
584  static_cast<pointer>(_globmem->begin()), _pattern->team().myid());
585 
586  DASH_ASSERT(lbegin);
587 
588  return std::next(lbegin, local_pos.index + offset);
589  }
DASH_CONSTEXPR std::enable_if< std::is_same< typename dash::memory_space_traits< MemSpaceT >::memory_space_layout_tag, memory_space_contiguous >::value, T >::type * local_begin(GlobPtr< T, MemSpaceT > global_begin, dash::team_unit_t unit)
Returns the begin of the local memory portion within a global memory segment.
Definition: GlobPtr.h:593

◆ lpos()

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
pattern_type::local_index_t dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::lpos ( ) const
inline

Unit and local offset at the iterator's position.

Projects iterator position from its view spec to global index domain.

Definition at line 673 of file GlobViewIter.h.

Referenced by dash::GlobViewIter< ElementT, PatternT, GlobMemT >::is_local(), and dash::GlobViewIter< ElementT, PatternT, GlobMemT >::operator--().

674  {
675  DASH_LOG_TRACE_VAR("GlobViewIter.lpos()", _idx);
676  typedef typename pattern_type::local_index_t
677  local_pos_t;
678  IndexType idx = _idx;
679  IndexType offset = 0;
680  // Convert iterator position (_idx) to local index and unit.
681  if (_idx > _max_idx) {
682  // Global iterator pointing past the range indexed by the pattern
683  // which is the case for .end() iterators.
684  idx = _max_idx;
685  offset = _idx - _max_idx;
686  DASH_LOG_TRACE_VAR("GlobViewIter.lpos", _max_idx);
687  DASH_LOG_TRACE_VAR("GlobViewIter.lpos", idx);
688  DASH_LOG_TRACE_VAR("GlobViewIter.lpos", offset);
689  }
690  // Global index to local index and unit:
691  local_pos_t local_pos;
692  if (_viewspec == nullptr) {
693  // No viewspec mapping required:
694  local_pos = _pattern->local(idx);
695  } else {
696  // Viewspec projection required:
697  DASH_LOG_TRACE_VAR("GlobViewIter.lpos", *_viewspec);
698  auto glob_coords = coords(idx);
699  local_pos = _pattern->local_index(glob_coords);
700  }
701  local_pos.index += offset;
702  DASH_LOG_TRACE("GlobViewIter.lpos >",
703  "unit:", local_pos.unit,
704  "local index:", local_pos.index);
705  return local_pos;
706  }

◆ ndim()

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
static dim_t dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::ndim ( )
inlinestatic

The number of dimensions of the iterator's underlying pattern.

Definition at line 323 of file GlobViewIter.h.

324  {
325  return NumDimensions;
326  }

◆ operator const_pointer()

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::operator const_pointer ( ) const
inlineexplicit

Type conversion operator to GlobPtr.

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

Definition at line 333 of file GlobViewIter.h.

334  {
335  DASH_LOG_TRACE_VAR("GlobViewIter.const_pointer()", _idx);
336  typedef typename pattern_type::local_index_t
337  local_pos_t;
338  IndexType idx = _idx;
339  IndexType offset = 0;
340  DASH_LOG_TRACE_VAR("GlobViewIter.const_pointer", _max_idx);
341  // Convert iterator position (_idx) to local index and unit.
342  if (_idx > _max_idx) {
343  // Global iterator pointing past the range indexed by the pattern
344  // which is the case for .end() iterators.
345  idx = _max_idx;
346  offset += _idx - _max_idx;
347  }
348  DASH_LOG_TRACE_VAR("GlobViewIter.const_pointer", idx);
349  DASH_LOG_TRACE_VAR("GlobViewIter.const_pointer", offset);
350  // Global index to local index and unit:
351  local_pos_t local_pos;
352  if (_viewspec == nullptr) {
353  // No viewspec mapping required:
354  local_pos = _pattern->local(idx);
355  } else {
356  // Viewspec projection required:
357  auto glob_coords = coords(idx);
358  local_pos = _pattern->local_index(glob_coords);
359  }
360  DASH_LOG_TRACE_VAR("GlobViewIter.const_pointer >",
361  local_pos.unit);
362  DASH_LOG_TRACE_VAR("GlobViewIter.const_pointer >",
363  local_pos.index + offset);
364  // Create global pointer from unit and local offset:
365  auto const dart_pointer = _get_pointer_at(local_pos);
366  const_pointer gptr(dart_pointer);
367  gptr += offset;
368  return gptr;
369  }

◆ operator pointer()

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::operator pointer ( )
inlineexplicit

Type conversion operator to GlobPtr.

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

Definition at line 376 of file GlobViewIter.h.

377  {
378  DASH_LOG_TRACE_VAR("GlobViewIter.pointer()", _idx);
379  typedef typename pattern_type::local_index_t
380  local_pos_t;
381  IndexType idx = _idx;
382  IndexType offset = 0;
383  DASH_LOG_TRACE_VAR("GlobViewIter.pointer", _max_idx);
384  // Convert iterator position (_idx) to local index and unit.
385  if (_idx > _max_idx) {
386  // Global iterator pointing past the range indexed by the pattern
387  // which is the case for .end() iterators.
388  idx = _max_idx;
389  offset += _idx - _max_idx;
390  }
391  DASH_LOG_TRACE_VAR("GlobViewIter.pointer", idx);
392  DASH_LOG_TRACE_VAR("GlobViewIter.pointer", offset);
393  // Global index to local index and unit:
394  local_pos_t local_pos;
395  if (_viewspec == nullptr) {
396  // No viewspec mapping required:
397  local_pos = _pattern->local(idx);
398  } else {
399  // Viewspec projection required:
400  auto glob_coords = coords(idx);
401  local_pos = _pattern->local_index(glob_coords);
402  }
403  DASH_LOG_TRACE_VAR("GlobViewIter.pointer >", local_pos.unit);
404  DASH_LOG_TRACE_VAR("GlobViewIter.pointer >", local_pos.index + offset);
405  // Create global pointer from unit and local offset:
406 
407  auto const dart_pointer = _get_pointer_at(local_pos);
408  pointer gptr(dart_pointer);
409  gptr += offset;
410  return gptr;
411  }

◆ operator*() [1/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
reference dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::operator* ( )
inline

Dereference operator.

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

Definition at line 462 of file GlobViewIter.h.

463  {
464  return this->operator[](_idx);
465  }
reference operator[](index_type g_index)
Subscript operator, returns global reference to element at given global index.
Definition: GlobViewIter.h:481

◆ operator*() [2/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
const_reference dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::operator* ( ) const
inline

Dereference operator.

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

Definition at line 472 of file GlobViewIter.h.

473  {
474  return this->operator[](_idx);
475  }
reference operator[](index_type g_index)
Subscript operator, returns global reference to element at given global index.
Definition: GlobViewIter.h:481

◆ operator++() [1/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
self_t& dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::operator++ ( )
inlinenoexcept

Prefix increment operator.

Definition at line 748 of file GlobViewIter.h.

749  {
750  ++_idx;
751  return *this;
752  }

◆ operator++() [2/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
self_t dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::operator++ ( int  )
inlinenoexcept

Postfix increment operator.

Definition at line 757 of file GlobViewIter.h.

758  {
759  self_t result = *this;
760  ++_idx;
761  return result;
762  }

◆ operator--() [1/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
self_t& dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::operator-- ( )
inlinenoexcept

Prefix decrement operator.

Definition at line 767 of file GlobViewIter.h.

768  {
769  --_idx;
770  return *this;
771  }

◆ operator--() [2/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
self_t dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::operator-- ( int  )
inlinenoexcept

Postfix decrement operator.

Definition at line 776 of file GlobViewIter.h.

777  {
778  self_t result = *this;
779  --_idx;
780  return result;
781  }

◆ operator=() [1/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
template<typename T_ , class P_ , class GM_ , class Ptr_ , class Ref_ >
self_t& dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::operator= ( const GlobViewIter< T_, P_, GM_, Ptr_, Ref_ > &  other)
inline

Assignment operator.

Definition at line 283 of file GlobViewIter.h.

285  {
286  _globmem = other._globmem;
287  _pattern = other._pattern;
288  _viewspec = other._viewspec;
289  _idx = other._idx;
290  _view_idx_offset = other._view_idx_offset;
291  _max_idx = other._max_idx;
292  _myid = other._myid;
293 
294  return *this;
295  }

◆ operator=() [2/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
template<typename T_ , class P_ , class GM_ , class Ptr_ , class Ref_ >
self_t& dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::operator= ( GlobViewIter< T_, P_, GM_, Ptr_, Ref_ > &&  other)
inline

Move-assignment operator.

Definition at line 306 of file GlobViewIter.h.

308  {
309  _globmem = std::move(other._globmem);
310  _pattern = std::move(other._pattern);
311  _viewspec = std::move(other._viewspec);
312  _idx = std::move(other._idx);
313  _view_idx_offset = std::move(other._view_idx_offset);
314  _max_idx = std::move(other._max_idx);
315  _myid = std::move(other._myid);
316  // no ownership to transfer
317  return *this;
318  }

◆ operator[]() [1/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
reference dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::operator[] ( index_type  g_index)
inline

Subscript operator, returns global reference to element at given global index.

Parameters
g_indexThe global position of the element

Definition at line 481 of file GlobViewIter.h.

Referenced by dash::GlobViewIter< ElementT, PatternT, GlobMemT >::operator*().

484  {
485  typedef typename pattern_type::local_index_t
486  local_pos_t;
487  // Global index to local index and unit:
488  local_pos_t local_pos;
489  if (_viewspec == nullptr) {
490  // No viewspec mapping required:
491  local_pos = _pattern->local(g_index);
492  } else {
493  // Viewspec projection required:
494  auto glob_coords = coords(g_index);
495  local_pos = _pattern->local_index(glob_coords);
496  }
497  DASH_LOG_TRACE("GlobViewIter.[]",
498  "(index:", g_index, " voffset:", _view_idx_offset, ") ->",
499  "(unit:", local_pos.unit, " index:", local_pos.index, ")");
500  // Global reference to element at given position:
501 
502  auto const dart_pointer = _get_pointer_at(local_pos);
503  return reference(dart_pointer);
504  }

◆ operator[]() [2/2]

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
const_reference dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::operator[] ( index_type  g_index) const
inline

Subscript operator, returns global reference to element at given global index.

Parameters
g_indexThe global position of the element

Definition at line 510 of file GlobViewIter.h.

513  {
514  typedef typename pattern_type::local_index_t
515  local_pos_t;
516  // Global index to local index and unit:
517  local_pos_t local_pos;
518  if (_viewspec == nullptr) {
519  // No viewspec mapping required:
520  local_pos = _pattern->local(g_index);
521  } else {
522  // Viewspec projection required:
523  auto glob_coords = coords(g_index);
524  local_pos = _pattern->local_index(glob_coords);
525  }
526  DASH_LOG_TRACE("GlobViewIter.[]",
527  "(index:", g_index, " voffset:", _view_idx_offset, ") ->",
528  "(unit:", local_pos.unit, " index:", local_pos.index, ")");
529  // Global reference to element at given position:
530 
531  auto const dart_pointer = _get_pointer_at(local_pos);
532  return const_reference(dart_pointer);
533  }

◆ pos()

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
constexpr index_type dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::pos ( ) const
inlinenoexcept

Position of the iterator in its view's iteration space and the view's offset in global index space.

Definition at line 620 of file GlobViewIter.h.

Referenced by dash::GlobViewIter< ElementT, PatternT, GlobMemT >::operator--().

621  {
622  return _idx + _view_idx_offset;
623  }

◆ rpos()

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
index_type dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::rpos ( ) const
inlinenoexcept

Position of the iterator in its view's iteration space, disregarding the view's offset in global index space.

Definition at line 629 of file GlobViewIter.h.

630  {
631  return _idx;
632  }

◆ viewspec()

template<typename ElementType, class PatternType, class GlobMemType, class PointerType = typename GlobMemType::void_pointer::template rebind<ElementType>, class ReferenceType = GlobRef<ElementType>>
ViewSpecType dash::GlobViewIter< ElementType, PatternType, GlobMemType, PointerType, ReferenceType >::viewspec ( ) const
inline

The view that specifies this iterator's index range.

Definition at line 719 of file GlobViewIter.h.

720  {
721  if (_viewspec != nullptr) {
722  return *_viewspec;
723  }
724  return ViewSpecType(_pattern->extents());
725  }

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