Commit 8425dfda authored by Pierre Kraemer's avatar Pierre Kraemer

quick traversals

parent c67517a7
...@@ -85,6 +85,12 @@ protected: ...@@ -85,6 +85,12 @@ protected:
*/ */
AttributeMultiVector<unsigned int>* m_embeddings[NB_ORBITS] ; AttributeMultiVector<unsigned int>* m_embeddings[NB_ORBITS] ;
/**
* Direct access to quick traversal attributes
* (initialized by enableQuickTraversal function)
*/
AttributeMultiVector<Dart>* m_quickTraversal[NB_ORBITS] ;
/** /**
* Marks manager * Marks manager
*/ */
...@@ -370,6 +376,22 @@ public: ...@@ -370,6 +376,22 @@ public:
template <unsigned int ORBIT> template <unsigned int ORBIT>
void initCell(unsigned int i) ; void initCell(unsigned int i) ;
/****************************************
* QUICK TRAVERSAL MANAGEMENT *
****************************************/
template <unsigned int ORBIT>
void enableQuickTraversal() ;
template <unsigned int ORBIT>
void updateQuickTraversal() ;
template <unsigned int ORBIT>
AttributeMultiVector<Dart>* getQuickTraversal() ;
template <unsigned int ORBIT>
void disableQuickTraversal() ;
/**************************************** /****************************************
* ATTRIBUTES MANAGEMENT * * ATTRIBUTES MANAGEMENT *
****************************************/ ****************************************/
......
...@@ -352,6 +352,52 @@ inline void GenericMap::initCell(unsigned int i) ...@@ -352,6 +352,52 @@ inline void GenericMap::initCell(unsigned int i)
m_attribs[ORBIT].initLine(i) ; m_attribs[ORBIT].initLine(i) ;
} }
/****************************************
* QUICK TRAVERSAL MANAGEMENT *
****************************************/
template <unsigned int ORBIT>
inline void GenericMap::enableQuickTraversal()
{
if(m_quickTraversal[ORBIT] == NULL)
{
if(!isOrbitEmbedded<ORBIT>())
addEmbedding<ORBIT>() ;
m_quickTraversal[ORBIT] = m_attribs[ORBIT].addAttribute<Dart>("quick_traversal") ;
}
updateQuickTraversal<ORBIT>() ;
}
template <unsigned int ORBIT>
inline void GenericMap::updateQuickTraversal()
{
CellMarker<ORBIT> cm ;
for(Dart d = begin(); d != end(); next(d))
{
if(!cm.isMarked(d))
{
cm.mark(d) ;
(*m_quickTraversal[ORBIT])[d.index] = d ;
}
}
}
template <unsigned int ORBIT>
inline AttributeMultiVector<Dart>* GenericMap::getQuickTraversal()
{
return m_quickTraversal[ORBIT] ;
}
template <unsigned int ORBIT>
inline void GenericMap::disableQuickTraversal()
{
if(m_quickTraversal[ORBIT] != NULL)
{
m_attribs[ORBIT].removeAttribute<Dart>(m_quickTraversal[ORBIT]->getIndex()) ;
m_quickTraversal[ORBIT] = NULL ;
}
}
/**************************************** /****************************************
* ATTRIBUTES MANAGEMENT * * ATTRIBUTES MANAGEMENT *
****************************************/ ****************************************/
......
...@@ -37,8 +37,12 @@ class TraversorCell ...@@ -37,8 +37,12 @@ class TraversorCell
{ {
private: private:
MAP& m ; MAP& m ;
AttributeContainer* cont ;
DartMarker* dmark ; DartMarker* dmark ;
CellMarker<ORBIT>* cmark ; CellMarker<ORBIT>* cmark ;
AttributeMultiVector<Dart>* quickTraversal ;
Dart current ; Dart current ;
bool firstTraversal ; bool firstTraversal ;
const FunctorSelect& m_good ; const FunctorSelect& m_good ;
......
...@@ -29,47 +29,66 @@ template <typename MAP, unsigned int ORBIT> ...@@ -29,47 +29,66 @@ template <typename MAP, unsigned int ORBIT>
TraversorCell<MAP, ORBIT>::TraversorCell(MAP& map, const FunctorSelect& good, bool forceDartMarker, unsigned int thread) : TraversorCell<MAP, ORBIT>::TraversorCell(MAP& map, const FunctorSelect& good, bool forceDartMarker, unsigned int thread) :
m(map), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good) m(map), dmark(NULL), cmark(NULL), current(NIL), firstTraversal(true), m_good(good)
{ {
if(!forceDartMarker && map.template isOrbitEmbedded<ORBIT>()) quickTraversal = map.template getQuickTraversal<ORBIT>() ;
cmark = new CellMarker<ORBIT>(map, thread) ; if(quickTraversal != NULL)
{
cont = &(m.template getAttributeContainer<ORBIT>()) ;
}
else else
dmark = new DartMarker(map, thread) ; {
if(!forceDartMarker && map.template isOrbitEmbedded<ORBIT>())
cmark = new CellMarker<ORBIT>(map, thread) ;
else
dmark = new DartMarker(map, thread) ;
}
} }
template <typename MAP, unsigned int ORBIT> template <typename MAP, unsigned int ORBIT>
TraversorCell<MAP, ORBIT>::~TraversorCell() TraversorCell<MAP, ORBIT>::~TraversorCell()
{ {
if(dmark) if(quickTraversal == NULL)
delete dmark ; {
else if(dmark)
delete cmark ; delete dmark ;
else
delete cmark ;
}
} }
template <typename MAP, unsigned int ORBIT> template <typename MAP, unsigned int ORBIT>
Dart TraversorCell<MAP, ORBIT>::begin() Dart TraversorCell<MAP, ORBIT>::begin()
{ {
if(!firstTraversal) if(quickTraversal != NULL)
{ {
if(dmark) current = (*quickTraversal)[cont->begin()] ;
dmark->unmarkAll() ;
else
cmark->unmarkAll() ;
} }
current = m.begin() ;
while(current != m.end() && (m.isBoundaryMarked(current) || !m_good(current)))
m.next(current) ;
if(current == m.end())
current = NIL ;
else else
{ {
if(dmark) if(!firstTraversal)
dmark->markOrbit<ORBIT>(current) ; {
if(dmark)
dmark->unmarkAll() ;
else
cmark->unmarkAll() ;
}
current = m.begin() ;
while(current != m.end() && (m.isBoundaryMarked(current) || !m_good(current)))
m.next(current) ;
if(current == m.end())
current = NIL ;
else else
cmark->mark(current) ; {
if(dmark)
dmark->markOrbit<ORBIT>(current) ;
else
cmark->mark(current) ;
}
firstTraversal = false ;
} }
firstTraversal = false ;
return current ; return current ;
} }
......
...@@ -73,6 +73,7 @@ GenericMap::GenericMap() : m_nbThreads(1) ...@@ -73,6 +73,7 @@ GenericMap::GenericMap() : m_nbThreads(1)
m_attribs[i].setOrbit(i) ; m_attribs[i].setOrbit(i) ;
m_attribs[i].setRegistry(m_attributes_registry_map) ; m_attribs[i].setRegistry(m_attributes_registry_map) ;
m_embeddings[i] = NULL ; m_embeddings[i] = NULL ;
m_quickTraversal[i] = NULL ;
for(unsigned int j = 0; j < NB_THREAD; ++j) for(unsigned int j = 0; j < NB_THREAD; ++j)
{ {
m_marksets[i][j].clear() ; m_marksets[i][j].clear() ;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment