mirror of
https://git.salome-platform.org/gitpub/modules/smesh.git
synced 2025-02-05 16:44:17 +05:00
Restoring parallelism on windows
This commit is contained in:
parent
9afcd890f5
commit
383311a14b
@ -40,11 +40,9 @@
|
|||||||
//Occ include
|
//Occ include
|
||||||
#include <TopoDS.hxx>
|
#include <TopoDS.hxx>
|
||||||
|
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/algorithm/string.hpp>
|
#include <boost/algorithm/string.hpp>
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
#endif
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Import the content of a shape file (STEP) into a TopDS_Shape object
|
* @brief Import the content of a shape file (STEP) into a TopDS_Shape object
|
||||||
@ -148,7 +146,6 @@ int exportBREPShape(const std::string shape_file, const TopoDS_Shape& aShape){
|
|||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
int SMESH_DriverShape::importShape(const std::string shape_file, TopoDS_Shape& aShape){
|
int SMESH_DriverShape::importShape(const std::string shape_file, TopoDS_Shape& aShape){
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
std::string type = fs::path(shape_file).extension().string();
|
std::string type = fs::path(shape_file).extension().string();
|
||||||
boost::algorithm::to_lower(type);
|
boost::algorithm::to_lower(type);
|
||||||
if (type == ".brep"){
|
if (type == ".brep"){
|
||||||
@ -158,9 +155,6 @@ int SMESH_DriverShape::importShape(const std::string shape_file, TopoDS_Shape& a
|
|||||||
} else {
|
} else {
|
||||||
throw SALOME_Exception("Unknow format for importShape: " + type);
|
throw SALOME_Exception("Unknow format for importShape: " + type);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -172,7 +166,6 @@ int SMESH_DriverShape::importShape(const std::string shape_file, TopoDS_Shape& a
|
|||||||
* @return error code
|
* @return error code
|
||||||
*/
|
*/
|
||||||
int SMESH_DriverShape::exportShape(const std::string shape_file, const TopoDS_Shape& aShape){
|
int SMESH_DriverShape::exportShape(const std::string shape_file, const TopoDS_Shape& aShape){
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
std::string type = fs::path(shape_file).extension().string();
|
std::string type = fs::path(shape_file).extension().string();
|
||||||
boost::algorithm::to_lower(type);
|
boost::algorithm::to_lower(type);
|
||||||
if (type == ".brep"){
|
if (type == ".brep"){
|
||||||
@ -182,7 +175,4 @@ int SMESH_DriverShape::exportShape(const std::string shape_file, const TopoDS_Sh
|
|||||||
} else {
|
} else {
|
||||||
throw SALOME_Exception("Unknow format for exportShape: " + type);
|
throw SALOME_Exception("Unknow format for exportShape: " + type);
|
||||||
}
|
}
|
||||||
#else
|
|
||||||
return 0;
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
@ -57,15 +57,11 @@
|
|||||||
|
|
||||||
#include <Basics_Utils.hxx>
|
#include <Basics_Utils.hxx>
|
||||||
|
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#endif
|
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
namespace fs = boost::filesystem;
|
namespace fs = boost::filesystem;
|
||||||
#endif
|
|
||||||
|
|
||||||
// Environment variable separator
|
// Environment variable separator
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -307,10 +303,6 @@ bool SMESH_Gen::parallelComputeSubMeshes(
|
|||||||
const bool complexShapeFirst,
|
const bool complexShapeFirst,
|
||||||
const bool aShapeOnly)
|
const bool aShapeOnly)
|
||||||
{
|
{
|
||||||
#ifdef DISABLE_PSMESH
|
|
||||||
throw SALOME_Exception("ParallelMesh is not working on Windows");
|
|
||||||
#else
|
|
||||||
|
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
|
|
||||||
SMESH_subMeshIteratorPtr smIt;
|
SMESH_subMeshIteratorPtr smIt;
|
||||||
@ -386,7 +378,6 @@ bool SMESH_Gen::parallelComputeSubMeshes(
|
|||||||
aMesh.GetMeshDS()->Modified();
|
aMesh.GetMeshDS()->Modified();
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
|
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
|
@ -49,10 +49,8 @@
|
|||||||
#include <vector>
|
#include <vector>
|
||||||
#include <ostream>
|
#include <ostream>
|
||||||
|
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
#include <boost/asio/thread_pool.hpp>
|
#include <boost/asio/thread_pool.hpp>
|
||||||
#endif
|
|
||||||
#include <boost/thread.hpp>
|
#include <boost/thread.hpp>
|
||||||
|
|
||||||
#ifdef WIN32
|
#ifdef WIN32
|
||||||
@ -404,10 +402,8 @@ class SMESH_EXPORT SMESH_Mesh
|
|||||||
|
|
||||||
virtual bool IsParallel(){std::cout << "Should not pass here: IsParallel" << std::endl;return false;};
|
virtual bool IsParallel(){std::cout << "Should not pass here: IsParallel" << std::endl;return false;};
|
||||||
|
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
virtual boost::filesystem::path GetTmpFolder() {return "";};
|
virtual boost::filesystem::path GetTmpFolder() {return "";};
|
||||||
virtual boost::asio::thread_pool* GetPool() {return NULL;};
|
virtual boost::asio::thread_pool* GetPool() {return NULL;};
|
||||||
#endif
|
|
||||||
|
|
||||||
virtual bool ComputeSubMeshes(
|
virtual bool ComputeSubMeshes(
|
||||||
SMESH_Gen* gen,
|
SMESH_Gen* gen,
|
||||||
@ -468,9 +464,7 @@ protected:
|
|||||||
TCallUp* _callUp;
|
TCallUp* _callUp;
|
||||||
|
|
||||||
// Mutex for multhitreading write in SMESH_Mesh
|
// Mutex for multhitreading write in SMESH_Mesh
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
boost::mutex _my_lock;
|
boost::mutex _my_lock;
|
||||||
#endif
|
|
||||||
int _NbThreads=-1;
|
int _NbThreads=-1;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
|
@ -32,14 +32,10 @@
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
#include <boost/filesystem.hpp>
|
#include <boost/filesystem.hpp>
|
||||||
namespace fs=boost::filesystem;
|
namespace fs=boost::filesystem;
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
#include <boost/asio.hpp>
|
#include <boost/asio.hpp>
|
||||||
#endif
|
|
||||||
|
|
||||||
#include <utilities.h>
|
#include <utilities.h>
|
||||||
|
|
||||||
@ -58,11 +54,7 @@ SMESH_ParallelMesh::SMESH_ParallelMesh(int theLocalId,
|
|||||||
theDocument)
|
theDocument)
|
||||||
{
|
{
|
||||||
MESSAGE("SMESH_ParallelMesh::SMESH_ParallelMesh(int localId)");
|
MESSAGE("SMESH_ParallelMesh::SMESH_ParallelMesh(int localId)");
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
_NbThreads = std::thread::hardware_concurrency();
|
_NbThreads = std::thread::hardware_concurrency();
|
||||||
#else
|
|
||||||
_NbThreads = 0;
|
|
||||||
#endif
|
|
||||||
CreateTmpFolder();
|
CreateTmpFolder();
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -82,11 +74,9 @@ SMESH_ParallelMesh::~SMESH_ParallelMesh()
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
void SMESH_ParallelMesh::CreateTmpFolder()
|
void SMESH_ParallelMesh::CreateTmpFolder()
|
||||||
{
|
{
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
// Temporary folder that will be used by parallel computation
|
// Temporary folder that will be used by parallel computation
|
||||||
tmp_folder = fs::temp_directory_path()/fs::unique_path(fs::path("SMESH_%%%%-%%%%"));
|
tmp_folder = fs::temp_directory_path()/fs::unique_path(fs::path("SMESH_%%%%-%%%%"));
|
||||||
fs::create_directories(tmp_folder);
|
fs::create_directories(tmp_folder);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
//
|
//
|
||||||
//=============================================================================
|
//=============================================================================
|
||||||
@ -96,9 +86,7 @@ void SMESH_ParallelMesh::CreateTmpFolder()
|
|||||||
//=============================================================================
|
//=============================================================================
|
||||||
void SMESH_ParallelMesh::DeleteTmpFolder()
|
void SMESH_ParallelMesh::DeleteTmpFolder()
|
||||||
{
|
{
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
fs::remove_all(tmp_folder);
|
fs::remove_all(tmp_folder);
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool SMESH_ParallelMesh::ComputeSubMeshes(
|
bool SMESH_ParallelMesh::ComputeSubMeshes(
|
||||||
|
@ -42,7 +42,6 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh
|
|||||||
|
|
||||||
virtual ~SMESH_ParallelMesh();
|
virtual ~SMESH_ParallelMesh();
|
||||||
|
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
void Lock() override {_my_lock.lock();};
|
void Lock() override {_my_lock.lock();};
|
||||||
void Unlock() override {_my_lock.unlock();};
|
void Unlock() override {_my_lock.unlock();};
|
||||||
|
|
||||||
@ -61,22 +60,6 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh
|
|||||||
|
|
||||||
boost::filesystem::path GetTmpFolder() override {return tmp_folder;};
|
boost::filesystem::path GetTmpFolder() override {return tmp_folder;};
|
||||||
boost::asio::thread_pool* GetPool() override {return _pool;};
|
boost::asio::thread_pool* GetPool() override {return _pool;};
|
||||||
#else
|
|
||||||
void Lock() override {};
|
|
||||||
void Unlock() override {};
|
|
||||||
|
|
||||||
int GetNbThreads() override {return 0;};
|
|
||||||
void SetNbThreads(long nbThreads) {(void) nbThreads;};
|
|
||||||
|
|
||||||
void InitPoolThreads() override {};
|
|
||||||
void DeletePoolThreads() override {};
|
|
||||||
void wait() override {};
|
|
||||||
|
|
||||||
bool IsParallel() override {return false;};
|
|
||||||
|
|
||||||
void CreateTmpFolder();
|
|
||||||
void DeleteTmpFolder();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
bool ComputeSubMeshes(
|
bool ComputeSubMeshes(
|
||||||
SMESH_Gen* gen,
|
SMESH_Gen* gen,
|
||||||
@ -94,9 +77,7 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh
|
|||||||
SMESH_ParallelMesh():SMESH_Mesh() {};
|
SMESH_ParallelMesh():SMESH_Mesh() {};
|
||||||
SMESH_ParallelMesh(const SMESH_ParallelMesh& aMesh):SMESH_Mesh(aMesh) {};
|
SMESH_ParallelMesh(const SMESH_ParallelMesh& aMesh):SMESH_Mesh(aMesh) {};
|
||||||
private:
|
private:
|
||||||
#ifndef DISABLE_PSMESH
|
|
||||||
boost::filesystem::path tmp_folder;
|
boost::filesystem::path tmp_folder;
|
||||||
boost::asio::thread_pool * _pool = nullptr; //thread pool for computation
|
boost::asio::thread_pool * _pool = nullptr; //thread pool for computation
|
||||||
#endif
|
|
||||||
};
|
};
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user