Logo AND Algorithmique Numérique Distribuée

Public GIT Repository
Remove surf_host_* functions
authorGabriel Corona <gabriel.corona@loria.fr>
Tue, 12 Jan 2016 13:46:22 +0000 (14:46 +0100)
committerGabriel Corona <gabriel.corona@loria.fr>
Tue, 12 Jan 2016 14:06:55 +0000 (15:06 +0100)
They are just C wrappers around the C++ API.

src/include/surf/surf.h
src/simdag/sd_workstation.cpp
src/simgrid/host.cpp
src/simix/smx_host.cpp
src/surf/host_interface.cpp
src/surf/host_interface.hpp
src/surf/surf_c_bindings.cpp
src/surf/virtual_machine.cpp
src/surf/virtual_machine.hpp

index 84b400d..702678e 100644 (file)
@@ -197,8 +197,6 @@ typedef enum {
 
 XBT_PUBLIC_DATA(routing_platf_t) routing_platf;
 
-XBT_PUBLIC(surf_host_t) surf_host_resource_priv(sg_host_t host);
-
 static inline void *surf_storage_resource_priv(const void *storage){
   return (void*)xbt_lib_get_level((xbt_dictelm_t)storage, SURF_STORAGE_LEVEL);
 }
@@ -423,34 +421,6 @@ XBT_PUBLIC(void) surf_vm_set_bound(sg_host_t resource, double bound);
  */
 XBT_PUBLIC(void) surf_vm_set_affinity(sg_host_t resource, sg_host_t cpu, unsigned long mask);
 
-/**
- * @brief Get the host power peak
- * @details [long description]
- *
- * @param host The surf host
- * @return The power peak
- */
-XBT_PUBLIC(double) surf_host_get_current_power_peak(sg_host_t host);
-
-/**
- * @brief [brief description]
- * @details [long description]
- *
- * @param host [description]
- * @param pstate_index [description]
- *
- * @return [description]
- */
-XBT_PUBLIC(double) surf_host_get_power_peak_at(sg_host_t host, int pstate_index);
-
-/**
- * @brief Get the list of storages mounted on an host
- *
- * @param host The surf host
- * @return Dictionary of mount point, Storage
- */
-XBT_PUBLIC(xbt_dict_t) surf_host_get_mounted_storage_list(sg_host_t host);
-
 /**
  * @brief Get the list of storages attached to an host
  *
@@ -701,8 +671,6 @@ XBT_PUBLIC(xbt_dict_t) surf_storage_action_get_ls_dict(surf_action_t action);
  */
 XBT_PUBLIC(const char * ) surf_storage_get_host(surf_resource_t resource);
 
-XBT_PUBLIC(surf_host_model_t) surf_host_get_model(sg_host_t host);
-
 /** @} */
 
 /**************************************/
index b43f8ab..afbb210 100644 (file)
@@ -4,6 +4,7 @@
 /* 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 "src/surf/host_interface.hpp"
 #include "src/simdag/simdag_private.h"
 #include "simgrid/simdag.h"
 #include "simgrid/Host.hpp"
@@ -460,7 +461,7 @@ void SD_workstation_set_access_mode(SD_workstation_t workstation,
  * \return a dynar containing all mounted storages on the workstation
  */
 xbt_dict_t SD_workstation_get_mounted_storage_list(SD_workstation_t workstation){
-  return surf_host_get_mounted_storage_list(workstation);
+  return workstation->extension<simgrid::surf::Host>()->getMountedStorageList();
 }
 
 /**
index 482f21f..e5198ae 100644 (file)
@@ -216,15 +216,17 @@ xbt_swag_t Host::getProcessList()
 /** Get the peak power of a host */
 double Host::getCurrentPowerPeak()
 {
-  return simgrid::simix::kernel(
-    std::bind(surf_host_get_current_power_peak, this));
+  return simgrid::simix::kernel([&] {
+    return this->pimpl_cpu->getCurrentPowerPeak();
+  });
 }
 
 /** Get one power peak (in flops/s) of a host at a given pstate */
 double Host::getPowerPeakAt(int pstate_index)
 {
-  return simgrid::simix::kernel(
-    std::bind(surf_host_get_power_peak_at, this, pstate_index));
+  return simgrid::simix::kernel([&] {
+    return this->pimpl_cpu->getPowerPeakAt(pstate_index);
+  });
 }
 
 /** @brief Get the speed of the cpu associated to a host */
index f0d4fdd..72a17bf 100644 (file)
@@ -339,9 +339,11 @@ smx_synchro_t SIMIX_process_parallel_execute(const char *name,
   /* FIXME: what happens if host_list contains VMs and PMs. If
    * execute_parallel_task() does not change the state of the model, we can mix
    * them. */
-  surf_host_model_t ws_model = surf_host_get_model(host_list[0]);
+  surf_host_model_t ws_model =
+    host_list[0]->extension<simgrid::surf::Host>()->getModel();
   for (i = 1; i < host_nb; i++) {
-    surf_host_model_t ws_model_tmp = surf_host_get_model(host_list[i]);
+    surf_host_model_t ws_model_tmp =
+      host_list[i]->extension<simgrid::surf::Host>()->getModel();
     if (ws_model_tmp != ws_model) {
       XBT_CRITICAL("mixing VMs and PMs is not supported");
       DIE_IMPOSSIBLE;
index a4367e1..9fa8022 100644 (file)
@@ -95,7 +95,7 @@ void Host::classInit()
   }
 }
 
-Host::Host(simgrid::surf::Model *model, const char *name, xbt_dict_t props,
+Host::Host(simgrid::surf::HostModel *model, const char *name, xbt_dict_t props,
                                 xbt_dynar_t storage, Cpu *cpu)
  : Resource(model, name)
  , PropertyHolder(props)
@@ -104,7 +104,7 @@ Host::Host(simgrid::surf::Model *model, const char *name, xbt_dict_t props,
   p_params.ramsize = 0;
 }
 
-Host::Host(simgrid::surf::Model *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint,
+Host::Host(simgrid::surf::HostModel *model, const char *name, xbt_dict_t props, lmm_constraint_t constraint,
                                         xbt_dynar_t storage, Cpu *cpu)
  : Resource(model, name, constraint)
  , PropertyHolder(props)
index 236ccdb..16bdb11 100644 (file)
@@ -94,7 +94,7 @@ public:
    * @param storage The Storage associated to this Host
    * @param cpu The Cpu associated to this Host
    */
-  Host(simgrid::surf::Model *model, const char *name, xbt_dict_t props,
+  Host(HostModel *model, const char *name, xbt_dict_t props,
                      xbt_dynar_t storage, Cpu *cpu);
 
   /**
@@ -107,7 +107,7 @@ public:
    * @param storage The Storage associated to this Host
    * @param cpu The Cpu associated to this Host
    */
-  Host(simgrid::surf::Model *model, const char *name, xbt_dict_t props,
+  Host(HostModel *model, const char *name, xbt_dict_t props,
       lmm_constraint_t constraint, xbt_dynar_t storage, Cpu *cpu);
 
   /* Host destruction logic */
@@ -121,6 +121,10 @@ private:
 
 
 public:
+  HostModel *getModel()
+  {
+    return static_cast<HostModel*>(Resource::getModel());
+  }
   void attach(simgrid::Host* host);
 
   bool isOn() override;
index 365ce8a..19e3a83 100644 (file)
@@ -169,13 +169,6 @@ void routing_get_route_and_latency(sg_netcard_t src, sg_netcard_t dst,
  * MODEL *
  *********/
 
-surf_host_model_t surf_host_get_model(sg_host_t host)
-{
-  simgrid::surf::Host* surf_host =
-    (simgrid::surf::Host*) host->extension<simgrid::surf::Host>();
-  return (surf_host_model_t) surf_host->getModel();
-}
-
 surf_action_t surf_model_extract_done_action_set(surf_model_t model){
   if (model->getDoneActionSet()->empty())
        return NULL;
@@ -250,19 +243,6 @@ double surf_host_get_available_speed(sg_host_t host){
   return host->pimpl_cpu->getAvailableSpeed();
 }
 
-double surf_host_get_current_power_peak(sg_host_t host){
-  return host->pimpl_cpu->getCurrentPowerPeak();
-}
-
-double surf_host_get_power_peak_at(sg_host_t host, int pstate_index){
-  return host->pimpl_cpu->getPowerPeakAt(pstate_index);
-}
-
-
-xbt_dict_t surf_host_get_mounted_storage_list(sg_host_t host){
-  return get_casted_host(host)->getMountedStorageList();
-}
-
 xbt_dynar_t surf_host_get_attached_storage_list(sg_host_t host){
   return get_casted_host(host)->getAttachedStorageList();
 }
@@ -456,7 +436,3 @@ double surf_network_action_get_latency_limited(surf_action_t action) {
 surf_file_t surf_storage_action_get_file(surf_action_t action){
   return static_cast<simgrid::surf::StorageAction*>(action)->p_file;
 }
-
-surf_host_t surf_host_resource_priv(sg_host_t host) {
-  return host->extension<simgrid::surf::Host>();
-}
index cc11586..87755ce 100644 (file)
@@ -33,7 +33,7 @@ VMModel::vm_list_t VMModel::ws_vms;
  * Resource *
  ************/
 
-VirtualMachine::VirtualMachine(Model *model, const char *name, xbt_dict_t props, simgrid::Host *hostPM)
+VirtualMachine::VirtualMachine(HostModel *model, const char *name, xbt_dict_t props, simgrid::Host *hostPM)
 : Host(model, name, props, NULL, NULL, NULL)
 , p_hostPM(hostPM)
 {
index 7b78d6a..c28b44d 100644 (file)
@@ -62,7 +62,7 @@ public:
    * @param netElm The RoutingEdge associated to this VM
    * @param cpu The Cpu associated to this VM
    */
-  VirtualMachine(simgrid::surf::Model *model, const char *name, xbt_dict_t props,
+  VirtualMachine(simgrid::surf::HostModel *model, const char *name, xbt_dict_t props,
                        simgrid::Host *host);
 
   /** @brief Destructor */