|
Peano
|
Stack over objects, where some of the properties per object are realised through smart pointers. More...
#include <STDVectorStackOverObjectsWithSmartPointers.h>

Data Structures | |
| class | PopBlockStackView |
| This class represents a whole block of the tree. More... | |
| class | PushBlockStackView |
Public Member Functions | |
| STDVectorStackOverObjectsWithSmartPointers () | |
| STDVectorStackOverObjectsWithSmartPointers (const STDVectorStackOverObjectsWithSmartPointers< T > &) | |
| STDVectorStackOverObjectsWithSmartPointers< T > & | operator= (const STDVectorStackOverObjectsWithSmartPointers< T > &stack) |
| One is allowed to copy a stack but it has to be empty. | |
| void | clone (const STDVectorStackOverObjectsWithSmartPointers< T > &data) |
| Clone data into the current object on which clone() is called. | |
| T | pop () |
| Pops element from a stack. | |
| T & | top (int shift=0) |
| Get top element or shiftth top element. | |
| const T & | top (int shift=0) const |
| Get top element or shiftth top element. | |
| void | push (const T &element) |
| Pushes element to a stack. | |
| PopBlockStackView | popBlock (int numberOfElements) |
| This operation grabs numberOfElements from the input stack en block and returns a view to it. | |
| PushBlockStackView | pushBlock (int numberOfElements) |
| Push a block on the output stack. | |
| int | size () const |
| bool | empty () const |
| void | clear () |
| void | startSend (peano4::grid::TraversalObserver::SendReceiveContext context, int rank, int tag, MPI_Comm comm) |
| Start the actual send process. | |
| void | startReceive (peano4::grid::TraversalObserver::SendReceiveContext context, int rank, int tag, MPI_Comm comm, int numberOfElements) |
| Trigger a receive. | |
| bool | tryToFinishSendOrReceive () |
| Finish a send or receive if it is still pending. | |
| int | sendingOrReceiving () const |
| I need this one to find out whether I'm waiting for data. | |
| void | reverse () |
| Reversing a stream is something I need extremely rarely. | |
| std::string | toString () const |
Private Types | |
| using | FlattenedContainer = std::vector< typename T::FlattenedType > |
Private Attributes | |
| std::vector< T > | _data |
| This is the attribute holding all the temporary stacks. | |
| FlattenedContainer | _flattenedData |
| We cannot send out _data, as each element in _data hosts at least one smart pointer. | |
| IOMode | _ioMode |
| int | _ioRank |
| int | _ioTag |
| MPI_Request * | _ioMPIRequest |
Static Private Attributes | |
| static tarch::logging::Log | _log |
| Logging device. | |
Stack over objects, where some of the properties per object are realised through smart pointers.
This class is similar to the other smart pointer class, but it differs in two ways:
The class can be seen as a plain wrapper around std::vector. Pop and push operations actually make the std::vector increase and decrease.
| T | DaStGen object that hosts a pointer which is backed up by a smart pointer, i.e. deleted as soon as noone needs it anymore. T has to provide a clone() operation but it also has to introduce a flattened variant of its own that we can use for MPI data exchange and copying. |
Definition at line 52 of file STDVectorStackOverObjectsWithSmartPointers.h.
|
private |
Definition at line 64 of file STDVectorStackOverObjectsWithSmartPointers.h.
| peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::STDVectorStackOverObjectsWithSmartPointers | ( | ) |
| peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::STDVectorStackOverObjectsWithSmartPointers | ( | const STDVectorStackOverObjectsWithSmartPointers< T > & | ) |
| void peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::clear | ( | ) |
Referenced by peano4.api.output.Makefile.Makefile::__init__().

| void peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::clone | ( | const STDVectorStackOverObjectsWithSmartPointers< T > & | data | ) |
Clone data into the current object on which clone() is called.
This operation overwrites the baseclass version. If we called the plain base class version, we would end up with a shallow copy. However, we want a semi-shallow copy: We replicate the meta data, and then we call the clone() of the actual vector over pointers. It is up to this routine if we craete a shallow copy or not.
Read the class documentation why I think that the clone() on the subvectors should create a deep copy. It is the section on intra-node parallelisation.
This operation has to use the default constructor of T to resize, as we want the destination data structure to be able to host the target data. So it has to issue all the news if required.
| bool peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::empty | ( | ) | const |
| STDVectorStackOverObjectsWithSmartPointers< T > & peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::operator= | ( | const STDVectorStackOverObjectsWithSmartPointers< T > & | stack | ) |
One is allowed to copy a stack but it has to be empty.
Definition at line 88 of file STDVectorStackOverObjectsWithSmartPointers.h.
References peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::_data, and assertion.
| T peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::pop | ( | ) |
Pops element from a stack.
I have to be careful how and why I use std::move here, as we employ smart pointers. I found that a move after the return confuses the reference counting, and eventually leads to memory leaks.
| PopBlockStackView peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::popBlock | ( | int | numberOfElements | ) |
This operation grabs numberOfElements from the input stack en block and returns a view to it.
Subsequent pops do not affect this block anymore, i.e. the stack is reduced immediately.
| numberOfElements | Size of the view |
| void peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::push | ( | const T & | element | ) |
Pushes element to a stack.
| PushBlockStackView peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::pushBlock | ( | int | numberOfElements | ) |
Push a block on the output stack.
| numberOfElements | Size of the view |
| void peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::reverse | ( | ) |
Reversing a stream is something I need extremely rarely.
The biggest application is the realisation of joins through peano4::parallel::SpacetreeSet::streamLocalVertexInformationToMasterThroughVerticalStacks(). Here, I need a streamed version of the tree to get the up-to-date data of the mesh in. However, I don't have streams. I have only stacks. So I map the stream idea to a stack.
| int peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::sendingOrReceiving | ( | ) | const |
I need this one to find out whether I'm waiting for data.
| int peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::size | ( | ) | const |
Referenced by tarch.plotter.api.input.Patch.Patch::__repr__(), and peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::PopBlockStackView::PopBlockStackView().

| void peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::startReceive | ( | peano4::grid::TraversalObserver::SendReceiveContext | context, |
| int | rank, | ||
| int | tag, | ||
| MPI_Comm | comm, | ||
| int | numberOfElements | ||
| ) |
Trigger a receive.
This is the counterpart of startSend() and hence pretty similar. We clear _data and we resize _flattenedData so that latter can take the incoming data. We know that we need that incoming data eventually within _data, but we are not there yet. After that, we issue a non-blocking receive and return.
See clone() for a description why we have to use resize() with the standard constructor here.
| void peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::startSend | ( | peano4::grid::TraversalObserver::SendReceiveContext | context, |
| int | rank, | ||
| int | tag, | ||
| MPI_Comm | comm | ||
| ) |
Start the actual send process.
Always pairs up with a tryToFinishSendOrReceive() call.
We know that the data are potentially gathered all over the place on the heap subject to a smart pointer. So we first create a complete copy of all data in a container called _flattenedData. These copies are flattened data, i.e. are stored consecutively in memory.
Once we have created this flattened copy, we can delete the original data structure. We won't need it anymore. This is in line with other stacks which clear themselves after they have sent out data. See for example peano4::stacks::STDVectorStackOverSmartPointers<T>::startSend(). This clear() on the original data might not immediately lead to system frees, as other stacks might hold references to the same data on the heap.
The flattened data however has to stay there, as we only trigger a non-blocking send, i.e. the data might not have left the system yet. This flattened data are cleaned up within tryToFinishSendOrReceive().
| T & peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::top | ( | int | shift = 0 | ) |
Get top element or shiftth top element.
We start to count with 0, i.e. a shift of 0 (default) really returns the top element. A shift of 3 returns the fourth element from the stack
| const T & peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::top | ( | int | shift = 0 | ) | const |
Get top element or shiftth top element.
We start to count with 0, i.e. a shift of 0 (default) really returns the top element. A shift of 3 returns the fourth element from the stack
| std::string peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::toString | ( | ) | const |
| bool peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::tryToFinishSendOrReceive | ( | ) |
Finish a send or receive if it is still pending.
If the stack is not in a sending or receiving state, we return immediately. Otherwise, we issue an MPI_Test to see if MPI tells us if it is done. If so, we can trigger the actual clean-up:
|
private |
This is the attribute holding all the temporary stacks.
Definition at line 62 of file STDVectorStackOverObjectsWithSmartPointers.h.
Referenced by peano4.api.datamodel.DaStGen2.DaStGen2Generator::construct_output(), peano4.api.datamodel.DaStGen2.DaStGen2GeneratorForObjectsWithSmartPointers::construct_output(), peano4.api.toolbox.particles.ParticleSet.ParticleSetGenerator_ScatteredOnHeap_IndexByList::construct_output(), peano4.api.toolbox.particles.ParticleSet.ParticleSetGenerator_ScatteredOnHeap_IndexByVector::construct_output(), peano4.api.toolbox.particles.ParticleSet.ParticleSetGenerator_ContinuousPerVertex::construct_output(), peano4.api.toolbox.particles.ParticleSet.ParticleSetGenerator_GlobalContinuous::construct_output(), peano4.api.datamodel.DaStGen2.DaStGen2Generator::get_header_file_include(), peano4.api.datamodel.DaStGen2.DaStGen2GeneratorForObjectsWithSmartPointers::get_header_file_include(), peano4.api.toolbox.particles.ParticleSet.AbstractParticleSetGenerator::get_header_file_include(), peano4.api.datamodel.DaStGen2.DaStGen2Generator::get_stack_container(), peano4.api.datamodel.DaStGen2.DaStGen2GeneratorForObjectsWithSmartPointers::get_stack_container(), peano4.api.datamodel.DynamicArrayOverPrimitivesToStdVector.DynamicArrayOverPrimitivesToStdVector::get_stack_container(), peano4.api.toolbox.particles.ParticleSet.AbstractParticleSetGenerator::get_stack_container(), peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::operator=(), and peano4::stacks::STDVectorStackOverObjectsWithSmartPointers< T >::PopBlockStackView::PopBlockStackView().
|
private |
We cannot send out _data, as each element in _data hosts at least one smart pointer.
Definition at line 70 of file STDVectorStackOverObjectsWithSmartPointers.h.
|
private |
Definition at line 72 of file STDVectorStackOverObjectsWithSmartPointers.h.
|
private |
Definition at line 77 of file STDVectorStackOverObjectsWithSmartPointers.h.
|
private |
Definition at line 73 of file STDVectorStackOverObjectsWithSmartPointers.h.
|
private |
Definition at line 74 of file STDVectorStackOverObjectsWithSmartPointers.h.
|
staticprivate |
Logging device.
Definition at line 57 of file STDVectorStackOverObjectsWithSmartPointers.h.