Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
add core_count setter
authorFrederic Suter <frederic.suter@cc.in2p3.fr>
Mon, 1 Mar 2021 22:49:48 +0000 (23:49 +0100)
committerFrederic Suter <frederic.suter@cc.in2p3.fr>
Tue, 2 Mar 2021 18:52:28 +0000 (19:52 +0100)
include/simgrid/s4u/Host.hpp
src/s4u/s4u_Host.cpp
src/surf/cpu_interface.cpp
src/surf/cpu_interface.hpp

index 6988a6f..f50f148 100644 (file)
@@ -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.
index 39234b5..1036f39 100644 (file)
@@ -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)
 {
index 3687e16..cd1fa08 100644 (file)
@@ -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_;
index 37202d3..fa856e7 100644 (file)
@@ -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();