From: Frederic Suter Date: Mon, 1 Mar 2021 22:49:48 +0000 (+0100) Subject: add core_count setter X-Git-Tag: v3.27~277 X-Git-Url: http://bilbo.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/8ac7aaeb3cbf0311bceae43a8a6f7a550993413d add core_count setter --- diff --git a/include/simgrid/s4u/Host.hpp b/include/simgrid/s4u/Host.hpp index 6988a6ff9d..f50f1484b7 100644 --- a/include/simgrid/s4u/Host.hpp +++ b/include/simgrid/s4u/Host.hpp @@ -128,8 +128,11 @@ public: * This accounts for external load (see @ref simgrid::surf::Cpu::set_speed_profile()). */ double get_available_speed() const; + /** Returns the number of core of the processor. */ int get_core_count() const; + Host* set_core_count(int core_count); + /** Returns the current computation load (in flops per second) * * The external load (coming from an availability trace) is not taken in account. diff --git a/src/s4u/s4u_Host.cpp b/src/s4u/s4u_Host.cpp index 39234b52f9..1036f39880 100644 --- a/src/s4u/s4u_Host.cpp +++ b/src/s4u/s4u_Host.cpp @@ -251,6 +251,12 @@ int Host::get_core_count() const return this->pimpl_cpu->get_core_count(); } +Host* Host::set_core_count(int core_count) +{ + this->pimpl_cpu->set_core_count(core_count); + return this; +} + /** @brief Set the pstate at which the host should run */ void Host::set_pstate(int pstate_index) { diff --git a/src/surf/cpu_interface.cpp b/src/surf/cpu_interface.cpp index 3687e16c0b..cd1fa08b75 100644 --- a/src/surf/cpu_interface.cpp +++ b/src/surf/cpu_interface.cpp @@ -129,6 +129,13 @@ void Cpu::on_speed_change() s4u::Host::on_speed_change(*host_); } +Cpu* Cpu::set_core_count(int core_count) +{ + xbt_assert(core_count > 0, "Host %s must have at least one core, not 0.", host_->get_cname()); + core_count_ = core_count; + return this; +} + int Cpu::get_core_count() { return core_count_; diff --git a/src/surf/cpu_interface.hpp b/src/surf/cpu_interface.hpp index 37202d316b..fa856e7f20 100644 --- a/src/surf/cpu_interface.hpp +++ b/src/surf/cpu_interface.hpp @@ -112,6 +112,7 @@ public: */ virtual CpuAction* sleep(double duration) = 0; + Cpu* set_core_count(int core_count); /** @brief Get the amount of cores */ virtual int get_core_count();