Subclass for the composite NodeCollection type. More...
#include <node_collection.h>
Public Member Functions | |
| NodeCollectionComposite (const NodeCollectionPrimitive &, size_t, size_t, size_t) | |
| Create a composite from a primitive, with boundaries and step length. | |
| NodeCollectionComposite (const NodeCollectionComposite &, size_t, size_t, size_t) | |
| Creates a new composite from another, with boundaries and step length. | |
| NodeCollectionComposite (const std::vector< NodeCollectionPrimitive > &) | |
| Create a composite from a vector of primitives. | |
| NodeCollectionComposite (const NodeCollectionComposite &)=default | |
| Composite copy constructor. | |
| std::ostream & | print_me (std::ostream &) const override |
| Print out the contents of the NodeCollection in a pretty and informative way. | |
| size_t | operator[] (const size_t) const override |
| Get the node ID in the specified index in the NodeCollection. | |
| NodeCollectionPTR | operator+ (NodeCollectionPTR rhs) const override |
| Addition operator. | |
| NodeCollectionPTR | operator+ (const NodeCollectionPrimitive &rhs) const |
| bool | operator== (const NodeCollectionPTR rhs) const override |
| const_iterator | begin (NodeCollectionPTR=NodeCollectionPTR(nullptr)) const override |
| Method to get an iterator representing the beginning of the NodeCollection. | |
| const_iterator | thread_local_begin (NodeCollectionPTR=NodeCollectionPTR(nullptr)) const override |
| Return iterator stepping from first node on the thread it is called on over nodes on that thread. | |
| const_iterator | rank_local_begin (NodeCollectionPTR=NodeCollectionPTR(nullptr)) const override |
| Method to get an iterator representing the beginning of the NodeCollection. | |
| const_iterator | end (NodeCollectionPTR=NodeCollectionPTR(nullptr)) const override |
| Method to get an iterator representing the end of the NodeCollection. | |
| size_t | size () const override |
| Returns total number of node IDs in the composite. | |
| size_t | stride () const override |
| Returns the stride between node IDs in the composite. | |
| bool | contains (const size_t node_id) const override |
| Check if the NodeCollection contains a specified node ID. | |
| NodeCollectionPTR | slice (size_t start, size_t end, size_t step=1) const override |
| Slices the NodeCollection to the boundaries, with an optional step parameter. | |
| void | set_metadata (NodeCollectionMetadataPTR) override |
| Sets the metadata of the NodeCollection. | |
| NodeCollectionMetadataPTR | get_metadata () const override |
| Gets the metadata of the NodeCollection. | |
| bool | is_range () const override |
| bool | empty () const override |
| Checks if the NodeCollection has no elements. | |
| long | get_nc_index (const size_t) const override |
| Returns index of node with given node ID in NodeCollection. | |
| bool | has_proxies () const override |
| Returns whether the NodeCollection contains any nodes with proxies or not. | |
Public Member Functions inherited from nest::NodeCollection | |
| NodeCollection () | |
| Initializer gets current fingerprint from the kernel. | |
| virtual | ~NodeCollection ()=default |
| bool | valid () const |
| Check to see if the fingerprint of the NodeCollection matches that of the kernel. | |
| virtual bool | operator!= (NodeCollectionPTR) const |
| Check if two NodeCollections are equal. | |
| std::vector< size_t > | to_array (const std::string &selection) const |
| Method that creates a vector filled with node IDs from the NodeCollection; for debugging. | |
| void | get_metadata_status (Dictionary &) const |
| Collect metadata into dictionary. | |
| size_t | get_first () const |
| return the first stored ID (i.e, ID at index zero) inside the NodeCollection | |
| size_t | get_last () const |
| return the last stored ID inside the NodeCollection | |
Private Types | |
| typedef size_t(* | gid_to_phase_fcn_) (size_t) |
| Type for lambda-helper function used by {rank, thread, specific}_local_begin. | |
Private Member Functions | |
| void | merge_parts_ (std::vector< NodeCollectionPrimitive > &parts) const |
| Goes through the vector of primitives, merging as much as possible. | |
| std::pair< size_t, size_t > | specific_local_begin_ (size_t period, size_t phase, size_t start_part, size_t start_offset, gid_to_phase_fcn_ period_first_node) const |
| Abstraction of {rank, thread}_local_begin. | |
| bool | valid_idx_ (const size_t part_idx, const size_t element_idx) const |
| Return true if part_idx/element_idx pair indicates element of collection. | |
| std::pair< size_t, size_t > | find_next_part_ (size_t part_idx, size_t element_idx, size_t n=1) const |
| Find next part and offset in it after moving beyond previous part, based on stride. | |
Static Private Member Functions | |
| static size_t | gid_to_vp_ (size_t gid) |
| helper for thread_local_begin/compsite_update_indices | |
| static size_t | gid_to_rank_ (size_t gid) |
| helper for rank_local_begin/compsite_update_indices | |
Private Attributes | |
| std::vector< NodeCollectionPrimitive > | parts_ |
| Primitives forming composite. | |
| size_t | size_ |
| Total number of node IDs, takes into account slicing. | |
| size_t | stride_ |
| Step length, set when slicing. | |
| size_t | first_part_ |
| Primitive to start at, set when slicing. | |
| size_t | first_elem_ |
| Element to start at, set when slicing. | |
| size_t | last_part_ |
| Last entry of parts_ belonging to sliced NC. | |
| size_t | last_elem_ |
| Last entry of parts_[last_part_] belonging to sliced NC. | |
| bool | is_sliced_ |
| Whether the NodeCollectionComposite is sliced. | |
| std::vector< size_t > | cumul_abs_size_ |
| Cumulative size of parts. | |
| std::vector< size_t > | first_in_part_ |
| Local index to first element in each part when slicing is taken into account, or invalid_index. | |
Friends | |
| class | nc_const_iterator |
Additional Inherited Members | |
Public Types inherited from nest::NodeCollection | |
| using | const_iterator = nc_const_iterator |
Static Public Member Functions inherited from nest::NodeCollection | |
| static NodeCollectionPTR | create (const size_t node_id) |
| Create a NodeCollection from a single node ID. | |
| static NodeCollectionPTR | create (const Node *node) |
| Create a NodeCollection from a single node pointer. | |
| static NodeCollectionPTR | create (const std::vector< size_t > &node_ids) |
| Create a NodeCollection from an array of node IDs. | |
Subclass for the composite NodeCollection type.
The composite type contains a collection of primitives which are not contiguous and homogeneous with each other. If the composite is sliced, it also holds information about what index to start at, one past the index to end at, and the step. The endpoint is one past the last valid node.
first_part_, first_elem_ to the first node belonging to the slicelast_part_, last_elem_ to the last node belongig to the slicefirst_part_ but before last_part_ will always be in the NC in its entirety.
|
private |
Type for lambda-helper function used by {rank, thread, specific}_local_begin.
| nest::NodeCollectionComposite::NodeCollectionComposite | ( | const NodeCollectionPrimitive & | primitive, |
| size_t | start, | ||
| size_t | end, | ||
| size_t | stride | ||
| ) |
Create a composite from a primitive, with boundaries and step length.
Let the slicing be given by b:e:s for brevity. Then the elements of the sliced composite will be given by
b, b + s, ..., b + j s < e <=> b, b + s, ..., b + j s ≤ e - 1 <=> j ≤ floor( ( e - 1 - b ) / s )
Since j = 0 is included in the sequence above, the sliced node collection has 1 + floor( ( e - 1 - b ) / s ) elements. Flooring is implemented via integer division.
| primitive | Primitive to be converted |
| start | Offset in the primitive to begin at. |
| end | Offset in the primitive, one past the node to end at. |
| step | Length to step in the primitive. |
| nest::NodeCollectionComposite::NodeCollectionComposite | ( | const NodeCollectionComposite & | composite, |
| size_t | start, | ||
| size_t | end, | ||
| size_t | stride | ||
| ) |
Creates a new composite from another, with boundaries and step length.
This constructor is used only when slicing.
Since we do not allow slicing of sliced node collections with step > 1, the underlying node collections all have step one and we can calculate the size of the sliced node collection as described in the constructor taking a NodeCollectionPrimitive as argument.
| composite | Composite to slice. |
| start | Index in the composite to begin at. |
| end | Index in the composite one past the node to end at. |
| step | Length to step in the composite. |
References begin(), cumul_abs_size_, end(), first_elem_, first_in_part_, first_part_, nest::nc_const_iterator::get_part_offset(), is_sliced_, last_elem_, last_part_, parts_, size(), size_, and stride_.
|
explicit |
Create a composite from a vector of primitives.
Since primitives by definition contain contiguous elements, the size of the composite collection is the sum of the size of its parts.
| parts | Vector of primitives. |
References cumul_abs_size_, first_in_part_, last_elem_, last_part_, parts_, nest::primitive_sort_op, and size_.
|
default |
Composite copy constructor.
| comp | Composite to be copied. |
|
inlineoverridevirtual |
Method to get an iterator representing the beginning of the NodeCollection.
Implements nest::NodeCollection.
References first_elem_, first_part_, nc_const_iterator, and stride_.
Referenced by NodeCollectionComposite(), operator[](), and print_me().
|
inlineoverridevirtual |
Check if the NodeCollection contains a specified node ID.
| node_id | node ID to see if exists in the NodeCollection |
Implements nest::NodeCollection.
References get_nc_index().
|
inlineoverridevirtual |
Checks if the NodeCollection has no elements.
Implements nest::NodeCollection.
|
inlineoverridevirtual |
Method to get an iterator representing the end of the NodeCollection.
| offset | Index of element NC that iterator points to |
Implements nest::NodeCollection.
References nest::nc_const_iterator::END, last_elem_, last_part_, and nc_const_iterator.
Referenced by NodeCollectionComposite(), nest::nc_const_iterator::operator*(), print_me(), rank_local_begin(), slice(), and thread_local_begin().
|
private |
Find next part and offset in it after moving beyond previous part, based on stride.
| part_idx | Part for current iterator position |
| element_idx | Element for current iterator position |
| n | Number of node collection elements we advance by (ie argument that was passed to to operator+(n)) |
|
inlineoverridevirtual |
Gets the metadata of the NodeCollection.
Implements nest::NodeCollection.
References parts_.
Referenced by operator+(), and operator+().
|
overridevirtual |
Returns index of node with given node ID in NodeCollection.
Index here is into the sliced node collection, so that nc[ nc.get_nc_index( gid )].node_id == gid.
Implements nest::NodeCollection.
References cumul_abs_size_, first_elem_, first_part_, is_sliced_, last_elem_, last_part_, parts_, size(), and stride_.
Referenced by contains().
|
staticprivate |
helper for rank_local_begin/compsite_update_indices
References nest::MPIManager::get_process_id_of_vp(), nest::kernel(), and nest::KernelManager::mpi_manager.
Referenced by nest::nc_const_iterator::advance_local_iter_to_new_part_(), and rank_local_begin().
|
staticprivate |
helper for thread_local_begin/compsite_update_indices
References nest::kernel(), nest::VPManager::node_id_to_vp(), and nest::KernelManager::vp_manager.
Referenced by nest::nc_const_iterator::advance_local_iter_to_new_part_(), and thread_local_begin().
|
overridevirtual |
Returns whether the NodeCollection contains any nodes with proxies or not.
Implements nest::NodeCollection.
References parts_.
|
inlineoverridevirtual |
Implements nest::NodeCollection.
|
private |
Goes through the vector of primitives, merging as much as possible.
| parts | Vector of primitives to be merged. |
Referenced by operator+(), and operator+().
| NodeCollectionPTR nest::NodeCollectionComposite::operator+ | ( | const NodeCollectionPrimitive & | rhs | ) | const |
References nest::NodeCollectionPrimitive::get_metadata(), get_metadata(), merge_parts_(), parts_, and nest::primitive_sort_op.
|
overridevirtual |
Addition operator.
Joins this composite with another NodeCollection. The resulting NodeCollection is sorted and merged, and converted to a primitive if possible.
| rhs | NodeCollection to add to this composite |
Implements nest::NodeCollection.
References get_metadata(), is_sliced_, last_elem_, last_part_, merge_parts_(), parts_, nest::primitive_sort_op, stride_, and nest::NodeCollection::valid().
|
overridevirtual |
Implements nest::NodeCollection.
|
overridevirtual |
Get the node ID in the specified index in the NodeCollection.
| idx | Index in the NodeCollection |
Implements nest::NodeCollection.
References begin(), is_sliced_, and parts_.
|
overridevirtual |
Print out the contents of the NodeCollection in a pretty and informative way.
Implements nest::NodeCollection.
References begin(), end(), nest::Model::get_name(), nest::ModelManager::get_node_model(), is_sliced_, nest::kernel(), nest::NodeIDTriple::model_id, nest::KernelManager::model_manager, nest::NodeIDTriple::node_id, parts_, and stride_.
|
overridevirtual |
Method to get an iterator representing the beginning of the NodeCollection.
Implements nest::NodeCollection.
References end(), first_elem_, first_part_, nest::MPIManager::get_num_processes(), nest::MPIManager::get_rank(), gid_to_rank_(), nest::kernel(), nest::KernelManager::mpi_manager, nc_const_iterator, nest::nc_const_iterator::RANK_LOCAL, specific_local_begin_(), and stride_.
|
inlineoverridevirtual |
Sets the metadata of the NodeCollection.
| meta | A Metadata pointer |
Implements nest::NodeCollection.
References parts_.
|
inlineoverridevirtual |
Returns total number of node IDs in the composite.
Implements nest::NodeCollection.
References size_.
Referenced by get_nc_index(), NodeCollectionComposite(), slice(), and specific_local_begin_().
|
overridevirtual |
Slices the NodeCollection to the boundaries, with an optional step parameter.
Note that the boundaries being specified are inclusive.
| start | Index of the NodeCollection to start at |
| end | One past the index of the NodeCollection to stop at |
| stride | Number of places between node IDs to skip. Defaults to 1 |
Implements nest::NodeCollection.
References end(), FULL_LOGGING_ONLY, nest::kernel(), size(), stride(), and nest::NodeCollection::valid().
|
private |
Abstraction of {rank, thread}_local_begin.
| period | number of ranks or virtual processes |
| phase | calling rank or virtual process |
| start_part | begin seach in this part of the collection |
| start_offset | begin search from this offset in start_part |
| period_first_node | function converting gid to rank or thread |
invalid_index if no solution found References first_in_part_, first_index(), FULL_LOGGING_ONLY, nest::kernel(), last_elem_, last_part_, parts_, size(), and stride_.
Referenced by nest::nc_const_iterator::advance_local_iter_to_new_part_(), rank_local_begin(), and thread_local_begin().
|
inlineoverridevirtual |
Returns the stride between node IDs in the composite.
Implements nest::NodeCollection.
References stride_.
Referenced by slice().
|
overridevirtual |
Return iterator stepping from first node on the thread it is called on over nodes on that thread.
Implements nest::NodeCollection.
References end(), first_elem_, first_part_, nest::VPManager::get_num_virtual_processes(), gid_to_vp_(), nest::kernel(), nc_const_iterator, specific_local_begin_(), stride_, nest::nc_const_iterator::THREAD_LOCAL, nest::VPManager::thread_to_vp(), and nest::KernelManager::vp_manager.
|
inlineprivate |
Return true if part_idx/element_idx pair indicates element of collection.
References last_elem_, and last_part_.
Referenced by nest::nc_const_iterator::advance_global_iter_to_new_part_(), nest::nc_const_iterator::advance_local_iter_to_new_part_(), nest::nc_const_iterator::find_next_within_part_(), and nest::nc_const_iterator::operator*().
|
friend |
Referenced by begin(), end(), rank_local_begin(), and thread_local_begin().
|
private |
Cumulative size of parts.
Referenced by nest::nc_const_iterator::advance_global_iter_to_new_part_(), get_nc_index(), NodeCollectionComposite(), NodeCollectionComposite(), and nest::nc_const_iterator::operator*().
|
private |
Element to start at, set when slicing.
Referenced by begin(), get_nc_index(), NodeCollectionComposite(), rank_local_begin(), and thread_local_begin().
|
private |
Local index to first element in each part when slicing is taken into account, or invalid_index.
Referenced by nest::nc_const_iterator::advance_local_iter_to_new_part_(), NodeCollectionComposite(), NodeCollectionComposite(), and specific_local_begin_().
|
private |
Primitive to start at, set when slicing.
Referenced by begin(), get_nc_index(), NodeCollectionComposite(), rank_local_begin(), and thread_local_begin().
|
private |
Whether the NodeCollectionComposite is sliced.
Referenced by get_nc_index(), NodeCollectionComposite(), operator+(), operator[](), and print_me().
|
private |
Last entry of parts_[last_part_] belonging to sliced NC.
Referenced by nest::nc_const_iterator::advance_global_iter_to_new_part_(), nest::nc_const_iterator::advance_local_iter_to_new_part_(), end(), nest::nc_const_iterator::find_next_within_part_(), get_nc_index(), NodeCollectionComposite(), NodeCollectionComposite(), nest::nc_const_iterator::operator*(), operator+(), specific_local_begin_(), and valid_idx_().
|
private |
Last entry of parts_ belonging to sliced NC.
Referenced by nest::nc_const_iterator::advance_global_iter_to_new_part_(), nest::nc_const_iterator::advance_local_iter_to_new_part_(), end(), nest::nc_const_iterator::find_next_within_part_(), get_nc_index(), NodeCollectionComposite(), NodeCollectionComposite(), nest::nc_const_iterator::operator*(), operator+(), specific_local_begin_(), and valid_idx_().
|
private |
Primitives forming composite.
Referenced by get_metadata(), get_nc_index(), has_proxies(), nest::nc_const_iterator::nc_const_iterator(), NodeCollectionComposite(), NodeCollectionComposite(), nest::nc_const_iterator::operator*(), operator+(), operator+(), operator==(), operator[](), print_me(), set_metadata(), and specific_local_begin_().
|
private |
Total number of node IDs, takes into account slicing.
Referenced by NodeCollectionComposite(), NodeCollectionComposite(), operator==(), and size().
|
private |
Step length, set when slicing.
Referenced by nest::nc_const_iterator::advance_global_iter_to_new_part_(), begin(), get_nc_index(), NodeCollectionComposite(), operator+(), print_me(), rank_local_begin(), specific_local_begin_(), stride(), and thread_local_begin().