diff --git a/Apps/Tuto/tuto_mt.cpp b/Apps/Tuto/tuto_mt.cpp index bfeb392fc967fbcfc808250e1530f8362261093c..958bec8057e51b07536214d124fdcb368a682436 100644 --- a/Apps/Tuto/tuto_mt.cpp +++ b/Apps/Tuto/tuto_mt.cpp @@ -665,6 +665,10 @@ public: typename PFP::VEC3 n2 = Algo::Geometry::vertexNormal(this->m_map, this->m_map.phi1(d), m_positions); typename PFP::VEC3 n3 = Algo::Geometry::vertexNormal(this->m_map, this->m_map.phi_1(d), m_positions); typename PFP::VEC3 n = n1+n2+n3; + n1 = Algo::Geometry::vertexNormal(this->m_map, d, m_positions); + n2 = Algo::Geometry::vertexNormal(this->m_map, this->m_map.phi1(d), m_positions); + n3 = Algo::Geometry::vertexNormal(this->m_map, this->m_map.phi_1(d), m_positions); + n += n1+n2+n3; n.normalize(); m_normals[d] = n; // m_normals[d] = Algo::Geometry::vertexNormal(this->m_map, d, m_positions); @@ -717,32 +721,26 @@ int main(int argc, char **argv) std::cout << " linear "<< seconds << "sec" << std::endl; - t1 = glutGet(GLUT_ELAPSED_TIME); - Algo::Geometry::computeNormalVertices(myMap,position,normal,SelectorTrue()); - t2 = glutGet(GLUT_ELAPSED_TIME); - seconds = (t2 - t1) / 1000.0f; - std::cout << " compute direct "<< seconds << "sec" << std::endl; +// t1 = glutGet(GLUT_ELAPSED_TIME); +// Algo::Geometry::computeNormalVertices(myMap,position,normal,SelectorTrue()); +// t2 = glutGet(GLUT_ELAPSED_TIME); +// seconds = (t2 - t1) / 1000.0f; +// std::cout << " compute direct "<< seconds << "sec" << std::endl; TestFunctor tf2(myMap,position,normal2); t1 = glutGet(GLUT_ELAPSED_TIME); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,4); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,4); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,4); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,4); + Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,4,1024); t2 = glutGet(GLUT_ELAPSED_TIME); seconds = (t2 - t1) / 1000.0f; - std::cout << " parallel 4 "<< seconds << "sec" << std::endl; + std::cout << " parallel 4, 1024 "<< seconds << "sec" << std::endl; t1 = glutGet(GLUT_ELAPSED_TIME); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,4,8192); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,4,8192); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,4,8192); Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,4,8192); t2 = glutGet(GLUT_ELAPSED_TIME); @@ -752,9 +750,6 @@ int main(int argc, char **argv) t1 = glutGet(GLUT_ELAPSED_TIME); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,8,8192); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,8,8192); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,8,8192); Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,8,8192); t2 = glutGet(GLUT_ELAPSED_TIME); @@ -765,21 +760,6 @@ int main(int argc, char **argv) t1 = glutGet(GLUT_ELAPSED_TIME); Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,16,8192); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,16,8192); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,16,8192); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,16,8192); - - t2 = glutGet(GLUT_ELAPSED_TIME); - seconds = (t2 - t1) / 1000.0f; - std::cout << " parallel 16/8192 "<< seconds << "sec" << std::endl; - - - t1 = glutGet(GLUT_ELAPSED_TIME); - - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,32,8192); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,32,8192); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,32,8192); - Algo::Parallel::foreach_cell(myMap,VERTEX_ORBIT, tf2,32,8192); t2 = glutGet(GLUT_ELAPSED_TIME); seconds = (t2 - t1) / 1000.0f; diff --git a/README.TXT b/README.TXT index 923c5edfb1266cceab2e363110b9d6555fce634b..1ba6e0d83938e870a1a96dac2e81554f4b46ec09 100644 --- a/README.TXT +++ b/README.TXT @@ -1,6 +1,6 @@ Dépendences Linux: installer les paquets suivants: -cmake libXi-dev libXmu-dev freeglut3-dev libdevil-dev libglew-dev libgmp3-dev libxml2-dev libboost-dev +cmake libXi-dev libXmu-dev freeglut3-dev libdevil-dev libglew-dev libgmp3-dev libxml2-dev libboost-dev lizip-dev Pour compiler CGoGN: diff --git a/include/Algo/Geometry/normal.hpp b/include/Algo/Geometry/normal.hpp index 24698e98945772e2f173798f7cfdccf21122e3a6..8404be6c64eb3dd81943a0e8c47d7ce6ddde8bc1 100644 --- a/include/Algo/Geometry/normal.hpp +++ b/include/Algo/Geometry/normal.hpp @@ -108,6 +108,26 @@ void computeNormalFaces(typename PFP::MAP& map, const typename PFP::TVEC3& posit } } +template +class computeNormalVerticesFunctor: public FunctorMap +{ +protected: + typename PFP::MAP& m_map; + const typename PFP::TVEC3& m_position; + typename PFP::TVEC3& m_normal; +public: + computeNormalVerticesFunctor(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& normal): + m_map(map), m_position(position), m_normal(normal) {} + + bool operator()(Dart d) + { + m_normal[d] = vertexNormal(m_map, d, m_position) ; + return false; + } +}; + + + template void computeNormalVertices(typename PFP::MAP& map, const typename PFP::TVEC3& position, typename PFP::TVEC3& normal, const FunctorSelect& select, unsigned int thread) { diff --git a/include/Algo/Parallel/parallel_foreach.h b/include/Algo/Parallel/parallel_foreach.h index baef4ab4d7711bb02d46528c2cc0358de1b1782d..46e637617210a131f7b710c4a487e520950574ea 100644 --- a/include/Algo/Parallel/parallel_foreach.h +++ b/include/Algo/Parallel/parallel_foreach.h @@ -44,7 +44,7 @@ namespace Parallel * @param map the map * @param orbit the orbit (VERTEX_ORBIT/EDGE_ORBIT/FACE_ORBIT/.. * @param func the functor to apply - * @param nbth number of thread to use ((use twice as threads of processor) + * @param nbth number of thread to use * @param szbuff size of buffers to store darts in each thread (default is 8192, use less for lower memory consumsion) * @param good a selector */ @@ -66,6 +66,20 @@ template void foreach_cell(typename PFP::MAP& map, unsigned int cell, FunctorType& func, unsigned int nbth, unsigned int szbuff=8192, const FunctorSelect& good= SelectorTrue()); +/** + * Traverse darts of a map in parallel + * Functor application must be independant + * @param map the map + * @param func the functor to apply + * @param nbth number of thread to use + * @param szbuff size of buffers to store darts in each thread (default is 8192, use less for lower memory consumsion) + * @param good a selector + */ +template +void foreach_dart(typename PFP::MAP& map, FunctorType& func, unsigned int nbth, unsigned int szbuff=8192, const FunctorSelect& good= SelectorTrue()); + + + } } // end namespace } diff --git a/include/Algo/Parallel/parallel_foreach.hpp b/include/Algo/Parallel/parallel_foreach.hpp index 9b08cc82c4e27dc33ec96d3d06fb74263b015405..52eff5f6ffe08dcca6bf7dc6b1fce812ee6b989a 100644 --- a/include/Algo/Parallel/parallel_foreach.hpp +++ b/include/Algo/Parallel/parallel_foreach.hpp @@ -232,6 +232,78 @@ void foreach_cell(typename PFP::MAP& map, unsigned int cell, FunctorType& func, } + +template +void foreach_dart(typename PFP::MAP& map, FunctorType& func, unsigned int nbth, unsigned int szbuff, const FunctorSelect& good) +{ + std::vector vd[nbth]; + boost::thread* threads[nbth]; + + Dart d=map.begin(); + + // nbth new functions, new thread (with good darts !) + for (unsigned int i=0; i tempo[nbth]; + for (unsigned int i=0; ijoin(); + delete threads[i]; + } +} + + } } // end namespace } diff --git a/src/Topology/generic/genericmap.cpp b/src/Topology/generic/genericmap.cpp index 220887cbbf94bb37aac88f0ea27a75513d84caf0..f26a383e09c5e6edaef6929f07f444562fe552ee 100644 --- a/src/Topology/generic/genericmap.cpp +++ b/src/Topology/generic/genericmap.cpp @@ -69,7 +69,8 @@ GenericMap::GenericMap() { m_attribs[i].setRegistry(m_attributes_registry_map) ; m_embeddings[i] = NULL ; - m_markerTables[i][0] = NULL ; + for (unsigned int j = 0; j < NBTHREAD; ++j) + m_markerTables[i][j] = NULL ; } }