]> SALOME platform Git repositories - modules/smesh.git/commitdiff
Salome HOME
Adding support of number of thread for the mesher
authorYoann Audouin <yoann.audouin@edf.fr>
Tue, 13 Sep 2022 12:17:43 +0000 (14:17 +0200)
committerYoann Audouin <yoann.audouin@edf.fr>
Tue, 13 Sep 2022 12:17:43 +0000 (14:17 +0200)
idl/SMESH_Mesh.idl
src/SMESH/SMESH_Gen.cxx
src/SMESH/SMESH_Mesh.hxx
src/SMESH_I/SMESH_2smeshpy.cxx
src/SMESH_I/SMESH_Mesh_i.cxx
src/SMESH_I/SMESH_Mesh_i.hxx
src/SMESH_SWIG/smeshBuilder.py

index 0abc234b6a97d48def9ac693c60f57196ef7b45b..adfe5f782356e38e77cf8ce9c4dc173475ed51bf 100644 (file)
@@ -903,6 +903,12 @@ module SMESH
      * \brief Set Number of Threads
      */
     void SetNbThreads(in long nbThreads);
+    /*!
+
+     * \brief Set Number of Threads for mesher
+     */
+    void SetMesherNbThreads(in long nbThreads);
+
 
     /*!
      * Get mesh description
index b7433ae7045945d70c7f58c496e16c9b65f5a41f..b0210005f02260d7ed1315a5450a3ac5edaa1c3e 100644 (file)
@@ -251,6 +251,7 @@ bool SMESH_Gen::Compute(SMESH_Mesh &                aMesh,
     TopAbs_ShapeEnum previousShapeType = TopAbs_VERTEX;
     int nbThreads = aMesh.GetNbThreads();
     auto begin = std::chrono::high_resolution_clock::now();
+    std::cout << "Running mesh with threads: " << nbThreads << " mesher: " << aMesh.GetMesherNbThreads() << std::endl;
 
 
     smIt = shapeSM->getDependsOnIterator(includeSelf, !complexShapeFirst);
@@ -309,8 +310,6 @@ bool SMESH_Gen::Compute(SMESH_Mesh &                aMesh,
       }
       if(aMesh.IsParallel())
       {
-        std::cout << "Submitting thread function " << std::endl;
-        boost::asio::post(*(aMesh._pool), [](){std::cerr<< "In Here" << std::endl;});
         boost::asio::post(*(aMesh._pool), std::bind(compute_function, 1, smToCompute, computeEvent,
                           shapeSM, aShapeOnly, allowedSubShapes,
                           aShapesId));
@@ -321,8 +320,6 @@ bool SMESH_Gen::Compute(SMESH_Mesh &                aMesh,
                          shapeSM, aShapeOnly, allowedSubShapes,
                          aShapesId);
 
-
-
         if (smToCompute->GetComputeState() == SMESH_subMesh::FAILED_TO_COMPUTE &&
            ( shapeType != TopAbs_EDGE || !SMESH_Algo::isDegenerated( TopoDS::Edge( shape ))))
           ret = false;
index 533b5648f02c5308522d75beba49da6df698c999..a0ef3ae87516933c2e1fda7e40d35747f380f78e 100644 (file)
@@ -392,6 +392,9 @@ class SMESH_EXPORT SMESH_Mesh
   int GetNbThreads(){return _NbThreads;};
   void SetNbThreads(int nbThreads){_NbThreads=nbThreads;};
 
+  int GetMesherNbThreads(){return _MesherNbThreads;};
+  void SetMesherNbThreads(int nbThreads){_MesherNbThreads=nbThreads;};
+
   void InitPoolThreads(){_pool = new boost::asio::thread_pool(_NbThreads);};
   void DeletePoolThreads(){delete _pool;};
 
@@ -453,6 +456,7 @@ protected:
   // Mutex for multhitreading write in SMESH_Mesh
   std::mutex _my_lock;
   int _NbThreads=0;
+  int _MesherNbThreads=0;
 
 protected:
   SMESH_Mesh();
index 1a0c6c2d2cb854a9548c2b1ba0528221324af774..187a2667ebeba3fea517efff591572ad1ccdc327 100644 (file)
@@ -2211,7 +2211,8 @@ bool _pyMesh::NeedMeshAccess( const Handle(_pyCommand)& theCommand )
         "GetElemNode","IsMediumNode","IsMediumNodeOfAnyElem","ElemNbEdges","ElemNbFaces",
         "GetElemFaceNodes", "GetFaceNormal", "FindElementByNodes",
         "IsPoly","IsQuadratic","BaryCenter","GetHypothesisList", "SetAutoColor", "GetAutoColor",
-        "Clear", "ConvertToStandalone", "GetMeshOrder", "SetMeshOrder", "SetNbThreads"
+        "Clear", "ConvertToStandalone", "GetMeshOrder", "SetMeshOrder",
+        "SetNbThreads", "SetMesherNbThreads"
         ,"" }; // <- mark of end
     sameMethods.Insert( names );
   }
index 2bf934ce92f5c13ee447d8eada36b855a7156212..7dc45b405ac03877e7576f563a3952e29d572c42 100644 (file)
@@ -7044,6 +7044,15 @@ void SMESH_Mesh_i::SetNbThreads(int nbThreads){
   _impl->SetNbThreads(nbThreads);
 }
 
+//=============================================================================
+/*!
+ * \brief Set the number of threads for the mesher for a parallel computation
+ */
+//=============================================================================
+void SMESH_Mesh_i::SetMesherNbThreads(int nbThreads){
+  _impl->SetMesherNbThreads(nbThreads);
+}
+
 
 //=============================================================================
 /*!
index 9685061d61da14266cc382b4d410be112e74635e..cee8e4b984ff36ec1e3e4c1b9f91cfb3f5888015 100644 (file)
@@ -674,6 +674,7 @@ private:
                         const bool                  theIsDump);
 
   void SetNbThreads(int nbThreads);
+  void SetMesherNbThreads(int nbThreads);
 
   /*!
    * \brief Finds concurrent sub-meshes
index ef57b606ce279c24f2dfb467799503d34bf5a1b5..74b1f67352005da74da3170915ecb9f962184cfb 100644 (file)
@@ -1842,7 +1842,7 @@ class Mesh(metaclass = MeshMeta):
                 geom = self.geom
         return self.smeshpyD.Evaluate(self.mesh, geom)
 
-    def ParallelCompute(self, nbThreads, geom=0, discardModifs=False, refresh=False):
+    def ParallelCompute(self, nbThreads, mesherNbThreads=1, geom=0, discardModifs=False, refresh=False):
         """
         Parallel computation of the mesh and return the status of the computation
         The mesh must contains have be constructed using create_parallel_mesh
@@ -1859,7 +1859,11 @@ class Mesh(metaclass = MeshMeta):
                 True or False
         """
         if (nbThreads <= 1):
+            raise ValueError("nbThreads must be strictly greater than 1")
+        if (mesherNbThreads < 1):
             raise ValueError("nbThreads must be greater than 1")
+
+        self.mesh.SetMesherNbThreads(mesherNbThreads)
         self.mesh.SetNbThreads(nbThreads)
         return self.Compute(geom=geom, discardModifs=discardModifs, refresh=refresh)