Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
include cleanups in src/s4u
[simgrid.git] / src / s4u / s4u_Host.cpp
index c06d170..7437ff7 100644 (file)
@@ -3,19 +3,19 @@
 /* This program is free software; you can redistribute it and/or modify it
  * under the terms of the license (GNU LGPL) which comes with this package. */
 
-#include "simgrid/Exception.hpp"
-#include "simgrid/host.h"
-#include "simgrid/kernel/routing/NetPoint.hpp"
-#include "simgrid/s4u/Actor.hpp"
-#include "simgrid/s4u/Comm.hpp"
-#include "simgrid/s4u/Engine.hpp"
-#include "simgrid/s4u/Exec.hpp"
-#include "simgrid/s4u/VirtualMachine.hpp"
+#include <simgrid/Exception.hpp>
+#include <simgrid/host.h>
+#include <simgrid/kernel/routing/NetPoint.hpp>
+#include <simgrid/s4u/Comm.hpp>
+#include <simgrid/s4u/Engine.hpp>
+#include <simgrid/s4u/Exec.hpp>
+#include <simgrid/s4u/Host.hpp>
+#include <simgrid/s4u/VirtualMachine.hpp>
+#include <xbt/parse_units.hpp>
+
 #include "src/plugins/vm/VirtualMachineImpl.hpp"
 #include "src/surf/HostImpl.hpp"
-#include "xbt/parse_units.hpp"
 
-#include <algorithm>
 #include <string>
 
 XBT_LOG_NEW_DEFAULT_SUBCATEGORY(s4u_host, s4u, "Logging specific to the S4U hosts");
@@ -126,7 +126,7 @@ bool Host::is_on() const
   return this->pimpl_cpu_->is_on();
 }
 
-int Host::get_pstate_count() const
+unsigned long Host::get_pstate_count() const
 {
   return this->pimpl_cpu_->get_pstate_count();
 }
@@ -154,7 +154,6 @@ size_t Host::get_actor_count() const
  * @param links [OUT] where to store the list of links (must exist, cannot be nullptr).
  * @param latency [OUT] where to store the latency experienced on the path (or nullptr if not interested)
  *                It is the caller responsibility to initialize latency to 0 (we add to provided route)
- * @pre links!=nullptr
  *
  * walk through the routing components tree and find a route between hosts
  * by calling each "get_route" function in each routing component.
@@ -246,7 +245,7 @@ Host* Host::set_speed_profile(kernel::profile::Profile* p)
 }
 
 /** @brief Get the peak processor speed (in flops/s), at the specified pstate  */
-double Host::get_pstate_speed(int pstate_index) const
+double Host::get_pstate_speed(unsigned long pstate_index) const
 {
   return this->pimpl_cpu_->get_pstate_peak_speed(pstate_index);
 }
@@ -264,6 +263,17 @@ double Host::get_available_speed() const
   return this->pimpl_cpu_->get_speed_ratio();
 }
 
+Host* Host::set_sharing_policy(SharingPolicy policy, const s4u::NonLinearResourceCb& cb)
+{
+  kernel::actor::simcall([this, policy, &cb] { pimpl_cpu_->set_sharing_policy(policy, cb); });
+  return this;
+}
+
+Host::SharingPolicy Host::get_sharing_policy() const
+{
+  return this->pimpl_cpu_->get_sharing_policy();
+}
+
 int Host::get_core_count() const
 {
   return this->pimpl_cpu_->get_core_count();
@@ -303,18 +313,24 @@ Host* Host::set_pstate_speed(const std::vector<std::string>& speed_per_state)
 }
 
 /** @brief Set the pstate at which the host should run */
-Host* Host::set_pstate(int pstate_index)
+Host* Host::set_pstate(unsigned long pstate_index)
 {
   kernel::actor::simcall([this, pstate_index] { this->pimpl_cpu_->set_pstate(pstate_index); });
   return this;
 }
 
 /** @brief Retrieve the pstate at which the host is currently running */
-int Host::get_pstate() const
+unsigned long Host::get_pstate() const
 {
   return this->pimpl_cpu_->get_pstate();
 }
 
+Host* Host::set_factor_cb(const std::function<CpuFactorCb>& cb)
+{
+  kernel::actor::simcall([this, &cb] { pimpl_cpu_->set_factor_cb(cb); });
+  return this;
+}
+
 Host* Host::set_coordinates(const std::string& coords)
 {
   if (not coords.empty())
@@ -496,7 +512,7 @@ double sg_host_speed(const_sg_host_t host) // XBT_ATTRIB_DEPRECATED_v330
  * @param pstate_index pstate to test
  * @return Returns the processor speed associated with pstate_index
  */
-double sg_host_get_pstate_speed(const_sg_host_t host, int pstate_index)
+double sg_host_get_pstate_speed(const_sg_host_t host, unsigned long pstate_index)
 {
   return host->get_pstate_speed(pstate_index);
 }
@@ -521,7 +537,7 @@ double sg_host_get_available_speed(const_sg_host_t host)
  *
  *  See also @ref plugin_host_energy.
  */
-int sg_host_get_nb_pstates(const_sg_host_t host)
+unsigned long sg_host_get_nb_pstates(const_sg_host_t host)
 {
   return host->get_pstate_count();
 }
@@ -530,7 +546,7 @@ int sg_host_get_nb_pstates(const_sg_host_t host)
  *
  *  See also @ref plugin_host_energy.
  */
-int sg_host_get_pstate(const_sg_host_t host)
+unsigned long sg_host_get_pstate(const_sg_host_t host)
 {
   return host->get_pstate();
 }
@@ -538,7 +554,7 @@ int sg_host_get_pstate(const_sg_host_t host)
  *
  *  See also @ref plugin_host_energy.
  */
-void sg_host_set_pstate(sg_host_t host, int pstate)
+void sg_host_set_pstate(sg_host_t host, unsigned long pstate)
 {
   host->set_pstate(pstate);
 }