4 #include <dash/Types.h> 5 #include <dash/GlobRef.h> 7 #include <dash/Exception.h> 8 #include <dash/memory/GlobHeapMem.h> 9 #include <dash/Allocator.h> 10 #include <dash/Array.h> 11 #include <dash/Meta.h> 13 #include <dash/list/ListRef.h> 14 #include <dash/list/LocalListRef.h> 15 #include <dash/list/GlobListIter.h> 16 #include <dash/list/internal/ListTypes.h> 170 typename ElementType,
176 "Type not supported for DASH containers");
178 template<
typename T_,
class A_>
179 friend class LocalListRef;
183 typedef List<ElementType, LocalMemorySpace> self_t;
185 typedef internal::ListNode<ElementType> node_type;
190 dash::CSRPattern<1, dash::ROW_MAJOR, int> >
203 typedef typename dash::default_size_t size_type;
220 typedef std::reverse_iterator< iterator> reverse_iterator;
221 typedef std::reverse_iterator<const_iterator> const_reverse_iterator;
226 typedef value_type & local_reference;
227 typedef const value_type & const_local_reference;
255 size_type _remote_size
258 local_iterator _lbegin;
260 local_iterator _lend;
264 local_sizes_map _local_sizes;
268 size_type _local_buffer_size
284 DASH_LOG_TRACE(
"List() >",
"default constructor");
298 DASH_LOG_TRACE(
"List(nelem,team)",
"nelem:", nelem);
299 if (_team->
size() > 0) {
301 _local_sizes.
local[0] = 0;
305 DASH_LOG_TRACE(
"List(nelem,team) >");
316 , _local_buffer_size(nlbuf)
318 DASH_LOG_TRACE(
"List(nelem,nlbuf,team)",
319 "nelem:", nelem,
"nlbuf:", nlbuf);
320 if (_team->
size() > 0) {
322 _local_sizes.
local[0] = 0;
326 DASH_LOG_TRACE(
"List(nelem,nlbuf,team) >");
335 DASH_LOG_TRACE_VAR(
"List.~List()",
this);
337 DASH_LOG_TRACE_VAR(
"List.~List >",
this);
415 constexpr const_iterator
begin() const noexcept
431 constexpr const_iterator
end() const noexcept
447 constexpr const_local_iterator
lbegin() const noexcept
463 constexpr const_local_iterator
lend() const noexcept
475 return std::numeric_limits<index_type>::max();
483 constexpr size_type
size() const noexcept
485 return _remote_size + _local_sizes.
local[0];
505 return _globmem->
size();
515 inline iterator
erase(const_iterator position)
527 inline iterator
erase(const_iterator
first, const_iterator last)
549 constexpr size_type
lsize() const noexcept
551 return _local_sizes.
local[0];
562 return _globmem !=
nullptr 572 constexpr
bool empty() const noexcept
583 DASH_LOG_TRACE_VAR(
"List.barrier()", _team);
585 if (_globmem !=
nullptr) {
590 for (
int u = 0; u < _team->
size(); ++u) {
592 size_type local_size_u = _local_sizes[u];
593 _remote_size += local_size_u;
596 DASH_LOG_TRACE(
"List.barrier()",
"passed barrier");
611 DASH_LOG_TRACE(
"List.allocate()");
612 DASH_LOG_TRACE_VAR(
"List.allocate", nelem);
613 DASH_LOG_TRACE_VAR(
"List.allocate", _local_buffer_size);
615 DASH_LOG_TRACE(
"List.allocate",
616 "initializing with Team::All()");
618 DASH_LOG_TRACE_VAR(
"List.allocate",
team.
dart_id());
620 DASH_LOG_TRACE(
"List.allocate",
621 "initializing with initial team");
623 DASH_ASSERT_GT(_local_buffer_size, 0,
"local buffer size must not be 0");
624 if (nelem < _team->
size() * _local_buffer_size) {
625 nelem = _team->
size() * _local_buffer_size;
628 auto lcap = dash::math::div_ceil(nelem, _team->
size());
630 _myid = _team->myid();
632 DASH_LOG_TRACE_VAR(
"List.allocate", lcap);
636 _begin = iterator(_globmem, _nil_node);
639 _lbegin = _globmem->
lbegin();
643 DASH_LOG_TRACE_VAR(
"List.allocate", _myid);
652 DASH_LOG_TRACE(
"List.allocate",
653 "waiting for allocation of all units");
656 DASH_LOG_TRACE(
"List.allocate >",
"finished");
668 DASH_LOG_TRACE_VAR(
"List.deallocate()",
this);
679 DASH_LOG_TRACE_VAR(
"List.deallocate()", _globmem);
680 if (_globmem !=
nullptr) {
684 _local_sizes.
local[0] = 0;
686 DASH_LOG_TRACE_VAR(
"List.deallocate >",
this);
693 #endif // DASH__LIST_H__ constexpr const_iterator end() const noexcept
Global pointer to the end of the list.
global_unit_t myid()
Shortcut to query the global unit ID of the calling unit.
internal::default_unsigned_index default_size_t
Unsigned integer type used as default for size values.
void barrier()
Establish a barrier for all units operating on the list, publishing all changes to all units...
This class is a simple memory pool which holds allocates elements of size ValueType.
constexpr size_type size() const noexcept
Total number of elements in attached memory space, including size of local unattached memory segments...
constexpr size_type size() const noexcept
The size of the list.
void resize(size_t num_elements)
Resizes the list so its capacity is changed to the given number of elements.
local_iterator lbegin() noexcept
Native pointer to the first local element in the list.
iterator erase(const_iterator position)
Removes and destroys single element referenced by given iterator from the container, decreasing the container size by 1.
index_type difference_type
Public types as required by STL list concept.
void deallocate()
Free global memory allocated by this container instance.
bool allocate(size_type nelem=0, dash::Team &team=dash::Team::All())
Allocate memory for this container in global memory.
local_iterator lend() noexcept
Native pointer to the end 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.
constexpr size_type max_size() const noexcept
Maximum number of elements a list container can hold, e.g.
void unregister_deallocator(void *object, Deallocator::dealloc_function dealloc)
Unregister a deallocator function for a team-allocated object.
void commit()
Commit changes of local memory region to global memory space.
bool is_initialized()
Check whether DASH has been initialized already.
Proxy type referencing a dash::List.
iterator end() noexcept
Global pointer to the end of the list.
List(Team &team=dash::Team::Null())
Default constructor, for delayed allocation.
size_t size() const
The number of units in this team.
constexpr size_type capacity() const noexcept
The number of elements that can be held in currently allocated storage of the list.
local_type local
Local proxy object, allows use in range-based for loops.
Global memory region with dynamic size.
List(size_type nelem, size_type nlbuf, Team &team=dash::Team::All())
Constructor, creates a new constainer instance with the specified initial global container capacity a...
internal::default_signed_index default_index_t
Signed integer type used as default for index values.
iterator begin() noexcept
Global pointer to the beginning of the list.
A Team instance specifies a subset of all available units.
constexpr const_iterator begin() const noexcept
Global pointer to the beginning of the list.
constexpr const_local_iterator lend() const noexcept
Native pointer to the end of the list.
void pop_back()
Removes and destroys the last element in the list, reducing the container size by one...
all units allocate invdividually in local memory and synchronize in epochs
constexpr size_type lcapacity() const noexcept
The capacity of the local part of the list.
constexpr const_local_iterator lbegin() const noexcept
Native pointer to the first local element in the list.
~List()
Destructor, deallocates local and global memory acquired by the container instance.
Iterator on global buckets.
void pop_front()
Removes and destroys the first element in the list, reducing the container size by one...
void push_back(const value_type &element)
Inserts a new element at the end of the list, after its current last element.
constexpr size_type local_size() const noexcept
Number of elements in local memory space.
struct dash::unit_id< dash::local_unit, dart_team_unit_t > team_unit_t
Unit ID to use for team-local IDs.
ElementType value_type
Public types as required by DASH list concept.
iterator erase(const_iterator first, const_iterator last)
Removes and destroys elements in the given range from the container, decreasing the container size by...
Type trait indicating whether the specified type is eligible for elements of DASH containers...
static Team & Null()
The invariant Team instance representing an undefined team.
void register_deallocator(void *object, Deallocator::dealloc_function dealloc)
Register a deallocator function for a team-allocated object.
constexpr Team & team() const noexcept
The team containing all units accessing this list.
constexpr bool empty() const noexcept
Whether the list is empty.
static Team & All()
The invariant Team instance containing all available units.
List(size_type nelem=0, Team &team=dash::Team::All())
Constructor, creates a new constainer instance with the specified initial global container capacity a...
reference front()
Accesses the first element in the list.
constexpr size_type lsize() const noexcept
The number of elements in the local part of the list.
local_pointer & lbegin() noexcept
Native pointer of the initial address of the local memory of the unit that initialized this GlobHeapM...
dart_team_t dart_id() const
Index of this team relative to global team dash::Team::All().
bool allocate(size_type nelem, dash::DistributionSpec< 1 > distribution, dash::Team &team=dash::Team::All())
Delayed allocation of global memory using a one-dimensional distribution spec.
local_type local
Local proxy object, allows use in range-based for loops.
reference back()
Accesses the last element in the list.