DASH  0.3.0
dash::LocalListRef< T, LMemSpace > Class Template Reference

Proxy type representing a local view on a referenced dash::List. More...

#include <LocalListRef.h>

Public Types

typedef dash::default_index_t index_type
 Type definitions required for dash::List concept: More...
 
typedef T value_type
 Type definitions required for std::list concept: More...
 
typedef std::make_unsigned< index_type >::type size_type
 
typedef std::make_unsigned< index_type >::type difference_type
 
typedef glob_mem_type::local_pointer pointer
 
typedef glob_mem_type::const_local_pointer const_pointer
 
typedef list_type::local_reference reference
 
typedef list_type::const_local_reference const_reference
 
typedef list_type::local_iterator iterator
 
typedef list_type::const_local_iterator const_iterator
 
typedef std::reverse_iterator< iteratorreverse_iterator
 
typedef std::reverse_iterator< const_iteratorconst_reverse_iterator
 

Public Member Functions

 LocalListRef (list_type *list)
 Constructor, creates a local access proxy for the given list. More...
 
 LocalListRef (list_type *list, const ViewSpec_t &viewspec)
 
iterator begin () const noexcept
 Pointer to initial local element in the list. More...
 
iterator end () const noexcept
 Pointer past final local element in the list. More...
 
iterator insert (const_iterator position, const value_type &value)
 
void push_back (const value_type &value)
 Inserts a new element at the end of the list, after its current last element. More...
 
void pop_back ()
 Removes and destroys the last element in the list, reducing the container size by one. More...
 
reference back ()
 Accesses the last element in the list. More...
 
void push_front (const value_type &value)
 Inserts a new element at the beginning of the list, before its current first element. More...
 
void pop_front ()
 Removes and destroys the first element in the list, reducing the container size by one. More...
 
reference front ()
 Accesses the first element in the list. More...
 
size_type size () const noexcept
 Number of list elements in local memory. More...
 
constexpr bool is_local (index_type global_index) const
 Checks whether the given global index is local to the calling unit. More...
 

Detailed Description

template<typename T, class LMemSpace>
class dash::LocalListRef< T, LMemSpace >

Proxy type representing a local view on a referenced dash::List.

Implemented concept:
List Concept

Definition at line 33 of file ListRef.h.

Member Typedef Documentation

◆ index_type

template<typename T, class LMemSpace>
typedef dash::default_index_t dash::LocalListRef< T, LMemSpace >::index_type

Type definitions required for dash::List concept:

Definition at line 58 of file LocalListRef.h.

◆ value_type

template<typename T, class LMemSpace>
typedef T dash::LocalListRef< T, LMemSpace >::value_type

Type definitions required for std::list concept:

Definition at line 62 of file LocalListRef.h.

Constructor & Destructor Documentation

◆ LocalListRef() [1/2]

template<typename T, class LMemSpace>
dash::LocalListRef< T, LMemSpace >::LocalListRef ( list_type list)
inline

Constructor, creates a local access proxy for the given list.

Definition at line 82 of file LocalListRef.h.

84  : _list(list)
85  { }

◆ LocalListRef() [2/2]

template<typename T, class LMemSpace>
dash::LocalListRef< T, LMemSpace >::LocalListRef ( list_type list,
const ViewSpec_t viewspec 
)
inline
Parameters
listPointer to list instance referenced by this view.
viewspecThe view's offset and extent within the referenced list.

Definition at line 87 of file LocalListRef.h.

92  : _list(list),
93  _viewspec(viewspec)
94  { }

Member Function Documentation

◆ back()

template<typename T, class LMemSpace>
reference dash::LocalListRef< T, LMemSpace >::back ( )
inline

Accesses the last element in the list.

Definition at line 211 of file LocalListRef.h.

212  {
214  "dash::LocalListRef._back is not implemented");
215  }

◆ begin()

template<typename T, class LMemSpace>
iterator dash::LocalListRef< T, LMemSpace >::begin ( ) const
inlinenoexcept

Pointer to initial local element in the list.

Definition at line 99 of file LocalListRef.h.

100  {
101  return _list->_lbegin;
102  }

◆ end()

template<typename T, class LMemSpace>
iterator dash::LocalListRef< T, LMemSpace >::end ( ) const
inlinenoexcept

Pointer past final local element in the list.

Definition at line 107 of file LocalListRef.h.

108  {
109  return _list->_lend;
110  }

◆ front()

template<typename T, class LMemSpace>
reference dash::LocalListRef< T, LMemSpace >::front ( )
inline

Accesses the first element in the list.

Definition at line 242 of file LocalListRef.h.

243  {
245  "dash::LocalListRef.front is not implemented");
246  }

◆ insert()

template<typename T, class LMemSpace>
iterator dash::LocalListRef< T, LMemSpace >::insert ( const_iterator  position,
const value_type value 
)
inline
Parameters
positionPosition in the list where the new element is inserted.
valueValue to be copied in the inserted element.

Definition at line 112 of file LocalListRef.h.

117  {
118  DASH_LOG_TRACE("LocalListRef.insert()");
119  // New element node:
120  ListNode_t node;
121  node.lprev = nullptr;
122  node.lnext = nullptr;
123  node.gprev = _gprev;
124  node.gnext = _gnext;
125  iterator it_insert_end = _list->_end;
127  "dash::LocalListRef.pop_back is not implemented");
128 
129  DASH_LOG_TRACE("LocalListRef.insert >");
130  return it_insert_end;
131  }

◆ is_local()

template<typename T, class LMemSpace>
constexpr bool dash::LocalListRef< T, LMemSpace >::is_local ( index_type  global_index) const
inline

Checks whether the given global index is local to the calling unit.

Returns
True
Parameters
global_indexA global list index

Definition at line 261 of file LocalListRef.h.

264  {
265  return true;
266  }

◆ pop_back()

template<typename T, class LMemSpace>
void dash::LocalListRef< T, LMemSpace >::pop_back ( )
inline

Removes and destroys the last element in the list, reducing the container size by one.

Definition at line 202 of file LocalListRef.h.

203  {
205  "dash::LocalListRef.pop_back is not implemented");
206  }

◆ pop_front()

template<typename T, class LMemSpace>
void dash::LocalListRef< T, LMemSpace >::pop_front ( )
inline

Removes and destroys the first element in the list, reducing the container size by one.

Definition at line 233 of file LocalListRef.h.

234  {
236  "dash::LocalListRef.pop_front is not implemented");
237  }

◆ push_back()

template<typename T, class LMemSpace>
void dash::LocalListRef< T, LMemSpace >::push_back ( const value_type value)
inline

Inserts a new element at the end of the list, after its current last element.

The content of value is copied or moved to the inserted element. Increases the container size by one.

Definition at line 139 of file LocalListRef.h.

140  {
141  DASH_LOG_TRACE("LocalListRef.push_back()");
142  // Pointer to new node element:
143  ListNode_t * node_lptr = nullptr;
144  // New element node:
145  ListNode_t node;
146  node.value = value;
147  node.lprev = nullptr;
148  node.lnext = nullptr;
149  node.gprev = _gprev;
150  node.gnext = _gnext;
151  // Local capacity before operation:
152  auto l_cap_old = _list->_globmem->local_size();
153  // Number of local elements before operation:
154  auto l_size_old = _list->_local_sizes.local[0];
155  // Update local size:
156  _list->_local_sizes.local[0]++;
157  // Number of local elements after operation:
158  auto l_size_new = _list->_local_sizes.local[0];
159 
160  DASH_LOG_TRACE_VAR("LocalListRef.push_back", l_cap_old);
161  DASH_LOG_TRACE_VAR("LocalListRef.push_back", l_size_old);
162  if (l_size_new > l_cap_old) {
163  DASH_LOG_TRACE("LocalListRef.push_back",
164  "globmem.grow(", _list->_local_buffer_size, ")");
165  // Acquire local memory for new node:
166  node_lptr = static_cast<ListNode_t *>(
167  _list->_globmem->grow(_list->_local_buffer_size));
168  DASH_ASSERT_GT(_list->_globmem->local_size(), l_cap_old,
169  "local capacity not increased after globmem.grow()");
170  } else {
171  // No allocation required (cast from LocalBucketIter<T> to T *):
172  node_lptr = static_cast<ListNode_t *>(
173  _list->_globmem->lbegin() + l_size_old);
174  }
175  // Local capacity before operation:
176  auto l_cap_new = _list->_globmem->local_size();
177  DASH_LOG_TRACE("LocalListRef.push_back",
178  "node target address:", node_lptr);
179  if (l_size_old > 0) {
180  // Set node predecessor (cast from LocalBucketIter<T> to T *):
181  node.lprev = static_cast<ListNode_t *>(
182  _list->_globmem->lbegin() + (l_size_old - 1));
183  // Set successor of node predecessor to new node:
184  DASH_ASSERT(node.lprev->lnext == nullptr);
185  node.lprev->lnext = node_lptr;
186  DASH_LOG_TRACE_VAR("LocalListRef.push_back", node.lprev->lnext);
187  }
188  DASH_LOG_TRACE_VAR("LocalListRef.push_back", node.lprev);
189  DASH_LOG_TRACE_VAR("LocalListRef.push_back", node.value);
190  DASH_LOG_TRACE_VAR("LocalListRef.push_back", node.lnext);
191  // Copy new node to target address:
192  *node_lptr = node;
193  DASH_LOG_TRACE_VAR("LocalListRef.push_back", l_cap_new);
194  DASH_LOG_TRACE_VAR("LocalListRef.push_back", l_size_new);
195  DASH_LOG_TRACE("LocalListRef.push_back >");
196  }
local_pointer grow(size_type num_elements)
Increase capacity of local segment of global memory region by the given number of elements...
Definition: GlobHeapMem.h:485
constexpr size_type local_size() const noexcept
Number of elements in local memory space.
Definition: GlobHeapMem.h:430
local_pointer & lbegin() noexcept
Native pointer of the initial address of the local memory of the unit that initialized this GlobHeapM...
Definition: GlobHeapMem.h:831
local_type local
Local proxy object, allows use in range-based for loops.
Definition: Array.h:732

◆ push_front()

template<typename T, class LMemSpace>
void dash::LocalListRef< T, LMemSpace >::push_front ( const value_type value)
inline

Inserts a new element at the beginning of the list, before its current first element.

The content of value is copied or moved to the inserted element. Increases the container size by one.

Definition at line 223 of file LocalListRef.h.

224  {
226  "dash::ListLocalRef.push_front is not implemented");
227  }

◆ size()

template<typename T, class LMemSpace>
size_type dash::LocalListRef< T, LMemSpace >::size ( ) const
inlinenoexcept

Number of list elements in local memory.

Definition at line 251 of file LocalListRef.h.

252  {
253  return _list->lsize();
254  }
constexpr size_type lsize() const noexcept
The number of elements in the local part of the list.
Definition: List.h:549

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