From 185dd64d978733a85a75fa05fe10344ea55815c6 Mon Sep 17 00:00:00 2001 From: Yoann Audouin Date: Wed, 26 Oct 2022 16:17:27 +0200 Subject: [PATCH] Disabling parallel compute for windows --- src/SMESH/SMESH_Gen.cxx | 11 +++++++++-- src/SMESH/SMESH_Mesh.cxx | 3 ++- src/SMESH/SMESH_Mesh.hxx | 21 +++++++++++++++++++++ 3 files changed, 32 insertions(+), 3 deletions(-) diff --git a/src/SMESH/SMESH_Gen.cxx b/src/SMESH/SMESH_Gen.cxx index 0d59428af..4297420f8 100644 --- a/src/SMESH/SMESH_Gen.cxx +++ b/src/SMESH/SMESH_Gen.cxx @@ -27,8 +27,10 @@ // //#define CHRONODEF - +// +#ifndef DISABLE_PARAMESH #include +#endif #include "SMESH_Gen.hxx" #include "SMESH_DriverMesh.hxx" @@ -348,9 +350,15 @@ bool SMESH_Gen::parallelComputeSubMeshes( smToCompute->ComputeStateEngine( SMESH_subMesh::CHECK_COMPUTE_STATE ); continue; } +#ifdef DISABLE_PARASMESH + compute_function(smToCompute, computeEvent, + shapeSM, aShapeOnly, allowedSubShapes, + aShapesId); +#else boost::asio::post(*(aMesh._pool), std::bind(compute_function, smToCompute, computeEvent, shapeSM, aShapeOnly, allowedSubShapes, aShapesId)); +#endif } // Waiting for the thread for Solids to finish @@ -361,7 +369,6 @@ bool SMESH_Gen::parallelComputeSubMeshes( return ret; }; - //============================================================================= /* * Compute a mesh diff --git a/src/SMESH/SMESH_Mesh.cxx b/src/SMESH/SMESH_Mesh.cxx index 077fd7f44..edff014cd 100644 --- a/src/SMESH/SMESH_Mesh.cxx +++ b/src/SMESH/SMESH_Mesh.cxx @@ -239,9 +239,10 @@ SMESH_Mesh::~SMESH_Mesh() int result=pthread_create(&thread, NULL, deleteMeshDS, (void*)_meshDS); #endif } - +#ifndef DISABLE_PARASMESH if(_pool) DeletePoolThreads(); +#endif #ifndef _DEBUG_ fs::remove_all(tmp_folder); #endif diff --git a/src/SMESH/SMESH_Mesh.hxx b/src/SMESH/SMESH_Mesh.hxx index 18da4e93f..deed18d6b 100644 --- a/src/SMESH/SMESH_Mesh.hxx +++ b/src/SMESH/SMESH_Mesh.hxx @@ -29,6 +29,7 @@ #include "SMESH_SMESH.hxx" + #include "SMDSAbs_ElementType.hxx" #include "SMESH_ComputeError.hxx" #include "SMESH_Controls.hxx" @@ -49,8 +50,10 @@ #include #include +#ifndef DISABLE_PARASMESH #include #include +#endif #ifdef WIN32 #pragma warning(disable:4251) // Warning DLL Interface ... @@ -388,6 +391,19 @@ class SMESH_EXPORT SMESH_Mesh // Parallel computation functions +#ifdef DISABLE_PARASMESH + void Lock() {}; + void Unlock() {}; + + int GetNbThreads(){return _NbThreads;}; + void SetNbThreads(int nbThreads){std::cout << "Warning Parallel Meshing is disabled on Windows it will behave as a slower normal compute" << std::endl;_NbThreads=nbThreads;}; + + void InitPoolThreads(){}; + void DeletePoolThreads(){}; + void wait(){} + + bool IsParallel(){return _NbThreads > 0;} +#else void Lock() {_my_lock.lock();}; void Unlock() {_my_lock.unlock();}; @@ -400,10 +416,13 @@ class SMESH_EXPORT SMESH_Mesh void wait(){_pool->join(); DeletePoolThreads(); InitPoolThreads(); } bool IsParallel(){return _NbThreads > 0;} +#endif // Temporary folder used during parallel Computation boost::filesystem::path tmp_folder; + #ifndef DISABLE_PARASMESH boost::asio::thread_pool * _pool = nullptr; //thread pool for computation + #endif private: @@ -453,7 +472,9 @@ protected: TCallUp* _callUp; // Mutex for multhitreading write in SMESH_Mesh +#ifndef DISABLE_PARASMESH boost::mutex _my_lock; +#endif int _NbThreads=0; protected: -- 2.39.2