1 #ifndef DASH__LIST__LOCAL_LIST_REF_H__INCLUDED 2 #define DASH__LIST__LOCAL_LIST_REF_H__INCLUDED 7 #include <dash/Types.h> 8 #include <dash/GlobRef.h> 10 #include <dash/Exception.h> 11 #include <dash/Cartesian.h> 12 #include <dash/Dimensional.h> 13 #include <dash/memory/GlobHeapMem.h> 14 #include <dash/Allocator.h> 16 #include <dash/list/internal/ListTypes.h> 18 #include <dash/iterator/GlobIter.h> 38 template <
typename T_,
typename LM_>
41 static const dim_t NumDimensions = 1;
44 typedef LocalListRef<T, LMemSpace>
46 typedef List<T, LMemSpace>
48 typedef ViewSpec<NumDimensions, dash::default_index_t>
51 typedef typename list_type::node_type ListNode_t;
53 typedef typename list_type::glob_mem_type
63 typedef typename std::make_unsigned<index_type>::type size_type;
64 typedef typename std::make_unsigned<index_type>::type difference_type;
69 typedef typename list_type::local_reference reference;
70 typedef typename list_type::const_local_reference const_reference;
75 typedef std::reverse_iterator< iterator> reverse_iterator;
76 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
91 const ViewSpec_t & viewspec)
99 inline iterator
begin() const noexcept
101 return _list->_lbegin;
107 inline iterator
end() const noexcept
114 const_iterator position,
116 const value_type & value)
118 DASH_LOG_TRACE(
"LocalListRef.insert()");
121 node.lprev =
nullptr;
122 node.lnext =
nullptr;
125 iterator it_insert_end = _list->_end;
127 "dash::LocalListRef.pop_back is not implemented");
129 DASH_LOG_TRACE(
"LocalListRef.insert >");
130 return it_insert_end;
141 DASH_LOG_TRACE(
"LocalListRef.push_back()");
143 ListNode_t * node_lptr =
nullptr;
147 node.lprev =
nullptr;
148 node.lnext =
nullptr;
152 auto l_cap_old = _list->_globmem->
local_size();
154 auto l_size_old = _list->_local_sizes.
local[0];
156 _list->_local_sizes.
local[0]++;
158 auto l_size_new = _list->_local_sizes.
local[0];
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,
")");
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()");
172 node_lptr =
static_cast<ListNode_t *
>(
173 _list->_globmem->
lbegin() + l_size_old);
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) {
181 node.lprev =
static_cast<ListNode_t *
>(
182 _list->_globmem->
lbegin() + (l_size_old - 1));
184 DASH_ASSERT(node.lprev->lnext ==
nullptr);
185 node.lprev->lnext = node_lptr;
186 DASH_LOG_TRACE_VAR(
"LocalListRef.push_back", node.lprev->lnext);
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);
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 >");
205 "dash::LocalListRef.pop_back is not implemented");
214 "dash::LocalListRef._back is not implemented");
226 "dash::ListLocalRef.push_front is not implemented");
236 "dash::LocalListRef.pop_front is not implemented");
245 "dash::LocalListRef.front is not implemented");
251 inline size_type
size() const noexcept
253 return _list->
lsize();
263 index_type global_index)
const 270 list_type *
const _list;
272 ViewSpec_t _viewspec;
280 #endif // DASH__LIST__LOCAL_LIST_REF_H__INCLUDED reference back()
Accesses the last element in the list.
This class is a simple memory pool which holds allocates elements of size ValueType.
void pop_front()
Removes and destroys the first element in the list, reducing the container size by one...
reference front()
Accesses the first element in the list.
int dim_t
Scalar type for a dimension value, with 0 indicating the first dimension.
size_type size() const noexcept
Number of list elements in local memory.
iterator end() const noexcept
Pointer past final local element in the list.
void push_back(const value_type &value)
Inserts a new element at the end of the list, after its current last element.
internal::default_signed_index default_index_t
Signed integer type used as default for index values.
iterator insert(const_iterator position, const value_type &value)
dash::default_index_t index_type
Type definitions required for dash::List concept:
local_pointer grow(size_type num_elements)
Increase capacity of local segment of global memory region by the given number of elements...
DART Global pointer type.
constexpr size_type local_size() const noexcept
Number of elements in local memory space.
LocalListRef(list_type *list)
Constructor, creates a local access proxy for the given list.
LocalListRef(list_type *list, const ViewSpec_t &viewspec)
void pop_back()
Removes and destroys the last element in the list, reducing the container size by one...
T value_type
Type definitions required for std::list concept:
iterator begin() const noexcept
Pointer to initial local element in the list.
constexpr bool is_local(index_type global_index) const
Checks whether the given global index is local to the calling unit.
constexpr size_type lsize() const noexcept
The number of elements in the local part of the list.
void push_front(const value_type &value)
Inserts a new element at the beginning of the list, before its current first element.
local_pointer & lbegin() noexcept
Native pointer of the initial address of the local memory of the unit that initialized this GlobHeapM...
local_type local
Local proxy object, allows use in range-based for loops.