Salome HOME
Work in progress : workload manager uses nb_parallel_procs.
authorOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Mon, 11 May 2020 10:09:52 +0000 (12:09 +0200)
committerOvidiu Mircescu <ovidiu.mircescu@edf.fr>
Mon, 11 May 2020 10:09:52 +0000 (12:09 +0200)
src/engine/Executor.cxx
src/engine/Test/RuntimeForEngineIntegrationTest.cxx
src/engine/Test/RuntimeForEngineTest.cxx
src/workloadmanager/DefaultAlgorithm.cxx
src/workloadmanager/DefaultAlgorithm.hxx
src/workloadmanager/Test/TestMain.cxx

index 453eed195b4f2b324b5fc5c27b3f42c30f9915c9..5f18fff1d75d3e5d3c9e9dde1eba9ab68957ba64 100644 (file)
@@ -1682,8 +1682,6 @@ void loadResources(WorkloadManager::WorkloadManager& wm)
     id++;
     newResource.nbCores = res.second;
     wm.addResource(newResource);
-    std::cerr << "Add resource " << newResource.name << " with "
-              << newResource.nbCores << " cores." << std::endl;
   }
 }
 
@@ -1709,7 +1707,11 @@ NewTask::NewTask(Executor& executor, YACS::ENGINE::Task* yacsTask)
   {
     _type.ignoreResources = false;
     _type.name = yacsContainer->getName();
-    _type.neededCores = 1; // TODO: use the actual value
+    std::string nb_procs_str = yacsContainer->getProperty("nb_parallel_procs");
+    float needed_cores = 0.0;
+    if(!nb_procs_str.empty())
+      needed_cores = std::stof(nb_procs_str);
+    _type.neededCores = needed_cores;
   }
   else
   {
index a9ae6e2b442c8aa166dd9beca6e081595c05bae6..dcb4161eedd98105fc5e9bc03a48b76a9c079e3f 100644 (file)
@@ -36,13 +36,7 @@ void RuntimeForEngineIntegrationTest::setRuntime()
 
 std::vector< std::pair<std::string,int> > RuntimeForEngineIntegrationTest::getCatalogOfComputeNodes() const
 {
-  std::vector< std::pair<std::string,int> > result(1);
-  std::pair<std::string,int> localhost;
-  localhost.first = "localhost";
-  localhost.second = 8;
-  result[0] = localhost;
-  return result;
-//  throw Exception("RuntimeForEngineTest::getCatalogOfComputeNodes : not implemented !");
+  return std::vector< std::pair<std::string,int> >();
 }
 
 ElementaryNode* RuntimeForEngineIntegrationTest::createNode(const std::string& implementation, const std::string& name)
index 4058da812c4ab5c36119bdcc92c1847b9d3d830f..42923830254adff516b865d47b5608d04f101fd4 100644 (file)
@@ -115,13 +115,7 @@ void RuntimeForEngineTest::setRuntime()
 
 std::vector< std::pair<std::string,int> > RuntimeForEngineTest::getCatalogOfComputeNodes() const
 {
-  std::vector< std::pair<std::string,int> > result(1);
-  std::pair<std::string,int> localhost;
-  localhost.first = "localhost";
-  localhost.second = 8;
-  result[0] = localhost;
-  return result;
-//  throw Exception("RuntimeForEngineTest::getCatalogOfComputeNodes : not implemented !");
+  return std::vector< std::pair<std::string,int> >();
 }
 
 ElementaryNode* RuntimeForEngineTest::createNode(const string& implementation, const string& name) 
index dbe588807c1f8943c3ba8668da7d8dd728040810..962c8dbf88da077c4b1a90690bf93e05a5fda848 100644 (file)
@@ -170,6 +170,7 @@ bool DefaultAlgorithm::ResourceInfoForContainer::isContainerRunning
 DefaultAlgorithm::ResourceLoadInfo::ResourceLoadInfo(const Resource& r)
 : _resource(r)
 , _load(0.0)
+, _loadCost(0.0)
 , _ctypes()
 {
 }
@@ -189,7 +190,7 @@ bool DefaultAlgorithm::ResourceLoadInfo::isAllocPossible
 float DefaultAlgorithm::ResourceLoadInfo::cost
                                 (const ContainerType& ctype)const
 {
-  return _load * 100.0 / float(_resource.nbCores);
+  return _loadCost * 100.0 / float(_resource.nbCores);
 }
 
 unsigned int DefaultAlgorithm::ResourceLoadInfo::alloc
@@ -206,6 +207,10 @@ unsigned int DefaultAlgorithm::ResourceLoadInfo::alloc
     it--;
   }
   _load += ctype.neededCores;
+  if(ctype.neededCores == 0)
+    _loadCost += COST_FOR_0_CORE_TASKS;
+  else
+    _loadCost += ctype.neededCores;
   return it->alloc();
 }
 
@@ -213,6 +218,10 @@ void DefaultAlgorithm::ResourceLoadInfo::free
                                 (const ContainerType& ctype, int index)
 {
   _load -= ctype.neededCores;
+  if(ctype.neededCores == 0)
+    _loadCost -= COST_FOR_0_CORE_TASKS;
+  else
+    _loadCost -= ctype.neededCores;
   std::list<ResourceInfoForContainer>::iterator it = std::find(_ctypes.begin(),
                                                                _ctypes.end(),
                                                                ctype);
index 2e58c66c50be69d8f30edb1058e980908cff7897..dc9c3dd4e4bdb6effac540d93136df024284d17d 100644 (file)
@@ -75,9 +75,11 @@ private:
     bool operator==(const Resource& other)const
     { return _resource == other;}
     const Resource& resource()const { return _resource;}
+    float COST_FOR_0_CORE_TASKS = 1.0 / 4096.0 ;
   private:
     Resource _resource;
     float _load;
+    float _loadCost;
     std::list<ResourceInfoForContainer> _ctypes;
   };
   
index daf621e1458ad9e8488580447d5dce676edf217d..b299f06840bf2687f251e6ae8c8f872c326582e2 100644 (file)
@@ -34,7 +34,7 @@
 #include "../WorkloadManager.hxx"
 #include "../DefaultAlgorithm.hxx"
 
-constexpr bool ACTIVATE_DEBUG_LOG = true;
+constexpr bool ACTIVATE_DEBUG_LOG = false;
 template<typename... Ts>
 void DEBUG_LOG(Ts... args)
 {