Adding walltime for multinode + keeping temporary folder with environement variable

This commit is contained in:
YOANN AUDOUIN 2023-09-07 10:25:11 +02:00
parent 18907e41a0
commit 9cefcee9dd
8 changed files with 93 additions and 11 deletions

View File

@ -1128,6 +1128,9 @@ module SMESH
string GetWcKey(); string GetWcKey();
void SetWcKey(in string wcKey); void SetWcKey(in string wcKey);
string GetWalltime();
void SetWalltime(in string walltime);
}; };
}; };

View File

@ -453,6 +453,9 @@ bool SMESH_Gen::parallelComputeSubMeshes(
aMesh.GetMeshDS()->Modified(); aMesh.GetMeshDS()->Modified();
// Cleanup done here as in Python the destructor is not called
aParMesh.cleanup();
return ret; return ret;
#endif #endif
}; };

View File

@ -43,12 +43,6 @@ namespace fs=boost::filesystem;
#include <utilities.h> #include <utilities.h>
#ifdef _DEBUG_
static int MYDEBUG = 1;
#else
static int MYDEBUG = 0;
#endif
SMESH_ParallelMesh::SMESH_ParallelMesh(int theLocalId, SMESH_ParallelMesh::SMESH_ParallelMesh(int theLocalId,
SMESH_Gen* theGen, SMESH_Gen* theGen,
bool theIsEmbeddedMode, bool theIsEmbeddedMode,
@ -63,11 +57,46 @@ SMESH_ParallelMesh::SMESH_ParallelMesh(int theLocalId,
SMESH_ParallelMesh::~SMESH_ParallelMesh() SMESH_ParallelMesh::~SMESH_ParallelMesh()
{ {
DeletePoolThreads(); cleanup();
if(!MYDEBUG)
DeleteTmpFolder();
}; };
void SMESH_ParallelMesh::cleanup()
{
DeletePoolThreads();
std::cout << "Keeping tmp folder" << keepingTmpFolfer() << std::endl;
if(!keepingTmpFolfer())
{
MESSAGE("Set SMESH_KEEP_TMP to > 0 to keep temporary folders")
DeleteTmpFolder();
}
};
//=============================================================================
/*!
* \brief Checking if we should keep the temporary folder
* They are kept if the variable SMESH_KEEP_TMP is set to higher than 0
*/
//=============================================================================
bool SMESH_ParallelMesh::keepingTmpFolfer()
{
const char* envVar = std::getenv("SMESH_KEEP_TMP");
std::cout << "smesh_keep_tmp: " << envVar << std::endl;
if (envVar && (envVar[0] != '\0'))
{
try
{
const long long numValue = std::stoll(envVar);
return numValue > 0;
}
catch(const std::exception& e)
{
std::cerr << e.what() << '\n';
}
}
return false;
};
//============================================================================= //=============================================================================
@ -92,6 +121,7 @@ void SMESH_ParallelMesh::CreateTmpFolder()
void SMESH_ParallelMesh::DeleteTmpFolder() void SMESH_ParallelMesh::DeleteTmpFolder()
{ {
#ifndef WIN32 #ifndef WIN32
MESSAGE("Deleting temporary folder" << tmp_folder.string());
fs::remove_all(tmp_folder); fs::remove_all(tmp_folder);
#endif #endif
} }

View File

@ -46,7 +46,7 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh
bool theIsEmbeddedMode, bool theIsEmbeddedMode,
SMESHDS_Document* theDocument); SMESHDS_Document* theDocument);
virtual ~SMESH_ParallelMesh(); ~SMESH_ParallelMesh();
// Locking mechanism // Locking mechanism
void Lock() override {_my_lock.lock();}; void Lock() override {_my_lock.lock();};
@ -66,9 +66,11 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh
int GetPoolNbThreads(); int GetPoolNbThreads();
// Temporary folder // Temporary folder
bool keepingTmpFolfer();
void CreateTmpFolder(); void CreateTmpFolder();
void DeleteTmpFolder(); void DeleteTmpFolder();
boost::filesystem::path GetTmpFolder() {return tmp_folder;}; boost::filesystem::path GetTmpFolder() {return tmp_folder;};
void cleanup();
// //
bool IsParallel() override {return true;}; bool IsParallel() override {return true;};
@ -97,6 +99,9 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh
std::string GetWcKey() {return _wcKey;}; std::string GetWcKey() {return _wcKey;};
void SetWcKey(std::string wcKey) {_wcKey = wcKey;}; void SetWcKey(std::string wcKey) {_wcKey = wcKey;};
std::string GetWalltime() {return _walltime;};
void SetWalltime(std::string walltime) {_walltime = walltime;};
// Parallel computation // Parallel computation
bool ComputeSubMeshes( bool ComputeSubMeshes(
SMESH_Gen* gen, SMESH_Gen* gen,
@ -131,5 +136,6 @@ class SMESH_EXPORT SMESH_ParallelMesh: public SMESH_Mesh
int _nbNode = 1; int _nbNode = 1;
std::string _resource = ""; std::string _resource = "";
std::string _wcKey = "P11N0:SALOME"; std::string _wcKey = "P11N0:SALOME";
std::string _walltime = "01:00:00";
}; };
#endif #endif

View File

@ -188,3 +188,21 @@ char* SMESH_ParallelMesh_i::GetWcKey(){
void SMESH_ParallelMesh_i::SetWcKey(const char* wcKey){ void SMESH_ParallelMesh_i::SetWcKey(const char* wcKey){
DownCast()->SetWcKey(std::string(wcKey)); DownCast()->SetWcKey(std::string(wcKey));
} }
//=============================================================================
/*!
* \brief Get the walltime to use on ressource
*/
//=============================================================================
char* SMESH_ParallelMesh_i::GetWalltime(){
return CORBA::string_dup(DownCast()->GetWalltime().c_str());
}
//=============================================================================
/*!
* \brief Set the walltime to use on ressource
*/
//=============================================================================
void SMESH_ParallelMesh_i::SetWalltime(const char* walltime){
DownCast()->SetWalltime(std::string(walltime));
}

View File

@ -71,6 +71,9 @@ class SMESH_I_EXPORT SMESH_ParallelMesh_i:
char* GetWcKey(); char* GetWcKey();
void SetWcKey(const char* wcKey); void SetWcKey(const char* wcKey);
char* GetWalltime();
void SetWalltime(const char* walltime);
private: private:
::SMESH_ParallelMesh* DownCast(); ::SMESH_ParallelMesh* DownCast();
}; };

View File

@ -22,7 +22,6 @@
""" """
File to run mesher from command line File to run mesher from command line
""" """
#TODO: Make the execution path independant (output files are written in current directory)
from os import environ, path from os import environ, path
import sys import sys
import subprocess as sp import subprocess as sp
@ -157,6 +156,7 @@ def run_pylauncher(args):
job_params.resource_required.nb_proc = args.nb_proc job_params.resource_required.nb_proc = args.nb_proc
job_params.resource_required.nb_proc_per_node = args.nb_proc_per_node job_params.resource_required.nb_proc_per_node = args.nb_proc_per_node
job_params.resource_required.nb_node = args.nb_node job_params.resource_required.nb_node = args.nb_node
job_params.maximum_duration = args.walltime
# job_params.pre_command = pre_command # command to run on frontal # job_params.pre_command = pre_command # command to run on frontal
# script to run in batch mode # script to run in batch mode
@ -241,6 +241,13 @@ def run_pylauncher(args):
launcher.getJobResults(job_id, "") launcher.getJobResults(job_id, "")
# Delete remote working dir # Delete remote working dir
del_tmp_folder = True
try:
val = int(environ.get("SMESH_KEEP_TMP", "0"))
del_tmp_folder = val > 0
except Exception as e:
del_tmp_folder = True
launcher.clearJobWorkingDir(job_id) launcher.clearJobWorkingDir(job_id)
def def_arg(): def def_arg():
@ -291,6 +298,9 @@ def def_arg():
default=1, default=1,
type=int, type=int,
help="Number of node") help="Number of node")
run_param.add_argument("--walltime",
default="01:00:00",
help="walltime for job submission HH:MM:SS (default 01:00:00)")
run_param.add_argument("--wc-key", run_param.add_argument("--wc-key",
default="P11N0:SALOME", default="P11N0:SALOME",
help="wc-key for job submission (default P11N0:SALOME)") help="wc-key for job submission (default P11N0:SALOME)")

View File

@ -7755,6 +7755,14 @@ class MNParallelismSettings(ParallelismSettings):
""" Get Number of Node """ """ Get Number of Node """
return self._mesh.mesh.GetWcKey() return self._mesh.mesh.GetWcKey()
def SetWalltime(self, walltime):
""" Set the number of Node for multinode """
self._mesh.mesh.SetWalltime(walltime)
def GetWalltime(self):
""" Get Number of Node """
return self._mesh.mesh.GetWalltime()
def __str__(self): def __str__(self):
""" str conversion """ """ str conversion """
string = "\nParameter for MultiNode parallelism:\n" string = "\nParameter for MultiNode parallelism:\n"
@ -7763,6 +7771,7 @@ class MNParallelismSettings(ParallelismSettings):
string += "NbProcPerNode: {}\n".format(self.GetNbProcPerNode()) string += "NbProcPerNode: {}\n".format(self.GetNbProcPerNode())
string += "NbNode: {}\n".format(self.GetNbNode()) string += "NbNode: {}\n".format(self.GetNbNode())
string += "WcKey: {}\n".format(self.GetWcKey()) string += "WcKey: {}\n".format(self.GetWcKey())
string += "Walltime: {}\n".format(self.GetWalltime())
return string return string