Commit d478214e authored by Sylvain Thery's avatar Sylvain Thery

profiling

parent 4c22b514
...@@ -150,7 +150,8 @@ IF(WIN32) ...@@ -150,7 +150,8 @@ IF(WIN32)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE) set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE)
# set(CMAKE_CONFIGURATION_TYPES "Release Debug" CACHE STRING "Only Release or Debug" FORCE) # set(CMAKE_CONFIGURATION_TYPES "Release Debug" CACHE STRING "Only Release or Debug" FORCE)
ELSE(WIN32) ELSE(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC -std=c++11") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC -std=c++11 -pg")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Woverride-init -fPIC") SET(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} -Wall -Woverride-init -fPIC")
# remove the 60000+ "no unused local typedefs" warnings with GCC4.8+ # remove the 60000+ "no unused local typedefs" warnings with GCC4.8+
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
......
...@@ -112,7 +112,9 @@ IF(WIN32) ...@@ -112,7 +112,9 @@ IF(WIN32)
set(CMAKE_CONFIGURATION_TYPES Release Debug) set(CMAKE_CONFIGURATION_TYPES Release Debug)
set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE) set(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING "Only Release or Debug" FORCE)
ELSE(WIN32) ELSE(WIN32)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC -std=c++11") SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wextra -fPIC -std=c++11 -pg")
SET(CMAKE_EXE_LINKER_FLAGS "${CMAKE_EXE_LINKER_FLAGS} -pg")
if(CMAKE_COMPILER_IS_GNUCXX) if(CMAKE_COMPILER_IS_GNUCXX)
execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION) execute_process(COMMAND ${CMAKE_C_COMPILER} -dumpversion OUTPUT_VARIABLE GCC_VERSION)
if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8) if (GCC_VERSION VERSION_GREATER 4.8 OR GCC_VERSION VERSION_EQUAL 4.8)
......
...@@ -177,14 +177,7 @@ void foreach_cell(MAP& map, std::vector<FunctorMapThreaded<MAP>*>& funcs, bool n ...@@ -177,14 +177,7 @@ void foreach_cell(MAP& map, std::vector<FunctorMapThreaded<MAP>*>& funcs, bool n
boost::barrier sync1(nbth+1); boost::barrier sync1(nbth+1);
boost::barrier sync2(nbth+1); boost::barrier sync2(nbth+1);
bool finished=false; bool finished=false;
// lauch threads // launch threads
if (needMarkers)
{
unsigned int nbth_prec = map.getNbThreadMarkers();
if (nbth_prec < nbth+1)
map.addThreadMarker(nbth+1-nbth_prec);
}
boost::thread** threads = new boost::thread*[nbth]; boost::thread** threads = new boost::thread*[nbth];
ThreadFunction<MAP>** tfs = new ThreadFunction<MAP>*[nbth]; ThreadFunction<MAP>** tfs = new ThreadFunction<MAP>*[nbth];
......
...@@ -128,7 +128,7 @@ public: ...@@ -128,7 +128,7 @@ public:
virtual unsigned int getNbBlocks() const = 0; virtual unsigned int getNbBlocks() const = 0;
virtual void addBlocksBefore(unsigned int nbb) = 0; // virtual void addBlocksBefore(unsigned int nbb) = 0;
virtual bool copy(const AttributeMultiVectorGen* atmvg) = 0; virtual bool copy(const AttributeMultiVectorGen* atmvg) = 0;
...@@ -311,6 +311,7 @@ public: ...@@ -311,6 +311,7 @@ public:
} // namespace CGoGN } // namespace CGoGN
#include "attributeMultiVectorBool.hpp"
#include "attributeMultiVector.hpp" #include "attributeMultiVector.hpp"
#endif #endif
This diff is collapsed.
...@@ -43,40 +43,26 @@ class CellMarkerGen ...@@ -43,40 +43,26 @@ class CellMarkerGen
friend class GenericMap ; friend class GenericMap ;
protected: protected:
Mark m_mark ; AttributeMultiVector<MarkerBool>* m_markVector ;
AttributeMultiVector<Mark>* m_markVector ;
unsigned int m_thread ;
unsigned int m_cell ; unsigned int m_cell ;
public: public:
CellMarkerGen(unsigned int cell, unsigned int thread = 0) : CellMarkerGen(unsigned int cell, unsigned int thread = 0) :
m_thread(thread),
m_cell(cell) m_cell(cell)
{} {}
virtual ~CellMarkerGen() virtual ~CellMarkerGen()
{} {}
unsigned int getThread() { return m_thread ; }
unsigned int getCell() { return m_cell ; } unsigned int getCell() { return m_cell ; }
void updateMarkVector(AttributeMultiVector<Mark>* amv) { m_markVector = amv ; } void updateMarkVector(AttributeMultiVector<MarkerBool>* amv) { m_markVector = amv ; }
protected: protected:
// protected copy constructor to forbid its usage // protected copy constructor to forbid its usage
CellMarkerGen(const CellMarkerGen& /*cm*/) CellMarkerGen(const CellMarkerGen& /*cm*/)
{} {}
// virtual void mark(Dart d) = 0 ;
// virtual void unmark(Dart d) = 0 ;
// virtual bool isMarked(Dart d) const = 0 ;
// virtual void mark(unsigned int em) = 0 ;
// virtual void unmark(unsigned int em) = 0 ;
// virtual bool isMarked(unsigned int em) const = 0 ;
// virtual void markAll() = 0 ;
// virtual void unmarkAll() = 0 ;
// virtual bool isAllUnmarked() = 0 ;
}; };
/** /**
...@@ -100,8 +86,7 @@ public: ...@@ -100,8 +86,7 @@ public:
{ {
if(!m_map.template isOrbitEmbedded<CELL>()) if(!m_map.template isOrbitEmbedded<CELL>())
m_map.template addEmbedding<CELL>() ; m_map.template addEmbedding<CELL>() ;
m_mark = m_map.template getMarkerSet<CELL>(m_thread).getNewMark() ; m_markVector = m_map.template askMarkVector<CELL>();
m_markVector = m_map.template getMarkVector<CELL>(m_thread) ;
} }
CellMarkerBase(const MAP& map, unsigned int thread = 0) : CellMarkerBase(const MAP& map, unsigned int thread = 0) :
...@@ -110,16 +95,23 @@ public: ...@@ -110,16 +95,23 @@ public:
{ {
if(!m_map.template isOrbitEmbedded<CELL>()) if(!m_map.template isOrbitEmbedded<CELL>())
m_map.template addEmbedding<CELL>() ; m_map.template addEmbedding<CELL>() ;
m_mark = m_map.template getMarkerSet<CELL>(m_thread).getNewMark() ; m_markVector = m_map.template askMarkVector<CELL>();
m_markVector = m_map.template getMarkVector<CELL>(m_thread) ;
} }
virtual ~CellMarkerBase() virtual ~CellMarkerBase()
{ {
if (GenericMap::alive(&m_map)) if (GenericMap::alive(&m_map))
m_map.template getMarkerSet<CELL>(m_thread).releaseMark(m_mark) ; m_map.template releaseMarkVector<CELL>(m_markVector);
} }
void update()
{
if(!m_map.template isOrbitEmbedded<CELL>())
m_map.template addEmbedding<CELL>() ;
m_markVector = m_map.template askMarkVector<CELL>();
}
protected: protected:
// protected copy constructor to forbid its usage // protected copy constructor to forbid its usage
CellMarkerBase(const CellMarkerBase<MAP, CELL>& cm) : CellMarkerBase(const CellMarkerBase<MAP, CELL>& cm) :
...@@ -133,7 +125,6 @@ public: ...@@ -133,7 +125,6 @@ public:
*/ */
inline void mark(Cell<CELL> c) inline void mark(Cell<CELL> c)
{ {
assert(m_map.template getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL); assert(m_markVector != NULL);
unsigned int a = m_map.getEmbedding(c) ; unsigned int a = m_map.getEmbedding(c) ;
...@@ -141,7 +132,7 @@ public: ...@@ -141,7 +132,7 @@ public:
if (a == EMBNULL) if (a == EMBNULL)
a = Algo::Topo::setOrbitEmbeddingOnNewCell(m_map, c) ; a = Algo::Topo::setOrbitEmbeddingOnNewCell(m_map, c) ;
(*m_markVector)[a].setMark(m_mark) ; m_markVector->setTrue(a);
} }
/** /**
...@@ -149,7 +140,6 @@ public: ...@@ -149,7 +140,6 @@ public:
*/ */
inline void unmark(Cell<CELL> c) inline void unmark(Cell<CELL> c)
{ {
assert(m_map.template getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL); assert(m_markVector != NULL);
unsigned int a = m_map.getEmbedding(c) ; unsigned int a = m_map.getEmbedding(c) ;
...@@ -157,7 +147,7 @@ public: ...@@ -157,7 +147,7 @@ public:
if (a == EMBNULL) if (a == EMBNULL)
a = Algo::Topo::setOrbitEmbeddingOnNewCell(m_map, c) ; a = Algo::Topo::setOrbitEmbeddingOnNewCell(m_map, c) ;
(*m_markVector)[a].unsetMark(m_mark) ; m_markVector->setFalse(a);
} }
/** /**
...@@ -165,7 +155,6 @@ public: ...@@ -165,7 +155,6 @@ public:
*/ */
inline bool isMarked(Cell<CELL> c) const inline bool isMarked(Cell<CELL> c) const
{ {
assert(m_map.template getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL); assert(m_markVector != NULL);
unsigned int a = m_map.getEmbedding(c) ; unsigned int a = m_map.getEmbedding(c) ;
...@@ -173,7 +162,7 @@ public: ...@@ -173,7 +162,7 @@ public:
if (a == EMBNULL) if (a == EMBNULL)
return false ; return false ;
return (*m_markVector)[a].testMark(m_mark) ; return m_markVector->operator[](a);
} }
/** /**
...@@ -181,10 +170,8 @@ public: ...@@ -181,10 +170,8 @@ public:
*/ */
inline void mark(unsigned int em) inline void mark(unsigned int em)
{ {
assert(m_map.template getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL); assert(m_markVector != NULL);
m_markVector->setTrue(em);
(*m_markVector)[em].setMark(m_mark) ;
} }
/** /**
...@@ -192,10 +179,8 @@ public: ...@@ -192,10 +179,8 @@ public:
*/ */
inline void unmark(unsigned int em) inline void unmark(unsigned int em)
{ {
assert(m_map.template getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL); assert(m_markVector != NULL);
m_markVector->setFalse(em);
(*m_markVector)[em].unsetMark(m_mark) ;
} }
/** /**
...@@ -203,12 +188,11 @@ public: ...@@ -203,12 +188,11 @@ public:
*/ */
inline bool isMarked(unsigned int em) const inline bool isMarked(unsigned int em) const
{ {
assert(m_map.template getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL); assert(m_markVector != NULL);
if (em == EMBNULL) if (em == EMBNULL)
return false ; return false ;
return (*m_markVector)[em].testMark(m_mark) ; return m_markVector->operator[](em);
} }
/** /**
...@@ -216,22 +200,17 @@ public: ...@@ -216,22 +200,17 @@ public:
*/ */
inline void markAll() inline void markAll()
{ {
assert(m_map.template getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL); assert(m_markVector != NULL);
m_markVector->allFalse();
AttributeContainer& cont = m_map.template getAttributeContainer<CELL>() ;
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
(*m_markVector)[i].setMark(m_mark) ;
} }
inline bool isAllUnmarked() inline bool isAllUnmarked()
{ {
assert(m_map.template getMarkerSet<CELL>(m_thread).testMark(m_mark));
assert(m_markVector != NULL); assert(m_markVector != NULL);
AttributeContainer& cont = m_map.template getAttributeContainer<CELL>() ; AttributeContainer& cont = m_map.template getAttributeContainer<CELL>() ;
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i)) for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
if((*m_markVector)[i].testMark(m_mark)) if(m_markVector->operator[](i))
return false ; return false ;
return true ; return true ;
} }
...@@ -265,12 +244,8 @@ protected: ...@@ -265,12 +244,8 @@ protected:
public: public:
inline void unmarkAll() inline void unmarkAll()
{ {
assert(this->m_map.template getMarkerSet<CELL>(this->m_thread).testMark(this->m_mark));
assert(this->m_markVector != NULL); assert(this->m_markVector != NULL);
this->m_markVector->allFalse();
AttributeContainer& cont = this->m_map.template getAttributeContainer<CELL>() ;
for (unsigned int i = cont.realBegin(); i != cont.realEnd(); cont.realNext(i))
this->m_markVector->operator[](i).unsetMark(this->m_mark) ;
} }
}; };
...@@ -325,11 +300,10 @@ public: ...@@ -325,11 +300,10 @@ public:
inline void unmarkAll() inline void unmarkAll()
{ {
assert(this->m_map.template getMarkerSet<CELL>(this->m_thread).testMark(this->m_mark));
assert(this->m_markVector != NULL); assert(this->m_markVector != NULL);
for (std::vector<unsigned int>::iterator it = m_markedCells.begin(); it != m_markedCells.end(); ++it) for (std::vector<unsigned int>::iterator it = m_markedCells.begin(); it != m_markedCells.end(); ++it)
this->m_markVector->operator[](*it).unsetMark(this->m_mark) ; this->m_markVector->setFalse(*it);
} }
}; };
...@@ -381,7 +355,6 @@ public: ...@@ -381,7 +355,6 @@ public:
inline void unmarkAll() inline void unmarkAll()
{ {
assert(this->m_map.template getMarkerSet<CELL>(this->m_thread).testMark(this->m_mark));
assert(this->m_markVector != NULL); assert(this->m_markVector != NULL);
for (std::vector<Dart>::iterator it = m_markedDarts.begin(); it != m_markedDarts.end(); ++it) for (std::vector<Dart>::iterator it = m_markedDarts.begin(); it != m_markedDarts.end(); ++it)
{ {
...@@ -428,12 +401,8 @@ protected: ...@@ -428,12 +401,8 @@ protected:
public: public:
inline void unmarkAll() inline void unmarkAll()
{ {
assert(this->m_map.template getMarkerSet<CELL>(this->m_thread).testMark(this->m_mark));
assert(this->m_markVector != NULL); assert(this->m_markVector != NULL);
this->m_markVector->allFalse();
AttributeContainer& cont = this->m_map.template getAttributeContainer<CELL>() ;
for (unsigned int i = cont.realBegin(); i != cont.realEnd(); cont.realNext(i))
this->m_markVector->operator[](i).unsetMark(this->m_mark) ;
} }
}; };
......
...@@ -43,25 +43,18 @@ class DartMarkerGen ...@@ -43,25 +43,18 @@ class DartMarkerGen
friend class GenericMap ; friend class GenericMap ;
protected: protected:
Mark m_mark ; AttributeMultiVector<MarkerBool>* m_markVector;
AttributeMultiVector<Mark>* m_markVector ;
unsigned int m_thread ;
public: public:
/** /**
* constructor * constructor
*/ */
DartMarkerGen(unsigned int thread = 0) : DartMarkerGen(unsigned int thread=0)
m_thread(thread)
{} {}
virtual ~DartMarkerGen() virtual ~DartMarkerGen()
{} {}
inline unsigned int getThread() { return m_thread ; }
inline void updateMarkVector(AttributeMultiVector<Mark>* amv) { m_markVector = amv ; }
protected: protected:
// protected copy constructor to forbid its usage // protected copy constructor to forbid its usage
DartMarkerGen(const DartMarkerGen& /*dm*/) DartMarkerGen(const DartMarkerGen& /*dm*/)
...@@ -84,25 +77,29 @@ public: ...@@ -84,25 +77,29 @@ public:
DartMarkerGen(thread), DartMarkerGen(thread),
m_map(map) m_map(map)
{ {
m_mark = m_map.template getMarkerSet<DART>(m_thread).getNewMark() ; m_markVector = m_map.template askMarkVector<DART>();
m_markVector = m_map.template getMarkVector<DART>(m_thread) ;
} }
DartMarkerTmpl(const MAP& map, unsigned int thread = 0) : DartMarkerTmpl(const MAP& map, unsigned int thread = 0) :
DartMarkerGen(thread), DartMarkerGen(thread),
m_map(const_cast<MAP&>(map)) m_map(const_cast<MAP&>(map))
{ {
m_mark = m_map.template getMarkerSet<DART>(m_thread).getNewMark() ; m_markVector = m_map.template askMarkVector<DART>();
m_markVector = m_map.template getMarkVector<DART>(m_thread) ;
} }
virtual ~DartMarkerTmpl() virtual ~DartMarkerTmpl()
{ {
if (GenericMap::alive(&m_map)) if (GenericMap::alive(&m_map))
m_map.template getMarkerSet<DART>(m_thread).releaseMark(m_mark) ; m_map.template releaseMarkVector<DART>(m_markVector);
}
inline void update()
{
m_markVector = m_map.template askMarkVector<DART>();
} }
protected: protected:
// protected copy constructor to forbid its usage // protected copy constructor to forbid its usage
DartMarkerTmpl(const DartMarkerTmpl<MAP>& dm) : DartMarkerTmpl(const DartMarkerTmpl<MAP>& dm) :
...@@ -115,9 +112,9 @@ public: ...@@ -115,9 +112,9 @@ public:
*/ */
inline void mark(Dart d) inline void mark(Dart d)
{ {
assert(m_map.template getMarkerSet<DART>(m_thread).testMark(m_mark)); assert(m_markVector != NULL);
unsigned int d_index = m_map.dartIndex(d) ; unsigned int d_index = m_map.dartIndex(d) ;
(*m_markVector)[d_index].setMark(m_mark) ; m_markVector->setTrue(d_index);
} }
/** /**
...@@ -125,9 +122,9 @@ public: ...@@ -125,9 +122,9 @@ public:
*/ */
inline void unmark(Dart d) inline void unmark(Dart d)
{ {
assert(m_map.template getMarkerSet<DART>(m_thread).testMark(m_mark)); assert(m_markVector != NULL);
unsigned int d_index = m_map.dartIndex(d) ; unsigned int d_index = m_map.dartIndex(d) ;
(*m_markVector)[d_index].unsetMark(m_mark) ; m_markVector->setFalse(d_index);
} }
/** /**
...@@ -135,9 +132,9 @@ public: ...@@ -135,9 +132,9 @@ public:
*/ */
inline bool isMarked(Dart d) const inline bool isMarked(Dart d) const
{ {
assert(m_map.template getMarkerSet<DART>(m_thread).testMark(m_mark)); assert(m_markVector != NULL);
unsigned int d_index = m_map.dartIndex(d) ; unsigned int d_index = m_map.dartIndex(d) ;
return (*m_markVector)[d_index].testMark(m_mark) ; return (*m_markVector)[d_index];
} }
/** /**
...@@ -146,12 +143,11 @@ public: ...@@ -146,12 +143,11 @@ public:
template <unsigned int ORBIT> template <unsigned int ORBIT>
inline void markOrbit(Cell<ORBIT> c) inline void markOrbit(Cell<ORBIT> c)
{ {
assert(m_map.template getMarkerSet<DART>(m_thread).testMark(m_mark)); assert(m_markVector != NULL);
m_map.foreach_dart_of_orbit(c, [&] (Dart d) m_map.foreach_dart_of_orbit(c, [&] (Dart d)
{ {
(*m_markVector)[m_map.dartIndex(d)].setMark(m_mark); m_markVector->setTrue(m_map.dartIndex(d));
} }) ;
, m_thread) ;
} }
/** /**
...@@ -160,12 +156,12 @@ public: ...@@ -160,12 +156,12 @@ public:
template <unsigned int ORBIT> template <unsigned int ORBIT>
inline void unmarkOrbit(Cell<ORBIT> c) inline void unmarkOrbit(Cell<ORBIT> c)
{ {
assert(m_map.template getMarkerSet<DART>(m_thread).testMark(m_mark)); assert(m_markVector != NULL);
m_map.foreach_dart_of_orbit(c, [&] (Dart d) m_map.foreach_dart_of_orbit(c, [&] (Dart d)
{ {
(*m_markVector)[m_map.dartIndex(d)].unsetMark(m_mark); m_markVector->setFalse(m_map.dartIndex(d));
} }) ;
, m_thread) ;
} }
/** /**
...@@ -173,10 +169,10 @@ public: ...@@ -173,10 +169,10 @@ public:
*/ */
inline void markAll() inline void markAll()
{ {
assert(m_map.template getMarkerSet<DART>(m_thread).testMark(m_mark)); assert(m_markVector != NULL);
AttributeContainer& cont = m_map.template getAttributeContainer<DART>() ; AttributeContainer& cont = m_map.template getAttributeContainer<DART>() ;
for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i)) for (unsigned int i = cont.begin(); i != cont.end(); cont.next(i))
(*m_markVector)[i