X-Git-Url: http://git.salome-platform.org/gitweb/?a=blobdiff_plain;f=src%2Fengine%2FPlayGround.cxx;h=506e6603593e54961e4e1d5a5e0d1c21ab8c841d;hb=255150e4eec79294bbd06c7c464f309b4a264960;hp=fb526134fd2ea03fe9cf8ccb0b45c925c027ba33;hpb=3209150c707d44744200738cdc69f844840da5a9;p=modules%2Fyacs.git diff --git a/src/engine/PlayGround.cxx b/src/engine/PlayGround.cxx index fb526134f..506e66035 100644 --- a/src/engine/PlayGround.cxx +++ b/src/engine/PlayGround.cxx @@ -1,4 +1,4 @@ -// Copyright (C) 2006-2019 CEA/DEN, EDF R&D +// Copyright (C) 2006-2023 CEA, EDF // // This library is free software; you can redistribute it and/or // modify it under the terms of the GNU Lesser General Public @@ -25,6 +25,7 @@ #include #include #include +#include #include using namespace YACS::ENGINE; @@ -86,6 +87,18 @@ std::size_t Resource::getNumberOfWorkers(int nbCoresPerCont) const return static_cast(this->nbCores())/static_cast(nbCoresPerCont); } +void Resource::printSelf(std::ostream& oss) const +{ + oss << this->name() << " (" << this->nbCores() << ") : "; + for(auto it : this->_occupied) + { + if(it) + oss << "1"; + else + oss << "0"; + } +} + std::string PlayGround::printSelf() const { std::ostringstream oss; @@ -182,7 +195,7 @@ std::vector PlayGround::allocateFor(std::size_t nbOfPlacesToTake, i { std::vector ret; std::size_t nbOfPlacesToTakeCpy(nbOfPlacesToTake),offset(0); - for(auto res : _data) + for(const auto& res : _data) { std::vector contIdsInRes(res.allocateFor(nbOfPlacesToTakeCpy,nbCoresPerCont)); std::for_each(contIdsInRes.begin(),contIdsInRes.end(),[offset](std::size_t& val) { val += offset; }); @@ -197,7 +210,7 @@ std::vector PlayGround::allocateFor(std::size_t nbOfPlacesToTake, i void PlayGround::release(std::size_t workerId, int nbCoresPerCont) const { std::size_t offset(0); - for(auto res : _data) + for(const auto& res : _data) { std::size_t nbOfWorker(static_cast(res.nbCores()/nbCoresPerCont)); std::size_t minId(offset),maxId(offset+nbOfWorker); @@ -209,6 +222,15 @@ void PlayGround::release(std::size_t workerId, int nbCoresPerCont) const } } +void PlayGround::printMe() const +{ + for(auto it : _data) + { + it.printSelf(std::cout); + std::cout << std::endl; + } +} + std::vector PlayGround::BuildVectOfIdsFromVecBool(const std::vector& v) { std::size_t sz(std::count(v.begin(),v.end(),true)),i(0);