]> SALOME platform Git repositories - modules/kernel.git/commitdiff
Salome HOME
Add job parameter mem_per_cpu (EDF issue #2671)
authorbarate <barate>
Mon, 23 Sep 2013 13:29:19 +0000 (13:29 +0000)
committerbarate <barate>
Mon, 23 Sep 2013 13:29:19 +0000 (13:29 +0000)
idl/SALOME_Launcher.idl
src/Launcher/Launcher_Job.cxx
src/Launcher/Launcher_Job.hxx
src/Launcher/SALOME_Launcher.cxx
src/LifeCycleCORBA_SWIG/LifeCycleCORBA.py

index 8e8a014ed8bc4630277ffbb927db0836c34f0b8d..92ecccb1616ab16973e632d0d9e84d7a6e596911 100644 (file)
@@ -76,6 +76,9 @@ struct JobParameters
   //! Specifies if the job must run in exclusive mode (without sharing nodes with other jobs)
   boolean exclusive;
 
+  //! Specifies the memory limit per cpu (exclusive with resource_required.mem_mb)
+  unsigned long mem_per_cpu;
+
   /*!
     Specific parameters for each type of job - optional
   */
index 60e0dcba6637838b781c6a7278514b022325e781..7ca6fd6b6bd8e3d107a358465e0d1d35b819de9e 100644 (file)
@@ -26,6 +26,8 @@
 #include <libbatch/Constants.hxx>
 #endif
 
+using namespace std;
+
 Launcher::Job::Job()
 {
   _number = -1;
@@ -53,6 +55,7 @@ Launcher::Job::Job()
   _queue = "";
   _job_type = "";
   _exclusive = false;
+  _mem_per_cpu = 0;
 
   // Parameters for COORM
   _launcher_file = "";
@@ -324,6 +327,12 @@ Launcher::Job::setExclusiveStr(const std::string & exclusiveStr)
     throw LauncherException(std::string("Invalid boolean value for exclusive: ") + exclusiveStr);
 }
 
+void
+Launcher::Job::setMemPerCpu(unsigned long mem_per_cpu)
+{
+  _mem_per_cpu = mem_per_cpu;
+}
+
 std::string 
 Launcher::Job::getWorkDirectory()
 {
@@ -396,6 +405,12 @@ Launcher::Job::getExclusiveStr() const
   return _exclusive ? "true" : "false";
 }
 
+unsigned long
+Launcher::Job::getMemPerCpu() const
+{
+  return _mem_per_cpu;
+}
+
 void 
 Launcher::Job::checkMaximumDuration(const std::string & maximum_duration)
 {
@@ -530,6 +545,10 @@ Launcher::Job::common_job_params()
   {
     params[Batch::MAXRAMSIZE] = _resource_required_params.mem_mb;
   }
+  else if (_mem_per_cpu > 0)
+  {
+    params[Batch::MEMPERCPU] = (long)_mem_per_cpu;
+  }
 
   // We define a default directory based on user time
   if (_work_directory == "")
@@ -683,6 +702,9 @@ Launcher::Job::addToXmlDocument(xmlNodePtr root_node)
   xmlNewChild(node, NULL, xmlCharStrdup("maximum_duration"), xmlCharStrdup(getMaximumDuration().c_str()));
   xmlNewChild(node, NULL, xmlCharStrdup("queue"),            xmlCharStrdup(getQueue().c_str()));
   xmlNewChild(node, NULL, xmlCharStrdup("exclusive"),        xmlCharStrdup(getExclusiveStr().c_str()));
+  ostringstream mem_per_cpu_stream;
+  mem_per_cpu_stream << _mem_per_cpu;
+  xmlNewChild(node, NULL, xmlCharStrdup("mem_per_cpu"),      xmlCharStrdup(mem_per_cpu_stream.str().c_str()));
 
   // For COORM
   xmlNewChild(node, NULL, xmlCharStrdup("launcher_args"), xmlCharStrdup(getLauncherArgs().c_str()));
index 39c999f1d5eb620ec2ea6b6570cb03fc1c2456b3..42ac55d0ebde87620bcd500b1e6dfbcc2097c592 100644 (file)
@@ -80,6 +80,7 @@ namespace Launcher
       void setEnvFile(const std::string & env_file);
       void setExclusive(bool exclusive);
       void setExclusiveStr(const std::string & exclusiveStr);
+      void setMemPerCpu(unsigned long mem_per_cpu);
          // For COORM
          void setLauncherFile(const std::string & launcher_file);
          void setLauncherArgs(const std::string & launcher_args);
@@ -98,6 +99,7 @@ namespace Launcher
       std::string getJobType();
       bool getExclusive();
       std::string getExclusiveStr() const;
+      unsigned long getMemPerCpu() const;
 
          // For COORM
          std::string getLauncherFile();
@@ -155,6 +157,7 @@ namespace Launcher
       resourceParams _resource_required_params;
       std::string _queue;
       bool _exclusive;
+      unsigned long _mem_per_cpu;
 
          // Parameters for COORM
          std::string _launcher_file;
index a0eb7e5f6f3d1c0d74dc3d29cb7e6c0575497e45..1832b963919ff78c14852f431cdfc6d26a9a38c7 100644 (file)
@@ -160,6 +160,9 @@ SALOME_Launcher::createJob(const Engines::JobParameters & job_parameters)
   // Exclusive
   new_job->setExclusive(job_parameters.exclusive);
 
+  // Memory required per CPU
+  new_job->setMemPerCpu(job_parameters.mem_per_cpu);
+
   // Resources requirements
   try
   {
@@ -496,6 +499,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->exclusive        = job->getExclusive();
+  job_parameters->mem_per_cpu      = job->getMemPerCpu();
 
   resourceParams resource_params = job->getResourceRequiredParams();
   job_parameters->resource_required.name             = CORBA::string_dup(resource_params.name.c_str());
@@ -714,11 +718,13 @@ SALOME_Launcher::loadJobs(const char* jobs_file)
         xmlNodePtr maximum_duration_node = xmlNextElementSibling(res_node);
         xmlNodePtr queue_node = xmlNextElementSibling(maximum_duration_node);
         xmlNodePtr exclusive_node = xmlNextElementSibling(queue_node);
-        xmlNodePtr launcher_args_node = xmlNextElementSibling(exclusive_node);
+        xmlNodePtr mem_per_cpu_node = xmlNextElementSibling(exclusive_node);
+        xmlNodePtr launcher_args_node = xmlNextElementSibling(mem_per_cpu_node);
         if (res_node              == NULL ||
             maximum_duration_node == NULL ||
             queue_node            == NULL ||
             exclusive_node        == NULL ||
+            mem_per_cpu_node      == NULL ||
                        // For COORM
             launcher_args_node    == NULL
            )
@@ -731,6 +737,7 @@ SALOME_Launcher::loadJobs(const char* jobs_file)
             xmlStrcmp(maximum_duration_node->name, xmlCharStrdup("maximum_duration")) ||
             xmlStrcmp(queue_node->name,            xmlCharStrdup("queue")) ||
             xmlStrcmp(exclusive_node->name,        xmlCharStrdup("exclusive")) ||
+            xmlStrcmp(mem_per_cpu_node->name,      xmlCharStrdup("mem_per_cpu")) ||
                        // For COORM
             xmlStrcmp(launcher_args_node->name,    xmlCharStrdup("launcher_args"))
            )
@@ -770,6 +777,18 @@ SALOME_Launcher::loadJobs(const char* jobs_file)
         }
         xmlFree(exclusive);
 
+        xmlChar* mem_per_cpu_str = xmlNodeGetContent(mem_per_cpu_node);
+        std::istringstream mem_per_cpu_stream((const char *)mem_per_cpu_str);
+        unsigned long mem_per_cpu = 0;
+        if (!(mem_per_cpu_stream >> mem_per_cpu))
+        {
+          INFOS("A bad job is found, mem_per_cpu parameter is not correct");
+          delete new_job;
+          break;
+        }
+        else
+          new_job->setMemPerCpu(mem_per_cpu);
+
                // For COORM
         xmlChar* launcher_args           = xmlNodeGetContent(launcher_args_node);
         new_job->setLauncherArgs(std::string((const char *)launcher_args));
index ad90b186eadfc7c65acbb8c697e2831d0dee20ac..f308536f1aeb2f10d8e022395d022fabe0208558 100644 (file)
@@ -56,12 +56,12 @@ class ResourceParameters (Engines.ResourceParameters):
 class JobParameters (Engines.JobParameters):
   def __init__(self, job_name="", job_type="", job_file="", env_file="", in_files=[], out_files=[],
                      work_directory="", local_directory="", result_directory="", maximum_duration="",
-                     resource_required=None, queue="", exclusive = False, specific_parameters=[],
-                     launcher_file = "", launcher_args = ""):
+                     resource_required=None, queue="", exclusive = False, mem_per_cpu = 0,
+                     specific_parameters=[], launcher_file = "", launcher_args = ""):
     Engines.JobParameters.__init__(self, job_name, job_type, job_file, env_file, in_files, out_files,
                                          work_directory, local_directory, result_directory, maximum_duration,
-                                         resource_required, queue, exclusive, specific_parameters,
-                                         launcher_file, launcher_args)
+                                         resource_required, queue, exclusive, mem_per_cpu,
+                                         specific_parameters, launcher_file, launcher_args)
 
 class ResourceDefinition(Engines.ResourceDefinition):
   def __init__(self, name="", hostname="", protocol="rsh", username="", applipath="", componentList=[],