From: Gabriel Corona Date: Tue, 12 Jan 2016 13:46:22 +0000 (+0100) Subject: Remove surf_host_* functions X-Git-Tag: v3_13~1267 X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/commitdiff_plain/471fea6efe44cedfedf6af1f62aa4eb9bc9c3abd Remove surf_host_* functions They are just C wrappers around the C++ API. --- diff --git a/src/include/surf/surf.h b/src/include/surf/surf.h index 84b400d1fe..702678e5b1 100644 --- a/src/include/surf/surf.h +++ b/src/include/surf/surf.h @@ -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); - /** @} */ /**************************************/ diff --git a/src/simdag/sd_workstation.cpp b/src/simdag/sd_workstation.cpp index b43f8ab3f4..afbb21014b 100644 --- a/src/simdag/sd_workstation.cpp +++ b/src/simdag/sd_workstation.cpp @@ -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()->getMountedStorageList(); } /** diff --git a/src/simgrid/host.cpp b/src/simgrid/host.cpp index 482f21fe2e..e5198ae768 100644 --- a/src/simgrid/host.cpp +++ b/src/simgrid/host.cpp @@ -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 */ diff --git a/src/simix/smx_host.cpp b/src/simix/smx_host.cpp index f0d4fdd7e3..72a17bf07b 100644 --- a/src/simix/smx_host.cpp +++ b/src/simix/smx_host.cpp @@ -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()->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()->getModel(); if (ws_model_tmp != ws_model) { XBT_CRITICAL("mixing VMs and PMs is not supported"); DIE_IMPOSSIBLE; diff --git a/src/surf/host_interface.cpp b/src/surf/host_interface.cpp index a4367e1e9f..9fa80220fa 100644 --- a/src/surf/host_interface.cpp +++ b/src/surf/host_interface.cpp @@ -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) diff --git a/src/surf/host_interface.hpp b/src/surf/host_interface.hpp index 236ccdb038..16bdb110d9 100644 --- a/src/surf/host_interface.hpp +++ b/src/surf/host_interface.hpp @@ -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(Resource::getModel()); + } void attach(simgrid::Host* host); bool isOn() override; diff --git a/src/surf/surf_c_bindings.cpp b/src/surf/surf_c_bindings.cpp index 365ce8a037..19e3a83815 100644 --- a/src/surf/surf_c_bindings.cpp +++ b/src/surf/surf_c_bindings.cpp @@ -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(); - 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(action)->p_file; } - -surf_host_t surf_host_resource_priv(sg_host_t host) { - return host->extension(); -} diff --git a/src/surf/virtual_machine.cpp b/src/surf/virtual_machine.cpp index cc11586da1..87755cebab 100644 --- a/src/surf/virtual_machine.cpp +++ b/src/surf/virtual_machine.cpp @@ -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) { diff --git a/src/surf/virtual_machine.hpp b/src/surf/virtual_machine.hpp index 7b78d6ae7e..c28b44dd34 100644 --- a/src/surf/virtual_machine.hpp +++ b/src/surf/virtual_machine.hpp @@ -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 */