]> SALOME platform Git repositories - modules/yacs.git/blobdiff - src/workloadmanager/DefaultAlgorithm.cxx
Salome HOME
Work in progress : workload manager uses nb_parallel_procs.
[modules/yacs.git] / src / workloadmanager / DefaultAlgorithm.cxx
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);