Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
convert some C bits into C++ in surf
authorMartin Quinson <martin.quinson@loria.fr>
Tue, 5 Jan 2016 00:05:59 +0000 (01:05 +0100)
committerMartin Quinson <martin.quinson@loria.fr>
Tue, 5 Jan 2016 00:05:59 +0000 (01:05 +0100)
include/simgrid/Host.hpp
include/simgrid/host.h
src/msg/msg_host.cpp
src/simdag/sd_workstation.cpp
src/simgrid/host.cpp

index 2810c16..99494dc 100644 (file)
 #include <xbt/string.hpp>
 #include <xbt/Extendable.hpp>
 
+
 namespace simgrid {
 
 XBT_PUBLIC_CLASS Host :
 public simgrid::xbt::Extendable<Host> {
 
 public:
-         surf::Cpu     *p_cpu = nullptr;
-         surf::NetCard *p_netcard = nullptr;
+       double getSpeed();
+       int getCoreAmount();
 
+       /* FIXME: these should be protected, but it leads to many errors */
+       surf::Cpu     *p_cpu = nullptr;
+       surf::NetCard *p_netcard = nullptr;
 private:
   simgrid::xbt::string name_ = "noname";
 public:
index 87abdf2..cd948d6 100644 (file)
@@ -55,9 +55,7 @@ XBT_PUBLIC(void) sg_host_simix_destroy(sg_host_t host);
 XBT_PUBLIC(void) sg_host_init(void);
 
 // =========== user-level functions ===============
-XBT_PUBLIC(double) sg_host_get_speed(sg_host_t host);
 XBT_PUBLIC(double) sg_host_get_available_speed(sg_host_t host);
-XBT_PUBLIC(int) sg_host_get_core(sg_host_t host);
 XBT_PUBLIC(int) sg_host_get_state(sg_host_t host);
 
 XBT_PUBLIC(int) sg_host_get_nb_pstates(sg_host_t host);
index c6a6e3e..db76c66 100644 (file)
@@ -214,11 +214,8 @@ xbt_dynar_t MSG_hosts_as_dynar(void) {
  * \brief Return the speed of the processor (in flop/s), regardless of 
     the current load on the machine.
  */
-double MSG_get_host_speed(msg_host_t h)
-{
-  xbt_assert((h != NULL), "Invalid parameters");
-
-  return sg_host_get_speed(h);
+double MSG_get_host_speed(msg_host_t host) {
+  return host->getSpeed();
 }
 
 
@@ -228,11 +225,8 @@ double MSG_get_host_speed(msg_host_t h)
  * \param host a host
  * \return the number of cores
  */
-int MSG_host_get_core_number(msg_host_t host)
-{
-  xbt_assert((host != NULL), "Invalid parameters");
-
-  return sg_host_get_core(host);
+int MSG_host_get_core_number(msg_host_t host) {
+  return host->getCoreAmount();
 }
 
 /** \ingroup m_host_management
index 6a98441..b43f8ab 100644 (file)
@@ -6,7 +6,7 @@
 
 #include "src/simdag/simdag_private.h"
 #include "simgrid/simdag.h"
-#include "simgrid/host.h"
+#include "simgrid/Host.hpp"
 #include "xbt/dict.h"
 #include "xbt/lib.h"
 #include "xbt/sysdep.h"
@@ -255,7 +255,7 @@ int SD_route_get_size(SD_workstation_t src, SD_workstation_t dst)
  */
 double SD_workstation_get_power(SD_workstation_t workstation)
 {
-  return sg_host_get_speed(workstation);
+  return workstation->getSpeed();
 }
 /**
  * \brief Returns the amount of cores of a workstation
@@ -264,7 +264,7 @@ double SD_workstation_get_power(SD_workstation_t workstation)
  * \return the amount of cores of this workstation
  */
 int SD_workstation_get_cores(SD_workstation_t workstation) {
-  return sg_host_get_core(workstation);
+  return workstation->getCoreAmount();
 }
 
 /**
index 5c881b0..5efe860 100644 (file)
@@ -126,18 +126,10 @@ void sg_host_simix_destroy(sg_host_t host) {
 
 // =========== user-level functions ===============
 // ================================================
-/** @brief Get the speed of the cpu associated to a host */
-double sg_host_get_speed(sg_host_t host){
-       return host->p_cpu->getSpeed(1.0);
-}
 
 double sg_host_get_available_speed(sg_host_t host){
   return surf_host_get_available_speed(host);
 }
-/** @brief Returns the number of core of the processor. */
-int sg_host_get_core(sg_host_t host) {
-       return host->p_cpu->getCore();
-}
 /** @brief Returns the state of a host.
  *  @return 1 if the host is active or 0 if it has crashed.
  */
@@ -180,6 +172,15 @@ Host::~Host()
 {
 }
 
+/** @brief Get the speed of the cpu associated to a host */
+double Host::getSpeed() {
+       return p_cpu->getSpeed(1.0);
+}
+/** @brief Returns the number of core of the processor. */
+int Host::getCoreAmount() {
+       return p_cpu->getCore();
+}
+
 Host* Host::by_name_or_null(const char* name)
 {
   return (Host*) xbt_dict_get_or_null(host_list, name);