-/* Copyright (c) 2013-2014. The SimGrid Team.
+/* Copyright (c) 2013-2015. The SimGrid Team.
* All rights reserved. */
/* This program is free software; you can redistribute it and/or modify it
#include "surf_interface.hpp"
#include "network_interface.hpp"
#include "surf_routing_cluster.hpp"
-#include "instr/instr_private.h"
+#include "src/instr/instr_private.h"
#include "plugins/energy.hpp"
-#include "vm_interface.hpp"
+#include "virtual_machine.hpp"
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_kernel);
return static_cast<Host*>(surf_host_resource_priv(resource));
}
-static VM *get_casted_vm(surf_resource_t resource){
- return static_cast<VM*>(surf_host_resource_priv(resource));
+static VirtualMachine *get_casted_vm(surf_resource_t resource){
+ return static_cast<VirtualMachine*>(surf_host_resource_priv(resource));
}
extern double NOW;
}
}
}
- xbt_dynar_foreach(model_list, iter, model)
+ xbt_dynar_foreach(all_existing_models, iter, model)
model->updateActionsState(NOW, 0.0);
}
surf_min = max_date - NOW;
}
- XBT_DEBUG("Looking for next action end for all models except NS3");
- xbt_dynar_foreach(model_list_invoke, iter, model) {
- double next_action_end = -1.0;
- if (model->shareResourcesIsIdempotent()) {
- XBT_DEBUG("Running for Resource [%s]", typeid(model).name());
- next_action_end = model->shareResources(NOW);
- XBT_DEBUG("Resource [%s] : next action end = %f",
- typeid(model).name(), next_action_end);
- }
- if ((surf_min < 0.0 || next_action_end < surf_min)
- && next_action_end >= 0.0) {
- surf_min = next_action_end;
- }
+ /* Physical models MUST be resolved first */
+ XBT_DEBUG("Looking for next event in physical models");
+ double next_event_phy = surf_host_model->shareResources(NOW);
+ if ((surf_min < 0.0 || next_event_phy < surf_min) && next_event_phy >= 0.0) {
+ surf_min = next_event_phy;
+ }
+ if (surf_vm_model != NULL) {
+ XBT_DEBUG("Looking for next event in virtual models");
+ double next_event_virt = surf_vm_model->shareResources(NOW);
+ if ((surf_min < 0.0 || next_event_virt < surf_min) && next_event_virt >= 0.0)
+ surf_min = next_event_virt;
}
XBT_DEBUG("Min for resources (remember that NS3 don't update that value) : %f", surf_min);
NOW = NOW + surf_min;
/* FIXME: model_list or model_list_invoke? revisit here later */
/* sequential version */
- xbt_dynar_foreach(model_list, iter, model) {
+ xbt_dynar_foreach(all_existing_models, iter, model) {
model->updateActionsState(NOW, surf_min);
}
return ws->getModel();
}
-void *surf_as_cluster_get_backbone(AS_t as){
- return static_cast<AsCluster*>(as)->p_backbone;
-}
-
-void surf_as_cluster_set_backbone(AS_t as, void* backbone){
- static_cast<AsCluster*>(as)->p_backbone = static_cast<Link*>(backbone);
-}
-
-const char *surf_model_name(surf_model_t model){
- return typeid(model).name();
-}
-
surf_action_t surf_model_extract_done_action_set(surf_model_t model){
if (model->getDoneActionSet()->empty())
return NULL;
surf_action_t surf_host_model_execute_parallel_task(surf_host_model_t model,
int host_nb,
- void **host_list,
+ sg_host_t *host_list,
double *flops_amount,
double *bytes_amount,
double rate){
resource->setState(state);
}
-surf_action_t surf_host_sleep(surf_resource_t resource, double duration){
- return get_casted_host(resource)->sleep(duration);
+surf_action_t surf_host_sleep(surf_resource_t host, double duration){
+ return get_casted_host(host)->sleep(duration);
}
-double surf_host_get_speed(surf_resource_t resource, double load){
- return get_casted_host(resource)->getSpeed(load);
+double surf_host_get_speed(surf_resource_t host, double load){
+ return sg_host_surfcpu(host)->getSpeed(load);
}
-double surf_host_get_available_speed(surf_resource_t resource){
- return get_casted_host(resource)->getAvailableSpeed();
+double surf_host_get_available_speed(surf_resource_t host){
+ return sg_host_surfcpu(host)->getAvailableSpeed();
}
-int surf_host_get_core(surf_resource_t resource){
- return get_casted_host(resource)->getCore();
+int surf_host_get_core(surf_resource_t host){
+ return sg_host_surfcpu(host)->getCore();
}
-surf_action_t surf_host_execute(surf_resource_t resource, double size){
- return get_casted_host(resource)->execute(size);
+surf_action_t surf_host_execute(surf_resource_t host, double size){
+ return get_casted_host(host)->execute(size);
}
-double surf_host_get_current_power_peak(surf_resource_t resource){
- return get_casted_host(resource)->getCurrentPowerPeak();
+double surf_host_get_current_power_peak(surf_resource_t host){
+ return sg_host_surfcpu(host)->getCurrentPowerPeak();
}
-double surf_host_get_power_peak_at(surf_resource_t resource, int pstate_index){
- return get_casted_host(resource)->getPowerPeakAt(pstate_index);
+double surf_host_get_power_peak_at(surf_resource_t host, int pstate_index){
+ return sg_host_surfcpu(host)->getPowerPeakAt(pstate_index);
}
-int surf_host_get_nb_pstates(surf_resource_t resource){
- return get_casted_host(resource)->getNbPstates();
+int surf_host_get_nb_pstates(surf_resource_t host){
+ return sg_host_surfcpu(host)->getNbPstates();
}
-void surf_host_set_pstate(surf_resource_t resource, int pstate_index){
- get_casted_host(resource)->setPstate(pstate_index);
+void surf_host_set_pstate(surf_resource_t host, int pstate_index){
+ sg_host_surfcpu(host)->setPstate(pstate_index);
}
-int surf_host_get_pstate(surf_resource_t resource){
- return get_casted_host(resource)->getPstate();
+int surf_host_get_pstate(surf_resource_t host){
+ return sg_host_surfcpu(host)->getPstate();
}
double surf_host_get_wattmin_at(surf_resource_t resource, int pstate){
xbt_assert(surf_energy!=NULL, "The Energy plugin is not active. Please call sg_energy_plugin_init() during initialization.");
xbt_dynar_t vms = get_casted_host(host)->getVms();
xbt_dynar_t vms_ = xbt_dynar_new(sizeof(sg_host_t), NULL);
unsigned int cpt;
- VM *vm;
+ VirtualMachine *vm;
xbt_dynar_foreach(vms, cpt, vm) {
sg_host_t vm_ = xbt_lib_get_elm_or_null(host_lib, vm->getName());
xbt_dynar_push(vms_, &vm_);
return vms_;
}
-void surf_host_get_params(surf_resource_t host, ws_params_t params){
+void surf_host_get_params(surf_resource_t host, vm_params_t params){
get_casted_host(host)->getParams(params);
}
-void surf_host_set_params(surf_resource_t host, ws_params_t params){
+void surf_host_set_params(surf_resource_t host, vm_params_t params){
get_casted_host(host)->setParams(params);
}
void surf_vm_destroy(surf_resource_t resource){
/* Before clearing the entries in host_lib, we have to pick up resources. */
- VM *vm = get_casted_vm(resource);
+ VirtualMachine *vm = get_casted_vm(resource);
char* name = xbt_dict_get_elm_key(resource);
/* We deregister objects from host_lib, without invoking the freeing callback
* of each level.