From 2767270bb701bd3a93be3480eb9820110342df5b Mon Sep 17 00:00:00 2001 From: Ovidiu Mircescu Date: Mon, 11 May 2020 12:09:52 +0200 Subject: [PATCH] Work in progress : workload manager uses nb_parallel_procs. --- src/engine/Executor.cxx | 8 +++++--- src/engine/Test/RuntimeForEngineIntegrationTest.cxx | 8 +------- src/engine/Test/RuntimeForEngineTest.cxx | 8 +------- src/workloadmanager/DefaultAlgorithm.cxx | 11 ++++++++++- src/workloadmanager/DefaultAlgorithm.hxx | 2 ++ src/workloadmanager/Test/TestMain.cxx | 2 +- 6 files changed, 20 insertions(+), 19 deletions(-) diff --git a/src/engine/Executor.cxx b/src/engine/Executor.cxx index 453eed195..5f18fff1d 100644 --- a/src/engine/Executor.cxx +++ b/src/engine/Executor.cxx @@ -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 { diff --git a/src/engine/Test/RuntimeForEngineIntegrationTest.cxx b/src/engine/Test/RuntimeForEngineIntegrationTest.cxx index a9ae6e2b4..dcb4161ee 100644 --- a/src/engine/Test/RuntimeForEngineIntegrationTest.cxx +++ b/src/engine/Test/RuntimeForEngineIntegrationTest.cxx @@ -36,13 +36,7 @@ void RuntimeForEngineIntegrationTest::setRuntime() std::vector< std::pair > RuntimeForEngineIntegrationTest::getCatalogOfComputeNodes() const { - std::vector< std::pair > result(1); - std::pair localhost; - localhost.first = "localhost"; - localhost.second = 8; - result[0] = localhost; - return result; -// throw Exception("RuntimeForEngineTest::getCatalogOfComputeNodes : not implemented !"); + return std::vector< std::pair >(); } ElementaryNode* RuntimeForEngineIntegrationTest::createNode(const std::string& implementation, const std::string& name) diff --git a/src/engine/Test/RuntimeForEngineTest.cxx b/src/engine/Test/RuntimeForEngineTest.cxx index 4058da812..429238302 100644 --- a/src/engine/Test/RuntimeForEngineTest.cxx +++ b/src/engine/Test/RuntimeForEngineTest.cxx @@ -115,13 +115,7 @@ void RuntimeForEngineTest::setRuntime() std::vector< std::pair > RuntimeForEngineTest::getCatalogOfComputeNodes() const { - std::vector< std::pair > result(1); - std::pair localhost; - localhost.first = "localhost"; - localhost.second = 8; - result[0] = localhost; - return result; -// throw Exception("RuntimeForEngineTest::getCatalogOfComputeNodes : not implemented !"); + return std::vector< std::pair >(); } ElementaryNode* RuntimeForEngineTest::createNode(const string& implementation, const string& name) diff --git a/src/workloadmanager/DefaultAlgorithm.cxx b/src/workloadmanager/DefaultAlgorithm.cxx index dbe588807..962c8dbf8 100644 --- a/src/workloadmanager/DefaultAlgorithm.cxx +++ b/src/workloadmanager/DefaultAlgorithm.cxx @@ -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::iterator it = std::find(_ctypes.begin(), _ctypes.end(), ctype); diff --git a/src/workloadmanager/DefaultAlgorithm.hxx b/src/workloadmanager/DefaultAlgorithm.hxx index 2e58c66c5..dc9c3dd4e 100644 --- a/src/workloadmanager/DefaultAlgorithm.hxx +++ b/src/workloadmanager/DefaultAlgorithm.hxx @@ -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 _ctypes; }; diff --git a/src/workloadmanager/Test/TestMain.cxx b/src/workloadmanager/Test/TestMain.cxx index daf621e14..b299f0684 100644 --- a/src/workloadmanager/Test/TestMain.cxx +++ b/src/workloadmanager/Test/TestMain.cxx @@ -34,7 +34,7 @@ #include "../WorkloadManager.hxx" #include "../DefaultAlgorithm.hxx" -constexpr bool ACTIVATE_DEBUG_LOG = true; +constexpr bool ACTIVATE_DEBUG_LOG = false; template void DEBUG_LOG(Ts... args) { -- 2.39.2