They are just C wrappers around the C++ API.
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);
}
*/
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
*
*/
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);
-
/** @} */
/**************************************/
/* 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"
* \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();
}
/**
/** 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 */
/* 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;
}
}
-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)
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)
* @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);
/**
* @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 */
public:
+ HostModel *getModel()
+ {
+ return static_cast<HostModel*>(Resource::getModel());
+ }
void attach(simgrid::Host* host);
bool isOn() override;
* 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;
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();
}
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>();
-}
* 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)
{
* @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 */