diff --git a/Apps/Tuto/tuto_mt.cpp b/Apps/Tuto/tuto_mt.cpp index cd2da2ad679636dad72463fd2576715376bc0076..63daf0bbbd0ff3f9434624218777eaa7be6db47f 100644 --- a/Apps/Tuto/tuto_mt.cpp +++ b/Apps/Tuto/tuto_mt.cpp @@ -666,6 +666,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); @@ -718,32 +722,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); @@ -753,9 +751,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); @@ -766,21 +761,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 353b3e15fa0775979c6dc2ee66501d74d4cb6d9a..fafbcb71ad26f67751971f718d369f3cb123fd8e 100644 --- a/include/Algo/Parallel/parallel_foreach.hpp +++ b/include/Algo/Parallel/parallel_foreach.hpp @@ -228,6 +228,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 b7fc929ff07894765bb0dedf8d3327e8ee81be7b..958063b35384c7ef3a1b92342c6ce5c0d82907ce 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 ; } }