|
| List (Team &team=dash::Team::Null()) |
| Default constructor, for delayed allocation. More...
|
|
| List (size_type nelem=0, Team &team=dash::Team::All()) |
| Constructor, creates a new constainer instance with the specified initial global container capacity and associated units. More...
|
|
| 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 and associated units. More...
|
|
| ~List () |
| Destructor, deallocates local and global memory acquired by the container instance. More...
|
|
void | push_back (const value_type &element) |
| 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...
|
|
iterator | begin () noexcept |
| Global pointer to the beginning of the list. More...
|
|
constexpr const_iterator | begin () const noexcept |
| Global pointer to the beginning of the list. More...
|
|
iterator | end () noexcept |
| Global pointer to the end of the list. More...
|
|
constexpr const_iterator | end () const noexcept |
| Global pointer to the end of the list. More...
|
|
local_iterator | lbegin () noexcept |
| Native pointer to the first local element in the list. More...
|
|
constexpr const_local_iterator | lbegin () const noexcept |
| Native pointer to the first local element in the list. More...
|
|
local_iterator | lend () noexcept |
| Native pointer to the end of the list. More...
|
|
constexpr const_local_iterator | lend () const noexcept |
| Native pointer to the end of the list. More...
|
|
constexpr size_type | max_size () const noexcept |
| Maximum number of elements a list container can hold, e.g. More...
|
|
constexpr size_type | size () const noexcept |
| The size of the list. More...
|
|
void | resize (size_t num_elements) |
| Resizes the list so its capacity is changed to the given number of elements. More...
|
|
constexpr size_type | capacity () const noexcept |
| The number of elements that can be held in currently allocated storage of the list. More...
|
|
iterator | erase (const_iterator position) |
| Removes and destroys single element referenced by given iterator from the container, decreasing the container size by 1. More...
|
|
iterator | erase (const_iterator first, const_iterator last) |
| Removes and destroys elements in the given range from the container, decreasing the container size by the number of elements removed. More...
|
|
constexpr Team & | team () const noexcept |
| The team containing all units accessing this list. More...
|
|
constexpr size_type | lsize () const noexcept |
| The number of elements in the local part of the list. More...
|
|
constexpr size_type | lcapacity () const noexcept |
| The capacity of the local part of the list. More...
|
|
constexpr bool | empty () const noexcept |
| Whether the list is empty. More...
|
|
void | barrier () |
| Establish a barrier for all units operating on the list, publishing all changes to all units. More...
|
|
bool | allocate (size_type nelem=0, dash::Team &team=dash::Team::All()) |
| Allocate memory for this container in global memory. More...
|
|
void | deallocate () |
| Free global memory allocated by this container instance. More...
|
|
template<typename ElementType, typename LocalMemorySpace = dash::HostSpace>
class dash::List< ElementType, LocalMemorySpace >
Usage examples:
size_t initial_local_capacity = 100; size_t initial_capacity = dash::size() * initial_local_capacity; dash::List<int> list(initial_capacity);
assert(list.size() == 0); assert(list.capacity() == initial_capacity);
list.local.push_back(dash::myid() + 2 + dash::myid() * 3); list.local.push_back(dash::myid() + 3 + dash::myid() * 3); list.local.push_back(dash::myid() + 4 + dash::myid() * 3);
// Logical structure of list for 3 units: // // | unit 0 | unit 1 | unit 2 | // -—|------——|------——|-----——|— // Nil —> 2 –. .—> 5 –. .—> 8 –. // .– 3 <-' | .– 6 <-' | .– 9 <-' // -> 4 -—'
-> 7 -—' `-> 10 —> Nil
assert(list.local.size() == 1); assert(list.local.front() == dash::myid() + 1); assert(list.local.back() == dash::myid() + 3);
list.barrier(); assert(list.size() == dash::size() * 3);
if (dash::myid() == 0) { list.push_front(0); list.push_front(1); list.push_back(11); list.push_back(12); list.push_back(13); list.push_back(14); }
// Logical structure of list for 3 units: // // | unit 0 | unit 1 | unit 2 | // -—|------——|------——|-----——|— // Nil —> 0 –. .—> 5 –. .—> 8 –. // .– 1 <-' | .– 6 <-' | .– 9 <-' // -> 2 –. |
-> 7 -—' `-> 10 –. // .– 3 <-' | .– 11 <-' // -> 4 -—'
-> 12 –. // .– 13 <-' // `-> 14 —> Nil
list.balance();
// Logical structure of list for 3 units: // // | unit 0 | unit 1 | unit 2 | // -—|------——|------——|-----——|— // Nil —> 0 –. .—> 5 –. .—> 10 –. // .– 1 <-' | .– 6 <-' | .– 11 <-' // -> 2 –. |
-> 7 –. | `-> 12 –. // .– 3 <-' | .– 8 <-' | .– 13 –' // -> 4 -—'
-> 9 -—' `-> 14 —> Nil
A dynamic bi-directional list with support for workload balancing.
- Implemented concept:
- List Concept
Definition at line 27 of file ListRef.h.
template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
Constructor, creates a new constainer instance with the specified initial global container capacity and associated units.
Definition at line 291 of file List.h.
References dash::List< ElementType, LocalMemorySpace >::allocate(), dash::Array< ElementType, IndexType, PatternType, LocalMemSpaceT >::allocate(), dash::List< ElementType, LocalMemorySpace >::barrier(), dash::Array< ElementType, IndexType, PatternType, LocalMemSpaceT >::local, dash::Team::size(), and dash::List< ElementType, LocalMemorySpace >::team().
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) >");
void barrier()
Establish a barrier for all units operating on the list, publishing all changes to all units...
bool allocate(size_type nelem=0, dash::Team &team=dash::Team::All())
Allocate memory for this container in global memory.
size_t size() const
The number of units in this team.
local_type local
Local proxy object, allows use in range-based for loops.
constexpr Team & team() const noexcept
The team containing all units accessing this list.
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.
template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
Constructor, creates a new constainer instance with the specified initial global container capacity and associated units.
Definition at line 312 of file List.h.
References dash::List< ElementType, LocalMemorySpace >::allocate(), dash::Array< ElementType, IndexType, PatternType, LocalMemSpaceT >::allocate(), dash::List< ElementType, LocalMemorySpace >::barrier(), dash::Array< ElementType, IndexType, PatternType, LocalMemSpaceT >::local, dash::Team::size(), and dash::List< ElementType, LocalMemorySpace >::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) >");
void barrier()
Establish a barrier for all units operating on the list, publishing all changes to all units...
bool allocate(size_type nelem=0, dash::Team &team=dash::Team::All())
Allocate memory for this container in global memory.
size_t size() const
The number of units in this team.
local_type local
Local proxy object, allows use in range-based for loops.
constexpr Team & team() const noexcept
The team containing all units accessing this list.
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.
template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
Allocate memory for this container in global memory.
Calls implicit barrier on the team associated with the container instance.
- Parameters
-
nelem | Initial global capacity of the container. |
team | Team containing all units associated with the container. |
Definition at line 605 of file List.h.
References dash::Team::dart_id(), dash::List< ElementType, LocalMemorySpace >::deallocate(), dash::is_initialized(), dash::GlobHeapMem< ElementType, LocalMemorySpace, AllocationPolicy, LocalAlloc >::lbegin(), dash::Team::Null(), dash::Team::register_deallocator(), dash::List< ElementType, LocalMemorySpace >::size(), dash::Team::size(), and dash::List< ElementType, LocalMemorySpace >::team().
Referenced by dash::List< ElementType, LocalMemorySpace >::List().
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);
634 _globmem =
new glob_mem_type(lcap, *_team);
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");
constexpr size_type size() const noexcept
The size of the list.
void deallocate()
Free global memory allocated by this container instance.
bool is_initialized()
Check whether DASH has been initialized already.
size_t size() const
The number of units in this team.
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.
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().
template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
void dash::List< ElementType, LocalMemorySpace >::barrier |
( |
| ) |
|
|
inline |
Establish a barrier for all units operating on the list, publishing all changes to all units.
Definition at line 581 of file List.h.
References dash::GlobHeapMem< ElementType, LocalMemorySpace, AllocationPolicy, LocalAlloc >::commit(), and dash::Team::size().
Referenced by dash::List< ElementType, LocalMemorySpace >::deallocate(), and dash::List< ElementType, LocalMemorySpace >::List().
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");
void commit()
Commit changes of local memory region to global memory space.
size_t size() const
The number of units in this team.
template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
void dash::List< ElementType, LocalMemorySpace >::deallocate |
( |
| ) |
|
|
inline |
Free global memory allocated by this container instance.
Calls implicit barrier on the team associated with the container instance.
Definition at line 666 of file List.h.
References dash::List< ElementType, LocalMemorySpace >::barrier(), dash::is_initialized(), dash::Array< ElementType, IndexType, PatternType, LocalMemSpaceT >::local, and dash::Team::unregister_deallocator().
Referenced by dash::List< ElementType, LocalMemorySpace >::allocate(), and dash::List< ElementType, LocalMemorySpace >::~List().
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);
void barrier()
Establish a barrier for all units operating on the list, publishing all changes to all units...
void deallocate()
Free global memory allocated by this container instance.
void unregister_deallocator(void *object, Deallocator::dealloc_function dealloc)
Unregister a deallocator function for a team-allocated object.
bool is_initialized()
Check whether DASH has been initialized already.
local_type local
Local proxy object, allows use in range-based for loops.
template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
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.
The operation takes immediate effect for the calling unit. For other units, changes will only be visible after the next call of barrier
. As one-sided, non-collective allocation on remote units is not possible with most DART communication backends, the new list element is allocated locally and moved to its final position in global memory in barrier
.
Definition at line 353 of file List.h.
template<typename ElementType , typename LocalMemorySpace = dash::HostSpace>
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.
The operation takes immediate effect for the calling unit. For other units, changes will only be visible after the next call of barrier
. As one-sided, non-collective allocation on remote units is not possible with most DART communication backends, the new list element is allocated locally and moved to its final position in global memory in barrier
.
Definition at line 385 of file List.h.