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

remove needMarker parameter

parent 1e679811
......@@ -459,45 +459,41 @@ void Viewer::cb_keyPress(int keycode)
Utils::Chrono ch;
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;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
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;
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;
// 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 = 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;
for (unsigned int i=0; i<4; ++i)
Algo::Surface::Geometry::Parallel::computeNormalVertices<PFP>(myMap, position, normal) ;
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)
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();
......@@ -505,7 +501,7 @@ void Viewer::cb_keyPress(int keycode)
Parallel::foreach_cell<VERTEX>(myMap, [&] (Vertex v, unsigned int th)
{
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;
......
......@@ -108,7 +108,7 @@ int main()
{
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) !!!!
}, 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;
foreach_cell<VERTEX>(myMap, [&] (Vertex v) // for each Vertex v of the MAP myMap
......@@ -132,7 +132,7 @@ int main()
{
// 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);
}, false);
});
std::cout << 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
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
area[f] = convexFaceArea<PFP>(map, f, position) ;
},false,AUTO);
});
}
......@@ -246,7 +246,7 @@ void computeOneRingAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{
area[v] = vertexOneRingArea<PFP>(map, v, position) ;
},false,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
template <typename PFP>
......@@ -256,7 +256,7 @@ void computeBarycentricAreaVertices(typename PFP::MAP& map, const VertexAttribut
{
vertex_area[v] = vertexBarycentricArea<PFP>(map, v, position) ;
}
,false,FORCE_CELL_MARKING);
,FORCE_CELL_MARKING);
}
template <typename PFP>
......@@ -265,7 +265,7 @@ void computeVoronoiAreaVertices(typename PFP::MAP& map, const VertexAttribute<ty
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{
area[v] = vertexVoronoiArea<PFP>(map, v, position) ;
},false,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
} // namespace Parallel
......
......@@ -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)
{
face_centroid[f] = faceCentroid<PFP>(map, f, position) ;
},false,AUTO);
});
}
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
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
face_centroid[f] = faceCentroidELW<PFP>(map, f, position) ;
},false,AUTO);
});
}
......@@ -207,7 +207,7 @@ void computeNeighborhoodCentroidVertices(typename PFP::MAP& map,
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int thr)
{
vertex_centroid[v] = vertexNeighborhoodCentroid<PFP>(map, v, position) ;
},false,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
} // namespace Parallel
......@@ -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)
{
vol_centroid[v] = Surface::Geometry::volumeCentroid<PFP,V_ATT>(map, v, position, thr) ;
},true,AUTO);
});
}
template <typename PFP, typename V_ATT, typename W_ATT>
......@@ -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)
{
vol_centroid[v] = Surface::Geometry::volumeCentroidELW<PFP,V_ATT>(map, v, position, thr) ;
},true,AUTO);
});
}
......
......@@ -667,7 +667,7 @@ void computeCurvatureVertices_NormalCycles(
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) ;
},true,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
template <typename PFP>
......@@ -696,7 +696,7 @@ void computeCurvatureVertices_NormalCycles_Projected(
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) ;
},true,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
......@@ -714,7 +714,7 @@ void computeCurvatureVertices_QuadraticFitting(
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int 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&
CGoGN::Parallel::foreach_cell<VERTEX>(map,[&](Vertex v, unsigned int /*thr*/)
{
normal[v] = vertexNormal<PFP>(map, v, position) ;
},true,FORCE_CELL_MARKING);
},FORCE_CELL_MARKING);
}
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
CGoGN::Parallel::foreach_cell<FACE>(map,[&](Face f, unsigned int thr)
{
normal[f] = faceNormal<PFP>(map, f, position) ;
},true,AUTO);
});
}
......@@ -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)
{
angles[e] = computeAngleBetweenNormalsOnEdge<PFP>(map, e, position) ;
},true,AUTO);
});
}
} // namespace Parallel
......
......@@ -332,7 +332,7 @@ void foreach_attribute(ATTR& attribute, FUNC func, unsigned int nbthread)
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]) ) );
}
......
......@@ -45,10 +45,11 @@ class CellMarkerGen
protected:
AttributeMultiVector<MarkerBool>* m_markVector ;
unsigned int m_cell ;
unsigned int m_thread;
public:
CellMarkerGen(unsigned int cell, unsigned int thread = 0) :
m_cell(cell)
m_cell(cell),m_thread(thread)
{}
virtual ~CellMarkerGen()
......@@ -86,7 +87,7 @@ public:
{
if(!m_map.template isOrbitEmbedded<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) :
......@@ -95,20 +96,20 @@ public:
{
if(!m_map.template isOrbitEmbedded<CELL>())
m_map.template addEmbedding<CELL>() ;
m_markVector = m_map.template askMarkVector<CELL>();
m_markVector = m_map.template askMarkVector<CELL>(m_thread);
}
virtual ~CellMarkerBase()
{
if (GenericMap::alive(&m_map))
m_map.template releaseMarkVector<CELL>(m_markVector);
m_map.template releaseMarkVector<CELL>(m_markVector,m_thread);
}
void update()
{
if(!m_map.template isOrbitEmbedded<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
protected:
AttributeMultiVector<MarkerBool>* m_markVector;
unsigned int m_thread;
public:
/**
* constructor
*/
DartMarkerGen(unsigned int thread=0)
DartMarkerGen(unsigned int thread=0):
m_thread(thread)
{}
virtual ~DartMarkerGen()
......@@ -77,26 +79,26 @@ public:
DartMarkerGen(thread),
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) :
DartMarkerGen(thread),
m_map(const_cast<MAP&>(map))
{
m_markVector = m_map.template askMarkVector<DART>();
m_markVector = m_map.template askMarkVector<DART>(m_thread);
}
virtual ~DartMarkerTmpl()
{
if (GenericMap::alive(&m_map))
m_map.template releaseMarkVector<DART>(m_markVector);
m_map.template releaseMarkVector<DART>(m_markVector,m_thread);
}
inline void update()
{
m_markVector = m_map.template askMarkVector<DART>();
m_markVector = m_map.template askMarkVector<DART>(m_thread);
}
......
......@@ -114,7 +114,7 @@ protected:
// 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];
/**
......@@ -278,13 +278,13 @@ public:
* @brief ask for a marker attribute
*/
template <unsigned int ORBIT>
AttributeMultiVector<MarkerBool>* askMarkVector() ;
AttributeMultiVector<MarkerBool>* askMarkVector(unsigned int thread=0) ;
/**
* @brief release allocated marker attribute
*/
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
template <unsigned int ORBIT>
AttributeMultiVector<MarkerBool>* GenericMap::askMarkVector()
AttributeMultiVector<MarkerBool>* GenericMap::askMarkVector(unsigned int thread)
{
assert(isOrbitEmbedded<ORBIT>() || !"Invalid parameter: orbit not embedded") ;
boost::mutex::scoped_lock lockMV(m_MarkerStorageMutex[ORBIT]);
if (!m_markVectors_free[ORBIT].empty())
if (!m_markVectors_free[ORBIT][thread].empty())
{
AttributeMultiVector<MarkerBool>* amv = m_markVectors_free[ORBIT].back();
m_markVectors_free[ORBIT].pop_back();
AttributeMultiVector<MarkerBool>* amv = m_markVectors_free[ORBIT][thread].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;
}
//else add attribute
AttributeMultiVector<MarkerBool>* amv = m_attribs[ORBIT].addAttribute<MarkerBool>("") ;
// std::cout << "ADD ATTRIBUTE"<< std::endl;
return amv;
}
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") ;
boost::mutex::scoped_lock lockMV(m_MarkerStorageMutex[ORBIT]);
m_markVectors_free[ORBIT].push_back(amv);
m_markVectors_free[ORBIT][thread].push_back(amv);
}
......
......@@ -137,7 +137,7 @@ namespace Parallel
* @param nbth number of used thread (0:for traversal, [1,nbth-1] for func computing
*/
template <unsigned int ORBIT, typename MAP, typename FUNC>
void foreach_cell(MAP& map, FUNC func, bool needMarkers = true, TraversalOptim opt = AUTO, unsigned int nbth = NumberOfThreads);
void foreach_cell(MAP& map, FUNC func, TraversalOptim opt = AUTO, unsigned int nbth = NumberOfThreads);
} // namespace Parallel
......
......@@ -686,7 +686,7 @@ public:
template <TraversalOptim OPT, unsigned int ORBIT, typename MAP, typename FUNC>
void foreach_cell_tmpl(MAP& map, FUNC func, bool needMarkers, unsigned int nbth)
void foreach_cell_tmpl(MAP& map, FUNC func, unsigned int nbth)
{
// buffer for cell traversing
std::vector< Cell<ORBIT> >* vd = new std::vector< Cell<ORBIT> >[nbth];
......@@ -759,7 +759,7 @@ void foreach_cell_tmpl(MAP& map, FUNC func, bool needMarkers, unsigned int nbth)
}
template <unsigned int ORBIT, typename MAP, typename FUNC>
void foreach_cell(MAP& map, FUNC func, bool needMarkers, TraversalOptim opt, unsigned int nbth)
void foreach_cell(MAP& map, FUNC func, TraversalOptim opt, unsigned int nbth)
{
if (nbth < 2)
{
......@@ -769,17 +769,17 @@ void foreach_cell(MAP& map, FUNC func, bool needMarkers, TraversalOptim opt, uns
switch(opt)
{
case FORCE_DART_MARKING:
foreach_cell_tmpl<FORCE_DART_MARKING,ORBIT,MAP,FUNC>(map,func,needMarkers,nbth-1);
foreach_cell_tmpl<FORCE_DART_MARKING,ORBIT,MAP,FUNC>(map,func,nbth-1);
break;
case FORCE_CELL_MARKING:
foreach_cell_tmpl<FORCE_CELL_MARKING,ORBIT,MAP,FUNC>(map,func,needMarkers,nbth-1);
foreach_cell_tmpl<FORCE_CELL_MARKING,ORBIT,MAP,FUNC>(map,func,nbth-1);
break;
case FORCE_QUICK_TRAVERSAL:
foreach_cell_tmpl<FORCE_QUICK_TRAVERSAL,ORBIT,MAP,FUNC>(map,func,needMarkers,nbth-1);
foreach_cell_tmpl<FORCE_QUICK_TRAVERSAL,ORBIT,MAP,FUNC>(map,func,nbth-1);
break;
case AUTO:
default:
foreach_cell_tmpl<AUTO,ORBIT,MAP,FUNC>(map,func,needMarkers,nbth-1);
foreach_cell_tmpl<AUTO,ORBIT,MAP,FUNC>(map,func,nbth-1);
break;
}
}
......
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