((cpu_Cas01_t) resource)->constraint);
}
-static double cpu_share_resources_lazy(double now)
+static double cpu_share_resources_lazy(surf_model_t cpu_model, double now)
{
- return generic_share_resources_lazy(now, surf_cpu_model);
+ return generic_share_resources_lazy(now, cpu_model);
}
-static double cpu_share_resources_full(double now)
+static double cpu_share_resources_full(surf_model_t cpu_model, double now)
{
s_surf_action_cpu_Cas01_t action;
- return generic_maxmin_share_resources(surf_cpu_model->states.
+ return generic_maxmin_share_resources(cpu_model->states.
running_action_set,
xbt_swag_offset(action,
generic_lmm_action.
variable),
- surf_cpu_model->model_private->maxmin_system, lmm_solve);
+ cpu_model->model_private->maxmin_system, lmm_solve);
}
-static void cpu_update_actions_state_lazy(double now, double delta)
+static void cpu_update_actions_state_lazy(surf_model_t cpu_model, double now, double delta)
{
- generic_update_actions_state_lazy(now, delta, surf_cpu_model);
+ generic_update_actions_state_lazy(now, delta, cpu_model);
}
-static void cpu_update_actions_state_full(double now, double delta)
+static void cpu_update_actions_state_full(surf_model_t cpu_model, double now, double delta)
{
- generic_update_actions_state_full(now, delta, surf_cpu_model);
+ generic_update_actions_state_full(now, delta, cpu_model);
}
static void cpu_update_resource_state(void *id,
return ((cpu_Cas01_t)surf_cpu_resource_priv(cpu))->power_scale;
}
-static void cpu_finalize(void)
+static void cpu_finalize(surf_model_t cpu_model)
{
- lmm_system_free(surf_cpu_model->model_private->maxmin_system);
- surf_cpu_model->model_private->maxmin_system = NULL;
+ lmm_system_free(cpu_model->model_private->maxmin_system);
+ cpu_model->model_private->maxmin_system = NULL;
- if (surf_cpu_model->model_private->action_heap)
- xbt_heap_free(surf_cpu_model->model_private->action_heap);
- xbt_swag_free(surf_cpu_model->model_private->modified_set);
+ if (cpu_model->model_private->action_heap)
+ xbt_heap_free(cpu_model->model_private->action_heap);
+ xbt_swag_free(cpu_model->model_private->modified_set);
- surf_model_exit(surf_cpu_model);
- surf_cpu_model = NULL;
+ surf_model_exit(cpu_model);
+ cpu_model = NULL;
xbt_swag_free(cpu_running_action_set_that_does_not_need_being_checked);
cpu_running_action_set_that_does_not_need_being_checked = NULL;
* \param cpu Cpu on which the actions are running
* \param now Current time
*/
-static void cpu_ti_update_remaining_amount(cpu_ti_t cpu, double now)
+static void cpu_ti_update_remaining_amount(surf_model_t cpu_model, cpu_ti_t cpu, double now)
{
double area_total;
surf_action_cpu_ti_t action;
surf_action_t generic = (surf_action_t)action;
/* action not running, skip it */
if (generic->state_set !=
- surf_cpu_model->states.running_action_set)
+ cpu_model->states.running_action_set)
continue;
/* bogus priority, skip it */
* \param cpu Cpu on which the actions are running
* \param now Current time
*/
-static void cpu_ti_update_action_finish_date(cpu_ti_t cpu, double now)
+static void cpu_ti_update_action_finish_date(surf_model_t cpu_model, cpu_ti_t cpu, double now)
{
#define GENERIC_ACTION(action) action->generic_action
surf_action_cpu_ti_t action;
double sum_priority = 0.0, total_area, min_finish = -1;
/* update remaning amount of actions */
- cpu_ti_update_remaining_amount(cpu, now);
+ cpu_ti_update_remaining_amount(cpu_model, cpu, now);
xbt_swag_foreach(action, cpu->action_set) {
/* action not running, skip it */
if (GENERIC_ACTION(action).state_set !=
- surf_cpu_model->states.running_action_set)
+ cpu_model->states.running_action_set)
continue;
/* bogus priority, skip it */
min_finish = -1;
/* action not running, skip it */
if (GENERIC_ACTION(action).state_set !=
- surf_cpu_model->states.running_action_set)
+ cpu_model->states.running_action_set)
continue;
/* verify if the action is really running on cpu */
#undef GENERIC_ACTION
}
-static double cpu_ti_share_resources(double now)
+static double cpu_ti_share_resources(surf_model_t cpu_model, double now)
{
cpu_ti_t cpu, cpu_next;
double min_action_duration = -1;
/* iterates over modified cpus to update share resources */
xbt_swag_foreach_safe(cpu, cpu_next, cpu_ti_modified_cpu) {
- cpu_ti_update_action_finish_date(cpu, now);
+ /* FIXME: cpu_ti_modified_cpu is a global object. But, now we have multiple
+ * cpu_model objects in the system. Do we have to create this
+ * swag for each cpu model object?
+ *
+ * We should revisit here after we know what cpu_ti is.
+ **/
+ cpu_ti_update_action_finish_date(cpu_model, cpu, now);
}
/* get the min next event if heap not empty */
if (xbt_heap_size(cpu_ti_action_heap) > 0)
return min_action_duration;
}
-static void cpu_ti_update_actions_state(double now, double delta)
+static void cpu_ti_update_actions_state(surf_model_t cpu_model, double now, double delta)
{
+ /* FIXME: cpu_ti_action_heap is global. Is this okay for VM support? */
+
#define GENERIC_ACTION(action) action->generic_action
surf_action_cpu_ti_t action;
while ((xbt_heap_size(cpu_ti_action_heap) > 0)
GENERIC_ACTION(action).remains = 0;
cpu_ti_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
/* update remaining amout of all actions */
- cpu_ti_update_remaining_amount(surf_cpu_resource_priv(action->cpu), surf_get_clock());
+ cpu_ti_update_remaining_amount(cpu_model, surf_cpu_resource_priv(action->cpu), surf_get_clock());
}
#undef GENERIC_ACTION
}
return CPU->power_scale;
}
-static void cpu_ti_finalize(void)
+static void cpu_ti_finalize(surf_model_t cpu_model)
{
void **cpu;
xbt_lib_cursor_t cursor;
char *key;
+ /* FIXME: we should update this code for VM support */
+ xbt_abort();
+
xbt_lib_foreach(host_lib, cursor, key, cpu){
if(cpu[SURF_CPU_LEVEL])
{
}
}
- surf_model_exit(surf_cpu_model);
- surf_cpu_model = NULL;
+ surf_model_exit(cpu_model);
+ cpu_model = NULL;
xbt_swag_free
(cpu_ti_running_action_set_that_does_not_need_being_checked);
}
#endif
-static double net_share_resources_full(double now)
+static double net_share_resources_full(surf_model_t network_model, double now)
{
s_surf_action_lmm_t s_action;
surf_action_network_CM02_t action = NULL;
xbt_swag_t running_actions =
- surf_network_model->states.running_action_set;
+ network_model->states.running_action_set;
double min;
min = generic_maxmin_share_resources(running_actions,
xbt_swag_offset(s_action,
variable),
- surf_network_model->model_private->maxmin_system,
+ network_model->model_private->maxmin_system,
network_solve);
#define VARIABLE(action) (*((lmm_variable_t*)(((char *) (action)) + xbt_swag_offset(s_action, variable) )))
return min;
}
-static double net_share_resources_lazy(double now)
+static double net_share_resources_lazy(surf_model_t network_model, double now)
{
- return generic_share_resources_lazy(now, surf_network_model);
+ return generic_share_resources_lazy(now, network_model);
}
-static void net_update_actions_state_full(double now, double delta)
+static void net_update_actions_state_full(surf_model_t network_model, double now, double delta)
{
- generic_update_actions_state_full(now, delta, surf_network_model);
+ generic_update_actions_state_full(now, delta, network_model);
}
-static void net_update_actions_state_lazy(double now, double delta)
+static void net_update_actions_state_lazy(surf_model_t network_model, double now, double delta)
{
- generic_update_actions_state_lazy(now, delta, surf_network_model);
+ generic_update_actions_state_lazy(now, delta, network_model);
}
static void net_update_resource_state(void *id,
lmm_constraint_is_shared(((surf_resource_lmm_t) link)->constraint);
}
-static void net_finalize(void)
+static void net_finalize(surf_model_t network_model)
{
- lmm_system_free(surf_network_model->model_private->maxmin_system);
- surf_network_model->model_private->maxmin_system = NULL;
+ lmm_system_free(network_model->model_private->maxmin_system);
+ network_model->model_private->maxmin_system = NULL;
- if (surf_network_model->model_private->update_mechanism == UM_LAZY) {
- xbt_heap_free(surf_network_model->model_private->action_heap);
- xbt_swag_free(surf_network_model->model_private->modified_set);
+ if (network_model->model_private->update_mechanism == UM_LAZY) {
+ xbt_heap_free(network_model->model_private->action_heap);
+ xbt_swag_free(network_model->model_private->modified_set);
}
- surf_model_exit(surf_network_model);
- surf_network_model = NULL;
+ surf_model_exit(network_model);
+ network_model = NULL;
if (smpi_bw_factor)
xbt_dynar_free(&smpi_bw_factor);
return;
}
-static double netcste_share_resources(double now)
+static double netcste_share_resources(surf_model_t network_model, double now)
{
surf_action_network_Constant_t action = NULL;
xbt_swag_t running_actions =
- surf_network_model->states.running_action_set;
+ network_model->states.running_action_set;
double min = -1.0;
xbt_swag_foreach(action, running_actions) {
return min;
}
-static void netcste_update_actions_state(double now, double delta)
+static void netcste_update_actions_state(surf_model_t network_model, double now, double delta)
{
surf_action_network_Constant_t action = NULL;
surf_action_network_Constant_t next_action = NULL;
xbt_swag_t running_actions =
- surf_network_model->states.running_action_set;
+ network_model->states.running_action_set;
xbt_swag_foreach_safe(action, next_action, running_actions) {
if (action->latency > 0) {
if (action->generic_action.remains <= 0) {
action->generic_action.finish = surf_get_clock();
- surf_network_model->action_state_set((surf_action_t) action,
+ network_model->action_state_set((surf_action_t) action,
SURF_ACTION_DONE);
} else if ((action->generic_action.max_duration != NO_MAX_DURATION)
&& (action->generic_action.max_duration <= 0)) {
action->generic_action.finish = surf_get_clock();
- surf_network_model->action_state_set((surf_action_t) action,
+ network_model->action_state_set((surf_action_t) action,
SURF_ACTION_DONE);
}
}
return ((surf_action_network_Constant_t) action)->suspended;
}
-static void netcste_finalize(void)
+static void netcste_finalize(surf_model_t network_model)
{
- surf_model_exit(surf_network_model);
- surf_network_model = NULL;
+ surf_model_exit(network_model);
+ network_model = NULL;
}
surf_action_state_set(action, state);
}
-static double share_resources(double now)
+static double share_resources(surf_model_t network_model, double now)
{
xbt_swag_t running_actions =
surf_network_model->states.running_action_set;
return time_to_next_flow_completion;
}
-static void update_actions_state(double now, double delta)
+static void update_actions_state(surf_model_t network_model, double now, double delta)
{
surf_action_network_GTNETS_t action = NULL;
xbt_swag_t running_actions =
- surf_network_model->states.running_action_set;
+ network_model->states.running_action_set;
/* If there are no running flows, just return */
if (time_to_next_flow_completion < 0.0) {
}
#endif
-static void finalize(void)
+static void finalize(surf_model_t network_model)
{
gtnets_finalize();
}
static double time_to_next_flow_completion = -1;
-static double ns3_share_resources(double min);
-static void ns3_update_actions_state(double now, double delta);
-static void finalize(void);
+static double ns3_share_resources(surf_model_t network_model, double min);
+static void ns3_update_actions_state(surf_model_t network_model, double now, double delta);
+static void finalize(surf_model_t network_model);
static surf_action_t ns3_communicate(sg_routing_edge_t src_elm,
sg_routing_edge_t dst_elm,
double size, double rate);
#endif
}
-static void finalize(void)
+static void finalize(surf_model_t network_model)
{
ns3_finalize();
xbt_dynar_free_container(&IPV4addr);
xbt_dict_free(&dict_socket);
}
-static double ns3_share_resources(double min)
+static double ns3_share_resources(surf_model_t network_model, double min)
{
XBT_DEBUG("ns3_share_resources");
xbt_swag_t running_actions =
- surf_network_model->states.running_action_set;
+ network_model->states.running_action_set;
//get the first relevant value from the running_actions list
if (!xbt_swag_size(running_actions) || min == 0.0)
return time_to_next_flow_completion;
}
-static void ns3_update_actions_state(double now, double delta)
+static void ns3_update_actions_state(surf_model_t network_model, double now, double delta)
{
xbt_dict_cursor_t cursor = NULL;
char *key;
surf_action_network_ns3_t action = NULL;
xbt_swag_t running_actions =
- surf_network_model->states.running_action_set;
+ network_model->states.running_action_set;
/* If there are no running flows, just return */
if (!xbt_swag_size(running_actions)) {
return NULL;
}
-static void new_model_finalize(void)
+static void new_model_finalize(surf_model_t new_model)
{
lmm_system_free(new_model_maxmin_system);
new_model_maxmin_system = NULL;
- surf_model_exit(surf_new_model);
- surf_new_model = NULL;
+ surf_model_exit(new_model);
+ new_model = NULL;
xbt_swag_free
(new_model_running_action_set_that_does_not_need_being_checked);
new_model_running_action_set_that_does_not_need_being_checked = NULL;
}
-static void new_model_update_actions_state(double now, double delta)
+static void new_model_update_actions_state(surf_model_t new_model, double now, double delta)
{
return;
}
-static double new_model_share_resources(double NOW)
+static double new_model_share_resources(surf_model_t new_model, double NOW)
{
return -1;
}
return storage;
}
-static void storage_finalize(void)
+static void storage_finalize(surf_model_t storage_model)
{
lmm_system_free(storage_maxmin_system);
storage_maxmin_system = NULL;
- surf_model_exit(surf_storage_model);
- surf_storage_model = NULL;
+ surf_model_exit(storage_model);
+ storage_model = NULL;
if(storage_list)
xbt_dynar_free(&storage_list);
storage_running_action_set_that_does_not_need_being_checked = NULL;
}
-static void storage_update_actions_state(double now, double delta)
+static void storage_update_actions_state(surf_model_t storage_model, double now, double delta)
{
surf_action_storage_t action = NULL;
surf_action_storage_t next_action = NULL;
- xbt_swag_t running_actions = surf_storage_model->states.running_action_set;
+ xbt_swag_t running_actions = storage_model->states.running_action_set;
// Update the disk usage
// Update the file size
return;
}
-static double storage_share_resources(double NOW)
+static double storage_share_resources(surf_model_t storage_model, double NOW)
{
XBT_DEBUG("storage_share_resources %f",NOW);
s_surf_action_storage_t action;
storage_t storage;
surf_action_storage_t write_action;
- double min_completion = generic_maxmin_share_resources(surf_storage_model->states.running_action_set,
+ double min_completion = generic_maxmin_share_resources(storage_model->states.running_action_set,
xbt_swag_offset(action, generic_lmm_action.variable),
storage_maxmin_system, lmm_solve);
sg_config_finalize();
xbt_dynar_foreach(model_list, iter, model)
- model->model_private->finalize();
+ model->model_private->finalize(model);
xbt_dynar_free(&model_list);
xbt_dynar_free(&model_list_invoke);
/* FIXME: see what is check_update_action_state(). if necessary, use model_list_invoke. */
xbt_dynar_foreach(model_list, iter, model)
- model->model_private->update_actions_state(NOW, 0.0);
+ model->model_private->update_actions_state(model, NOW, 0.0);
}
double surf_solve(double max_date)
XBT_DEBUG("Run for network at most %f", min);
// run until min or next flow
- model_next_action_end = surf_network_model->model_private->share_resources(min);
+ model_next_action_end = surf_network_model->model_private->share_resources(surf_network_model, min);
XBT_DEBUG("Min for network : %f", model_next_action_end);
if(model_next_action_end>=0.0)
int i = __sync_fetch_and_add(&surf_min_index, 1);
if (strcmp(model->name,"network NS3")) {
XBT_DEBUG("Running for Resource [%s]", model->name);
- next_action_end = model->model_private->share_resources(NOW);
+ next_action_end = model->model_private->share_resources(model, NOW);
XBT_DEBUG("Resource [%s] : next action end = %f",
model->name, next_action_end);
}
static void surf_update_actions_state(surf_model_t model)
{
- model->model_private->update_actions_state(NOW, min);
+ model->model_private->update_actions_state(model, NOW, min);
}
/**
int (*resource_used) (void *resource_id);
/* Share the resources to the actions and return in how much time
the next action may terminate */
- double (*share_resources) (double now);
+ double (*share_resources) (surf_model_t model, double now);
/* Update the actions' state */
- void (*update_actions_state) (double now, double delta);
- void (*update_resource_state) (void *id, tmgr_trace_event_t event_type,
+ void (*update_actions_state) (surf_model_t model, double now, double delta);
+ void (*update_resource_state) (void *resource, tmgr_trace_event_t event_type,
double value, double time);
- void (*finalize) (void);
+ void (*finalize) (surf_model_t model);
lmm_system_t maxmin_system;
e_UM_t update_mechanism;
}
-static double ws_share_resources(double now)
+static double vm_ws_share_resources(surf_model_t workstation_model, double now)
{
// Can be obsolete if you right can ensure that ws_model has been code previously
// invoke ws_share_resources on the physical_lyer: sub_ws->ws_share_resources()
return;
}
-static double ws_share_resources(double now)
+static double ws_share_resources(surf_model_t workstation_model, double now)
{
// invoke share_resources on CPU and network (layer 0)
return -1.0;
}
-static void ws_update_actions_state(double now, double delta)
+static void ws_update_actions_state(surf_model_t workstation_model, double now, double delta)
{
return;
}
return surf_network_model->extension.network.link_shared(link);
}
-static void ws_finalize(void)
+static void ws_finalize(surf_model_t workstation_model)
{
- surf_model_exit(surf_workstation_model);
- surf_workstation_model = NULL;
+ surf_model_exit(workstation_model);
+ workstation_model = NULL;
}
static xbt_dict_t ws_get_properties(const void *ws)
}
-static double ptask_share_resources(double now)
+static double ptask_share_resources(surf_model_t workstation_model, double now)
{
s_surf_action_workstation_L07_t s_action;
surf_action_workstation_L07_t action = NULL;
xbt_swag_t running_actions =
- surf_workstation_model->states.running_action_set;
+ workstation_model->states.running_action_set;
double min = generic_maxmin_share_resources(running_actions,
xbt_swag_offset(s_action,
variable),
return min;
}
-static void ptask_update_actions_state(double now, double delta)
+static void ptask_update_actions_state(surf_model_t workstation_model, double now, double delta)
{
double deltap = 0.0;
surf_action_workstation_L07_t action = NULL;
surf_action_workstation_L07_t next_action = NULL;
xbt_swag_t running_actions =
- surf_workstation_model->states.running_action_set;
+ workstation_model->states.running_action_set;
xbt_swag_foreach_safe(action, next_action, running_actions) {
deltap = delta;
return;
}
-static void ptask_finalize(void)
+static void ptask_finalize(surf_model_t workstation_model)
{
xbt_dict_free(&ptask_parallel_task_link_set);
- surf_model_exit(surf_workstation_model);
- surf_workstation_model = NULL;
+ surf_model_exit(workstation_model);
+ workstation_model = NULL;
surf_model_exit(surf_network_model);
surf_network_model = NULL;