Peano 4
Loading...
Searching...
No Matches
peano4::maps::HierarchicalStackMap< T > Class Template Reference

#include <HierarchicalStackMap.h>

Collaboration diagram for peano4::maps::HierarchicalStackMap< T >:

Data Structures

struct  TreeData
 Data of one tree. More...
 

Public Member Functions

 HierarchicalStackMap ()
 
 ~HierarchicalStackMap ()
 
bool empty (int treeId, int stackId) const
 
void clear ()
 
void clear (int spacetree)
 
T * getForPush (int treeId, int stackId)
 Get the stack belonging to a tree.
 
T * getForPush (const StackKey &key)
 
T * getForPop (int treeId, int stackId)
 
T * getForPop (const StackKey &key)
 
std::string toString () const
 
std::set< StackKeygetKeys ()
 This one should be const, but I might need a semaphore, so I have to omit the const qualifier.
 
void garbageCollection (int spacetree)
 
bool holdsStack (int treeId, int stackId) const
 For debugging/assertions.
 
bool holdsStack (const StackKey &key) const
 

Private Member Functions

void createStack (int localTreeNumber, int stackNumber)
 This routine is not thread-safe, i.e.
 

Private Attributes

std::vector< TreeData_data
 A vector of maps.
 

Detailed Description

template<typename T>
class peano4::maps::HierarchicalStackMap< T >

Software architecture

There's one entry per tree. I use the mapping from global to local trees, so I don't have to maintain too many entries for 'just in case'. Each entry has a semaphore of its own. So if we need a lock, we only lock once per tree.

Definition at line 37 of file HierarchicalStackMap.h.

Constructor & Destructor Documentation

◆ HierarchicalStackMap()

template<typename T >
peano4::maps::HierarchicalStackMap< T >::HierarchicalStackMap ( )

Definition at line 227 of file HierarchicalStackMap.h.

◆ ~HierarchicalStackMap()

template<typename T >
peano4::maps::HierarchicalStackMap< T >::~HierarchicalStackMap ( )

Definition at line 217 of file HierarchicalStackMap.h.

Member Function Documentation

◆ clear() [1/2]

template<typename T >
void peano4::maps::HierarchicalStackMap< T >::clear ( )
See also
STDStackMap::clear()

Definition at line 251 of file HierarchicalStackMap.h.

Referenced by peano4.output.Makefile.Makefile::__init__(), and peano4::parallel::SpacetreeSet::shutdown().

Here is the caller graph for this function:

◆ clear() [2/2]

template<typename T >
void peano4::maps::HierarchicalStackMap< T >::clear ( int spacetree)

Definition at line 264 of file HierarchicalStackMap.h.

References peano4::parallel::Node::getInstance(), and peano4::parallel::Node::getLocalTreeId().

Referenced by peano4.output.Makefile.Makefile::__init__().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ createStack()

template<typename T >
void peano4::maps::HierarchicalStackMap< T >::createStack ( int localTreeNumber,
int stackNumber )
private

This routine is not thread-safe, i.e.

if you need it thread-safe then you have to wrap it into a semaphore manually.

Definition at line 117 of file HierarchicalStackMap.h.

References assertion.

◆ empty()

template<typename T >
bool peano4::maps::HierarchicalStackMap< T >::empty ( int treeId,
int stackId ) const

Definition at line 132 of file HierarchicalStackMap.h.

References assertion3, assertion4, peano4::parallel::Node::getInstance(), and peano4::parallel::Node::getLocalTreeId().

Referenced by peano4::parallel::SpacetreeSet::streamDataFromSplittingTreesToNewTrees().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ garbageCollection()

template<typename T >
void peano4::maps::HierarchicalStackMap< T >::garbageCollection ( int spacetree)

◆ getForPop() [1/2]

template<typename T >
T * peano4::maps::HierarchicalStackMap< T >::getForPop ( const StackKey & key)

Definition at line 180 of file HierarchicalStackMap.h.

References assertion3, assertion4, peano4::parallel::Node::getInstance(), and peano4::parallel::Node::getLocalTreeId().

Here is the call graph for this function:

◆ getForPop() [2/2]

template<typename T >
T * peano4::maps::HierarchicalStackMap< T >::getForPop ( int treeId,
int stackId )
See also
getForPush(int,int)

Definition at line 174 of file HierarchicalStackMap.h.

◆ getForPush() [1/2]

template<typename T >
T * peano4::maps::HierarchicalStackMap< T >::getForPush ( const StackKey & key)

◆ getForPush() [2/2]

template<typename T >
T * peano4::maps::HierarchicalStackMap< T >::getForPush ( int treeId,
int stackId )

Get the stack belonging to a tree.

There are two versions of the routine: one is thread-safe, the other one does not employ a dedicated semaphore. The one with a semaphore can lazily create stacks; which is the reason why we need the semaphore: everytime we lazily insert new stacks, we run risk that we break the consistency of the underlying container. Originally, I worked with thread-safe accessors only. This resulted in disappointing timings and notably speedup. With a carelfull distinction, I got down the runtime to two third of the original.

Returns
A stack of type T. Actually, it is a pointer and this routine is a lazy creation, i.e. might create the result upon demand.

Definition at line 142 of file HierarchicalStackMap.h.

Referenced by peano4::parallel::SpacetreeSet::streamDataFromSplittingTreesToNewTrees().

Here is the caller graph for this function:

◆ getKeys()

template<typename T >
std::set< peano4::maps::StackKey > peano4::maps::HierarchicalStackMap< T >::getKeys ( )

This one should be const, but I might need a semaphore, so I have to omit the const qualifier.

Definition at line 205 of file HierarchicalStackMap.h.

References peano4::parallel::Node::getInstance().

Here is the call graph for this function:

◆ holdsStack() [1/2]

template<typename T >
bool peano4::maps::HierarchicalStackMap< T >::holdsStack ( const StackKey & key) const

Definition at line 154 of file HierarchicalStackMap.h.

References assertion3, assertion4, peano4::parallel::Node::getInstance(), and peano4::parallel::Node::getLocalTreeId().

Here is the call graph for this function:

◆ holdsStack() [2/2]

template<typename T >
bool peano4::maps::HierarchicalStackMap< T >::holdsStack ( int treeId,
int stackId ) const

For debugging/assertions.

Definition at line 148 of file HierarchicalStackMap.h.

◆ toString()

template<typename T >
std::string peano4::maps::HierarchicalStackMap< T >::toString ( ) const

Definition at line 191 of file HierarchicalStackMap.h.

Field Documentation

◆ _data


The documentation for this class was generated from the following file: