Commit 14c3f576 authored by Sylvain Thery's avatar Sylvain Thery
Browse files

remove needMarker parameter

parent 1e679811
...@@ -459,45 +459,41 @@ void Viewer::cb_keyPress(int keycode) ...@@ -459,45 +459,41 @@ void Viewer::cb_keyPress(int keycode)
Utils::Chrono ch; Utils::Chrono ch;
ch.start(); ch.start();
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
CGoGN::Parallel::NumberOfThreads = 1; CGoGN::Parallel::NumberOfThreads = 1;
for (unsigned int i=0; i<4; ++i) for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ; Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices1 "<< ch.elapsed()<< " ms "<< std::endl; std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices1 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start(); // ch.start();
// CGoGN::Parallel::NumberOfThreads = 2;
// for (unsigned int i=0; i<4; ++i)
// Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
// std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices2 "<< ch.elapsed()<< " ms "<< std::endl;
CGoGN::Parallel::NumberOfThreads = 2; // ch.start();
for (unsigned int i=0; i<4; ++i) // CGoGN::Parallel::NumberOfThreads = 3;
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ; // for (unsigned int i=0; i<4; ++i)
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices2 "<< ch.elapsed()<< " ms "<< std::endl; // Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
// std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices3 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start(); ch.start();
CGoGN::Parallel::NumberOfThreads = 3;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices3 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start();
CGoGN::Parallel::NumberOfThreads = 4; CGoGN::Parallel::NumberOfThreads = 4;
for (unsigned int i=0; i<4; ++i) for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ; Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices4 "<< ch.elapsed()<< " ms "<< std::endl; std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices4 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start(); // ch.start();
// CGoGN::Parallel::NumberOfThreads = 8;
// for (unsigned int i=0; i<4; ++i)
// Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
// std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices8 "<< ch.elapsed()<< " ms "<< std::endl;
CGoGN::Parallel::NumberOfThreads = 8; ch.start();
CGoGN::Parallel::NumberOfThreads = 1;
for (unsigned int i=0; i<4; ++i) for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ; Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices8 "<< ch.elapsed()<< " ms "<< std::endl; std::cout << "Algo::Surface::Geometry::Parallel::computeNormalVertices1 "<< ch.elapsed()<< " ms "<< std::endl;
ch.start(); ch.start();
...@@ -505,7 +501,7 @@ void Viewer::cb_keyPress(int keycode) ...@@ -505,7 +501,7 @@ void Viewer::cb_keyPress(int keycode)
Parallel::foreach_cell<VERTEX>(myMap, [&] (Vertex v, unsigned int th) Parallel::foreach_cell<VERTEX>(myMap, [&] (Vertex v, unsigned int th)
{ {
normal[v] = Algo::Surface::Geometry::vertexNormal<PFP>(myMap,v,position); normal[v] = Algo::Surface::Geometry::vertexNormal<PFP>(myMap,v,position);
}, false, FORCE_CELL_MARKING); }, FORCE_CELL_MARKING);
std::cout << "Parallel::foreach_cell "<< ch.elapsed()<< " ms "<< std::endl; std::cout << "Parallel::foreach_cell "<< ch.elapsed()<< " ms "<< std::endl;
......
...@@ -108,7 +108,7 @@ int main() ...@@ -108,7 +108,7 @@ int main()
{ {
position[v] += VEC3(0.0, 0.0, PFP::REAL(thread) * 0.1f); position[v] += VEC3(0.0, 0.0, PFP::REAL(thread) * 0.1f);
// WARNING thread vary here from 1 to 4 (and not from 0 to 3) !!!! // WARNING thread vary here from 1 to 4 (and not from 0 to 3) !!!!
}, false); // 4:4 thread, false for no need for markers in threaded code. }); // 4:4 thread, false for no need for markers in threaded code.
std::cout << "After // processing"<< std::endl; std::cout << "After // processing"<< std::endl;
foreach_cell<VERTEX>(myMap, [&] (Vertex v) // for each Vertex v of the MAP myMap foreach_cell<VERTEX>(myMap, [&] (Vertex v) // for each Vertex v of the MAP myMap
...@@ -132,7 +132,7 @@ int main() ...@@ -132,7 +132,7 @@ int main()
{ {
// for each face add surface to accumulator (-1 because counter between 1-3 not 0-3) // for each face add surface to accumulator (-1 because counter between 1-3 not 0-3)
surf[thr-1] += Algo::Surface::Geometry::convexFaceArea<PFP>(myMap, f, position); surf[thr-1] += Algo::Surface::Geometry::convexFaceArea<PFP>(myMap, f, position);
}, false); });
std::cout << surf[0]<< "/"<< surf[1]<< "/"<< surf[2]<< "/"<< std::endl; std::cout << surf[0]<< "/"<< surf[1]<< "/"<< surf[2]<< "/"<< std::endl;
std::cout << "Total="<<surf[0]+surf[1]+surf[2]<< std::endl; std::cout << "Total="<<surf[0]+surf[1]+surf[2]<< std::endl;
......
...@@ -236,7 +236,7 @@ void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP ...@@ -236,7 +236,7 @@ void computeAreaFaces(typename PFP::MAP& map, const VertexAttribute<typename PFP
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr) CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{ {
area[f] = convexFaceArea<PFP>(map, f, position) ; area[f] = convexFaceArea<PFP>(map, f, position) ;
},false,AUTO); });
} }
...@@ -246,7 +246,7 @@ void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty ...@@ -246,7 +246,7 @@ void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr) CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{ {
area[v] = vertexOneRingArea<PFP>(map, v, position) ; area[v] = vertexOneRingArea<PFP>(map, v, position) ;
},false,FORCE_CELL_MARKING); },FORCE_CELL_MARKING);
} }
template <typename PFP> template <typename PFP>
...@@ -256,7 +256,7 @@ void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribut ...@@ -256,7 +256,7 @@ void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribut
{ {
vertex_area[v] = vertexBarycentricArea<PFP>(map, v, position) ; vertex_area[v] = vertexBarycentricArea<PFP>(map, v, position) ;
} }
,false,FORCE_CELL_MARKING); ,FORCE_CELL_MARKING);
} }
template <typename PFP> template <typename PFP>
...@@ -265,7 +265,7 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty ...@@ -265,7 +265,7 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr) CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{ {
area[v] = vertexVoronoiArea<PFP>(map, v, position) ; area[v] = vertexVoronoiArea<PFP>(map, v, position) ;
},false,FORCE_CELL_MARKING); },FORCE_CELL_MARKING);
} }
} // namespace Parallel } // namespace Parallel
......
...@@ -187,7 +187,7 @@ void computeCentroidFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& ...@@ -187,7 +187,7 @@ void computeCentroidFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT&
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr) CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{ {
face_centroid[f] = faceCentroid<PFP>(map, f, position) ; face_centroid[f] = faceCentroid<PFP>(map, f, position) ;
},false,AUTO); });
} }
template <typename PFP, typename V_ATT, typename F_ATT> template <typename PFP, typename V_ATT, typename F_ATT>
...@@ -196,7 +196,7 @@ void computeCentroidELWFaces(typename PFP::MAP& map, const V_ATT& position, F_AT ...@@ -196,7 +196,7 @@ void computeCentroidELWFaces(typename PFP::MAP& map, const V_ATT& position, F_AT
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr) CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{ {
face_centroid[f] = faceCentroidELW<PFP>(map, f, position) ; face_centroid[f] = faceCentroidELW<PFP>(map, f, position) ;
},false,AUTO); });
} }
...@@ -207,7 +207,7 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map, ...@@ -207,7 +207,7 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr) CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{ {
vertex_centroid[v] = vertexNeighborhoodCentroid<PFP>(map, v, position) ; vertex_centroid[v] = vertexNeighborhoodCentroid<PFP>(map, v, position) ;
},false,FORCE_CELL_MARKING); },FORCE_CELL_MARKING);
} }
} // namespace Parallel } // namespace Parallel
...@@ -297,7 +297,7 @@ void computeCentroidVolumes(typename PFP::MAP& map, const V_ATT& position, W_ATT ...@@ -297,7 +297,7 @@ void computeCentroidVolumes(typename PFP::MAP& map, const V_ATT& position, W_ATT
CGoGN::Parallel::foreach_cell<VOLUME>(map,[&](Vol v, unsigned int thr) CGoGN::Parallel::foreach_cell<VOLUME>(map,[&](Vol v, unsigned int thr)
{ {
vol_centroid[v] = Surface::Geometry::volumeCentroid<PFP,V_ATT>(map, v, position, thr) ; vol_centroid[v] = Surface::Geometry::volumeCentroid<PFP,V_ATT>(map, v, position, thr) ;
},true,AUTO); });
} }
template <typename PFP, typename V_ATT, typename W_ATT> template <typename PFP, typename V_ATT, typename W_ATT>
...@@ -306,7 +306,7 @@ void computeCentroidELWVolumes(typename PFP::MAP& map, const V_ATT& position, W_ ...@@ -306,7 +306,7 @@ void computeCentroidELWVolumes(typename PFP::MAP& map, const V_ATT& position, W_
CGoGN::Parallel::foreach_cell<VOLUME>(map,[&](Vol v, unsigned int thr) CGoGN::Parallel::foreach_cell<VOLUME>(map,[&](Vol v, unsigned int thr)
{ {
vol_centroid[v] = Surface::Geometry::volumeCentroidELW<PFP,V_ATT>(map, v, position, thr) ; vol_centroid[v] = Surface::Geometry::volumeCentroidELW<PFP,V_ATT>(map, v, position, thr) ;
},true,AUTO); });
} }
......
...@@ -667,7 +667,7 @@ void computeCurvatureVertices_NormalCycles( ...@@ -667,7 +667,7 @@ void computeCurvatureVertices_NormalCycles(
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int threadID) CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int threadID)
{ {
computeCurvatureVertex_NormalCycles<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal, threadID) ; computeCurvatureVertex_NormalCycles<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal, threadID) ;
},true,FORCE_CELL_MARKING); },FORCE_CELL_MARKING);
} }
template <typename PFP> template <typename PFP>
...@@ -696,7 +696,7 @@ void computeCurvatureVertices_NormalCycles_Projected( ...@@ -696,7 +696,7 @@ void computeCurvatureVertices_NormalCycles_Projected(
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int threadID) CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int threadID)
{ {
computeCurvatureVertex_NormalCycles_Projected<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal, threadID) ; computeCurvatureVertex_NormalCycles_Projected<PFP>(map, v, radius, position, normal, edgeangle, kmax, kmin, Kmax, Kmin, Knormal, threadID) ;
},true,FORCE_CELL_MARKING); },FORCE_CELL_MARKING);
} }
...@@ -714,7 +714,7 @@ void computeCurvatureVertices_QuadraticFitting( ...@@ -714,7 +714,7 @@ void computeCurvatureVertices_QuadraticFitting(
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int threadID) CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int threadID)
{ {
computeCurvatureVertex_QuadraticFitting<PFP>(map, v, position, normal, kmax, kmin, Kmax, Kmin, threadID) ; computeCurvatureVertex_QuadraticFitting<PFP>(map, v, position, normal, kmax, kmin, Kmax, Kmin, threadID) ;
},true,FORCE_CELL_MARKING); },FORCE_CELL_MARKING);
} }
......
...@@ -235,7 +235,7 @@ void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT& ...@@ -235,7 +235,7 @@ void computeNormalVertices(typename PFP::MAP& map, const V_ATT& position, V_ATT&
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int /*thr*/) CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int /*thr*/)
{ {
normal[v] = vertexNormal<PFP>(map, v, position) ; normal[v] = vertexNormal<PFP>(map, v, position) ;
},true,FORCE_CELL_MARKING); },FORCE_CELL_MARKING);
} }
template <typename PFP, typename V_ATT, typename F_ATT> template <typename PFP, typename V_ATT, typename F_ATT>
...@@ -244,7 +244,7 @@ void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& no ...@@ -244,7 +244,7 @@ void computeNormalFaces(typename PFP::MAP& map, const V_ATT& position, F_ATT& no
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr) CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{ {
normal[f] = faceNormal<PFP>(map, f, position) ; normal[f] = faceNormal<PFP>(map, f, position) ;
},true,AUTO); });
} }
...@@ -254,7 +254,7 @@ void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& pos ...@@ -254,7 +254,7 @@ void computeAnglesBetweenNormalsOnEdges(typename PFP::MAP& map, const V_ATT& pos
CGoGN::Parallel::foreach_cell<EDGE>(map,[&](Edge e, unsigned int thr) CGoGN::Parallel::foreach_cell<EDGE>(map,[&](Edge e, unsigned int thr)
{ {
angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ; angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ;
},true,AUTO); });
} }
} // namespace Parallel } // namespace Parallel
......
...@@ -332,7 +332,7 @@ void foreach_attribute(ATTR& attribute, FUNC func, unsigned int nbthread) ...@@ -332,7 +332,7 @@ void foreach_attribute(ATTR& attribute, FUNC func, unsigned int nbthread)
for (unsigned int i = 0; i < nbth; ++i) for (unsigned int i = 0; i < nbth; ++i)
{ {
tfs[i] = new ThreadFunctionAttrib<FUNC>(func, vd[i], sync1,sync2,finished,1+i); tfs[i] = new ThreadFunctionAttrib<FUNC>(func, vd[i], sync1,sync2,finished,i);
threads[i] = new boost::thread( boost::ref( *(tfs[i]) ) ); threads[i] = new boost::thread( boost::ref( *(tfs[i]) ) );
} }
......
...@@ -45,10 +45,11 @@ class CellMarkerGen ...@@ -45,10 +45,11 @@ class CellMarkerGen
protected: protected:
AttributeMultiVector<MarkerBool>* m_markVector ; AttributeMultiVector<MarkerBool>* m_markVector ;
unsigned int m_cell ; unsigned int m_cell ;
unsigned int m_thread;
public: public:
CellMarkerGen(unsigned int cell, unsigned int thread = 0) : CellMarkerGen(unsigned int cell, unsigned int thread = 0) :
m_cell(cell) m_cell(cell),m_thread(thread)
{} {}
virtual ~CellMarkerGen() virtual ~CellMarkerGen()
...@@ -86,7 +87,7 @@ public: ...@@ -86,7 +87,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_markVector = m_map.template askMarkVector<CELL>(); m_markVector = m_map.template askMarkVector<CELL>(m_thread);
} }
CellMarkerBase(const MAP& map, unsigned int thread = 0) : CellMarkerBase(const MAP& map, unsigned int thread = 0) :
...@@ -95,20 +96,20 @@ public: ...@@ -95,20 +96,20 @@ public:
{ {
if(!m_map.template isOrbitEmbedded<CELL>()) if(!m_map.template isOrbitEmbedded<CELL>())
m_map.template addEmbedding<CELL>() ; m_map.template addEmbedding<CELL>() ;
m_markVector = m_map.template askMarkVector<CELL>(); m_markVector = m_map.template askMarkVector<CELL>(m_thread);
} }
virtual ~CellMarkerBase() virtual ~CellMarkerBase()
{ {
if (GenericMap::alive(&m_map)) if (GenericMap::alive(&m_map))
m_map.template releaseMarkVector<CELL>(m_markVector); m_map.template releaseMarkVector<CELL>(m_markVector,m_thread);
} }
void update() void update()
{ {
if(!m_map.template isOrbitEmbedded<CELL>()) if(!m_map.template isOrbitEmbedded<CELL>())
m_map.template addEmbedding<CELL>() ; m_map.template addEmbedding<CELL>() ;
m_markVector = m_map.template askMarkVector<CELL>(); m_markVector = m_map.template askMarkVector<CELL>(m_thread);
} }
......
...@@ -44,12 +44,14 @@ class DartMarkerGen ...@@ -44,12 +44,14 @@ class DartMarkerGen
protected: protected:
AttributeMultiVector<MarkerBool>* m_markVector; AttributeMultiVector<MarkerBool>* 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()
...@@ -77,26 +79,26 @@ public: ...@@ -77,26 +79,26 @@ public:
DartMarkerGen(thread), DartMarkerGen(thread),
m_map(map) m_map(map)
{ {
m_markVector = m_map.template askMarkVector<DART>(); m_markVector = m_map.template askMarkVector<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_markVector = m_map.template askMarkVector<DART>(); m_markVector = m_map.template askMarkVector<DART>(m_thread);
} }
virtual ~DartMarkerTmpl() virtual ~DartMarkerTmpl()
{ {
if (GenericMap::alive(&m_map)) if (GenericMap::alive(&m_map))
m_map.template releaseMarkVector<DART>(m_markVector); m_map.template releaseMarkVector<DART>(m_markVector,m_thread);
} }
inline void update() inline void update()
{ {
m_markVector = m_map.template askMarkVector<DART>(); m_markVector = m_map.template askMarkVector<DART>(m_thread);
} }
......
...@@ -114,7 +114,7 @@ protected: ...@@ -114,7 +114,7 @@ protected:
// std::vector< AttributeMultiVector<MarkerBool>* > m_markVectors[NB_ORBITS] ; // std::vector< AttributeMultiVector<MarkerBool>* > m_markVectors[NB_ORBITS] ;
std::vector< AttributeMultiVector<MarkerBool>* > m_markVectors_free[NB_ORBITS] ; std::vector< AttributeMultiVector<MarkerBool>* > m_markVectors_free[NB_ORBITS][NB_THREAD] ;
boost::mutex m_MarkerStorageMutex[NB_ORBITS]; boost::mutex m_MarkerStorageMutex[NB_ORBITS];
/** /**
...@@ -278,13 +278,13 @@ public: ...@@ -278,13 +278,13 @@ public:
* @brief ask for a marker attribute * @brief ask for a marker attribute
*/ */
template <unsigned int ORBIT> template <unsigned int ORBIT>
AttributeMultiVector<MarkerBool>* askMarkVector() ; AttributeMultiVector<MarkerBool>* askMarkVector(unsigned int thread=0) ;
/** /**
* @brief release allocated marker attribute * @brief release allocated marker attribute
*/ */
template <unsigned int ORBIT> template <unsigned int ORBIT>
void releaseMarkVector(AttributeMultiVector<MarkerBool>* amv); void releaseMarkVector(AttributeMultiVector<MarkerBool>* amv, unsigned int thread=0);
/** /**
......
...@@ -155,31 +155,31 @@ inline AttributeMultiVectorGen* GenericMap::getAttributeVectorGen(unsigned int o ...@@ -155,31 +155,31 @@ inline AttributeMultiVectorGen* GenericMap::getAttributeVectorGen(unsigned int o
template <unsigned int ORBIT> template <unsigned int ORBIT>
AttributeMultiVector<MarkerBool>* GenericMap::askMarkVector() AttributeMultiVector<MarkerBool>* GenericMap::askMarkVector(unsigned int thread)
{ {
assert(isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded") ; assert(isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded") ;
boost::mutex::scoped_lock lockMV(m_MarkerStorageMutex[ORBIT]); if (!m_markVectors_free[ORBIT][thread].empty())
if (!m_markVectors_free[ORBIT].empty())
{ {
AttributeMultiVector<MarkerBool>* amv = m_markVectors_free[ORBIT].back(); AttributeMultiVector<MarkerBool>* amv = m_markVectors_free[ORBIT][thread].back();
m_markVectors_free[ORBIT].pop_back(); m_markVectors_free[ORBIT][thread].pop_back();
return amv;
}
else
{
boost::mutex::scoped_lock lockMV(m_MarkerStorageMutex[ORBIT]);
AttributeMultiVector<MarkerBool>* amv = m_attribs[ORBIT].addAttribute<MarkerBool>("") ;
return amv; return amv;
} }
//else add attribute
AttributeMultiVector<MarkerBool>* amv = m_attribs[ORBIT].addAttribute<MarkerBool>("") ;
// std::cout << "ADD ATTRIBUTE"<< std::endl;
return amv;
} }
template <unsigned int ORBIT> template <unsigned int ORBIT>
inline void GenericMap::releaseMarkVector(AttributeMultiVector<MarkerBool>* amv) inline void GenericMap::releaseMarkVector(AttributeMultiVector<MarkerBool>* amv, unsigned int thread)
{ {
assert(isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded") ; assert(isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded") ;
boost::mutex::scoped_lock lockMV(m_MarkerStorageMutex[ORBIT]); m_markVectors_free[ORBIT][thread].push_back(amv);
m_markVectors_free[ORBIT].push_back(amv);
} }
......
...@@ -137,7 +137,7 @@ namespace Parallel ...@@ -137,7 +137,7 @@ namespace Parallel
* @param nbth number of used thread (0:for traversal, [1,nbth-1] for func computing * @param nbth number of used thread (0:for traversal, [1,nbth-1] for func computing
*/ */