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

quick traversals

parent c67517a7
......@@ -85,6 +85,12 @@ protected:
*/
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
*/
......@@ -370,6 +376,22 @@ public:
template <unsigned int ORBIT>
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 *
****************************************/
......
......@@ -352,6 +352,52 @@ inline void GenericMap::initCell(unsigned int 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 *
****************************************/
......
......@@ -37,8 +37,12 @@ class TraversorCell
{
private:
MAP& m ;
AttributeContainer* cont ;
DartMarker* dmark ;
CellMarker<ORBIT>* cmark ;
AttributeMultiVector<Dart>* quickTraversal ;
Dart current ;
bool firstTraversal ;
const FunctorSelect& m_good ;
......
......@@ -29,47 +29,66 @@ template <typename MAP, unsigned int ORBIT>
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)
{
if(!forceDartMarker && map.template isOrbitEmbedded<ORBIT>())
cmark = new CellMarker<ORBIT>(map, thread) ;
quickTraversal = map.template getQuickTraversal<ORBIT>() ;
if(quickTraversal != NULL)
{
cont = &(m.template getAttributeContainer<ORBIT>()) ;
}
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>
TraversorCell<MAP, ORBIT>::~TraversorCell()
{
if(dmark)
delete dmark ;
else
delete cmark ;
if(quickTraversal == NULL)
{
if(dmark)
delete dmark ;
else
delete cmark ;
}
}
template <typename MAP, unsigned int ORBIT>
Dart TraversorCell<MAP, ORBIT>::begin()
{
if(!firstTraversal)
if(quickTraversal != NULL)
{
if(dmark)
dmark->unmarkAll() ;
else
cmark->unmarkAll() ;
current = (*quickTraversal)[cont->begin()] ;
}
current = m.begin() ;
while(current != m.end() && (m.isBoundaryMarked(current) || !m_good(current)))
m.next(current) ;
if(current == m.end())
current = NIL ;
else
{
if(dmark)
dmark->markOrbit<ORBIT>(current) ;
if(!firstTraversal)
{
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
cmark->mark(current) ;
{
if(dmark)
dmark->markOrbit<ORBIT>(current) ;
else
cmark->mark(current) ;
}
firstTraversal = false ;
}
firstTraversal = false ;
return current ;
}
......
......@@ -73,6 +73,7 @@ GenericMap::GenericMap() : m_nbThreads(1)
m_attribs[i].setOrbit(i) ;
m_attribs[i].setRegistry(m_attributes_registry_map) ;
m_embeddings[i] = NULL ;
m_quickTraversal[i] = NULL ;
for(unsigned int j = 0; j < NB_THREAD; ++j)
{
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