From 606d6a265bd69bf1dae465ac59ab45f8a97dd0a1 Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Tue, 23 Jan 2018 15:14:37 +0100 Subject: [PATCH] Add parameters 'partition' and 'nodes' for slurm jobs. --- idl/SALOME_Launcher.idl | 7 ++++++- idl/SALOME_ResourcesManager.idl | 2 +- src/Launcher/Launcher_Job.cxx | 20 ++++++++++++++++++++ src/Launcher/Launcher_Job.hxx | 3 +++ src/Launcher/Launcher_XML_Persistence.cxx | 4 ++++ src/Launcher/SALOME_Launcher.cxx | 5 +++++ src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py | 4 ++-- 7 files changed, 41 insertions(+), 4 deletions(-) diff --git a/idl/SALOME_Launcher.idl b/idl/SALOME_Launcher.idl index ca8a0248c..2506fa52e 100644 --- a/idl/SALOME_Launcher.idl +++ b/idl/SALOME_Launcher.idl @@ -138,7 +138,12 @@ struct JobParameters //! Name of the batch queue chosen - optional string queue; - + + //! Name of the partition - optional + /*! It can be used only for slurm batch managers. + */ + string partition; + //! Specifies if the job must run in exclusive mode (without sharing nodes with other jobs) boolean exclusive; diff --git a/idl/SALOME_ResourcesManager.idl b/idl/SALOME_ResourcesManager.idl index 4884233bd..61c93a0ba 100644 --- a/idl/SALOME_ResourcesManager.idl +++ b/idl/SALOME_ResourcesManager.idl @@ -89,7 +89,7 @@ to map segment from shared object: Cannot allocate memory long mem_mb; //! required frequency long cpu_clock; - //! required number of nodes + //! required number of nodes. Can be used when submitting slurm jobs. long nb_node; //! required number of proc per node long nb_proc_per_node; diff --git a/src/Launcher/Launcher_Job.cxx b/src/Launcher/Launcher_Job.cxx index e98e0f204..0c4e3ce7e 100644 --- a/src/Launcher/Launcher_Job.cxx +++ b/src/Launcher/Launcher_Job.cxx @@ -48,6 +48,7 @@ Launcher::Job::Job() _maximum_duration = ""; _maximum_duration_in_second = -1; _queue = ""; + _partition = ""; _job_type = ""; _exclusive = false; _mem_per_cpu = 0; @@ -307,6 +308,12 @@ Launcher::Job::setQueue(const std::string & queue) _queue = queue; } +void +Launcher::Job::setPartition(const std::string & partition) +{ + _partition = partition; +} + void Launcher::Job::setExclusive(bool exclusive) { @@ -408,6 +415,12 @@ Launcher::Job::getQueue() const return _queue; } +std::string +Launcher::Job::getPartition() const +{ + return _partition; +} + bool Launcher::Job::getExclusive() const { @@ -585,6 +598,9 @@ Launcher::Job::common_job_params() params[Batch::NBPROC] = _resource_required_params.nb_proc; params[Batch::NBPROCPERNODE] = _resource_required_params.nb_proc_per_node; + if(_resource_required_params.nb_node > 0) + params[Batch::NBNODE] = _resource_required_params.nb_node; + // Memory in megabytes if (_resource_required_params.mem_mb > 0) { @@ -693,6 +709,10 @@ Launcher::Job::common_job_params() if (_queue != "") params[Batch::QUEUE] = _queue; + // Partition + if (_partition != "") + params[Batch::PARTITION] = _partition; + // Exclusive if (getExclusive()) params[Batch::EXCLUSIVE] = true; diff --git a/src/Launcher/Launcher_Job.hxx b/src/Launcher/Launcher_Job.hxx index 8531cd1c0..44d5f75fe 100644 --- a/src/Launcher/Launcher_Job.hxx +++ b/src/Launcher/Launcher_Job.hxx @@ -76,6 +76,7 @@ namespace Launcher void setMaximumDuration(const std::string & maximum_duration); void setResourceRequiredParams(const resourceParams & resource_required_params); void setQueue(const std::string & queue); + void setPartition(const std::string & partition); void setEnvFile(const std::string & env_file); void setExclusive(bool exclusive); void setExclusiveStr(const std::string & exclusiveStr); @@ -98,6 +99,7 @@ namespace Launcher std::string getMaximumDuration() const; resourceParams getResourceRequiredParams() const; std::string getQueue() const; + std::string getPartition() const; std::string getEnvFile() const; std::string getJobType() const; bool getExclusive() const; @@ -160,6 +162,7 @@ namespace Launcher long _maximum_duration_in_second; resourceParams _resource_required_params; std::string _queue; + std::string _partition; bool _exclusive; unsigned long _mem_per_cpu; std::string _wckey; diff --git a/src/Launcher/Launcher_XML_Persistence.cxx b/src/Launcher/Launcher_XML_Persistence.cxx index eb7775e5a..8da040423 100644 --- a/src/Launcher/Launcher_XML_Persistence.cxx +++ b/src/Launcher/Launcher_XML_Persistence.cxx @@ -196,6 +196,8 @@ XML_Persistence::addJobToXmlDocument(xmlNodePtr root_node, const Job & job) addNode(node, "maximum_duration", job.getMaximumDuration()); if (!job.getQueue().empty()) addNode(node, "queue", job.getQueue()); + if (!job.getPartition().empty()) + addNode(node, "partition", job.getPartition()); if (job.getExclusive()) addNode(node, "exclusive", job.getExclusiveStr()); if (job.getMemPerCpu() > 0) @@ -336,6 +338,8 @@ XML_Persistence::parseUserNode(Job * new_job, xmlNodePtr user_node) new_job->setMaximumDuration(getNodeContent(current_node)); else if (node_name == "queue") new_job->setQueue(getNodeContent(current_node)); + else if (node_name == "partition") + new_job->setPartition(getNodeContent(current_node)); else if (node_name == "exclusive") new_job->setExclusiveStr(getNodeContent(current_node)); else if (node_name == "mem_per_cpu") diff --git a/src/Launcher/SALOME_Launcher.cxx b/src/Launcher/SALOME_Launcher.cxx index 39447a7fd..8849b855e 100644 --- a/src/Launcher/SALOME_Launcher.cxx +++ b/src/Launcher/SALOME_Launcher.cxx @@ -164,6 +164,10 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters) std::string queue = job_parameters.queue.in(); new_job->setQueue(queue); + // Partition + std::string partition = job_parameters.partition.in(); + new_job->setPartition(partition); + // Exclusive new_job->setExclusive(job_parameters.exclusive); @@ -544,6 +548,7 @@ SALOME_Launcher::getJobParameters(CORBA::Long job_id) job_parameters->maximum_duration = CORBA::string_dup(job->getMaximumDuration().c_str()); job_parameters->queue = CORBA::string_dup(job->getQueue().c_str()); + job_parameters->partition = CORBA::string_dup(job->getPartition().c_str()); job_parameters->exclusive = job->getExclusive(); job_parameters->mem_per_cpu = job->getMemPerCpu(); job_parameters->wckey = CORBA::string_dup(job->getWCKey().c_str()); diff --git a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py index bfb357a79..d7f4e634f 100644 --- a/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py +++ b/src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py @@ -60,7 +60,7 @@ class ResourceParameters (Engines.ResourceParameters): class JobParameters (Engines.JobParameters): def __init__(self, job_name="", job_type="", job_file="", pre_command="", env_file="", in_files=None, out_files=None, work_directory="", local_directory="", result_directory="", maximum_duration="", - resource_required=None, queue="", exclusive = False, mem_per_cpu = 0, + resource_required=None, queue="", partition="", exclusive = False, mem_per_cpu = 0, wckey = "", extra_params = "", specific_parameters=None, launcher_file = "", launcher_args = ""): if in_files is None: @@ -71,7 +71,7 @@ class JobParameters (Engines.JobParameters): specific_parameters = [] Engines.JobParameters.__init__(self, job_name, job_type, job_file, pre_command, env_file, in_files, out_files, work_directory, local_directory, result_directory, maximum_duration, - resource_required, queue, exclusive, mem_per_cpu, + resource_required, queue, partition, exclusive, mem_per_cpu, wckey, extra_params, specific_parameters, launcher_file, launcher_args) -- 2.39.2