Salome HOME
Adding Multinode method for smesh parallelism + cleanup and doc
[modules/smesh.git] / src / SMESH / SMESH_ParallelMesh.cxx
index 6d70e15a289e84aac197dbc3e8f8d949fb479530..ef75ab21feb127674c7967243341892c44fe47f7 100644 (file)
@@ -58,11 +58,6 @@ SMESH_ParallelMesh::SMESH_ParallelMesh(int               theLocalId,
                                                                   theDocument)
 {
   MESSAGE("SMESH_ParallelMesh::SMESH_ParallelMesh(int localId)");
-#ifndef WIN32
-  _NbThreads = std::thread::hardware_concurrency();
-#else
-  _NbThreads = 0;
-#endif
   CreateTmpFolder();
 };
 
@@ -101,6 +96,39 @@ void SMESH_ParallelMesh::DeleteTmpFolder()
 #endif
 }
 
+//=============================================================================
+/*!
+ * \brief Get the number of Threads to be used for the pool of Threads
+ */
+//=============================================================================
+int SMESH_ParallelMesh::GetPoolNbThreads()
+{
+  int nbThreads = -1;
+
+  if(_method == ParallelismMethod::MultiThread){
+    nbThreads = _NbThreads;
+  }else if( _method == ParallelismMethod::MultiNode){
+    //TODO: Check of that is the right way
+    nbThreads = std::max(_nbProc, _nbNode*_nbProcPerNode);
+  } else {
+    throw SALOME_Exception("Unknown method "+std::to_string(_method));
+  }
+
+  return nbThreads;
+}
+
+//=============================================================================
+/*!
+ * \brief Set Number of thread for multithread run
+ */
+//=============================================================================
+void SMESH_ParallelMesh::SetNbThreads(long nbThreads)
+{
+  if(nbThreads < 1)
+    throw SALOME_Exception("Number of threads should be higher than 1");
+  _NbThreads=nbThreads;
+};
+
 bool SMESH_ParallelMesh::ComputeSubMeshes(
           SMESH_Gen* gen,
           SMESH_Mesh & aMesh,