git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6450
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
xbt_dict_t properties;
} s_surf_resource_t, *surf_resource_t;
xbt_dict_t properties;
} s_surf_resource_t, *surf_resource_t;
/**
* Resource which have a metric handled by a maxmin system
*/
/**
* Resource which have a metric handled by a maxmin system
*/
+typedef struct {
+ double current;
+ double max;
+ tmgr_trace_event_t event;
+} s_surf_metric_t;
+
typedef struct surf_resource_lmm {
s_surf_resource_t generic_resource;
lmm_constraint_t constraint;
e_surf_resource_state_t state_current;
tmgr_trace_event_t state_event;
typedef struct surf_resource_lmm {
s_surf_resource_t generic_resource;
lmm_constraint_t constraint;
e_surf_resource_state_t state_current;
tmgr_trace_event_t state_event;
- double metric_current;
- tmgr_trace_event_t metric_event;
}s_surf_resource_lmm_t, *surf_resource_lmm_t;
/**************************************/
}s_surf_resource_lmm_t, *surf_resource_lmm_t;
/**************************************/
XBT_PUBLIC(double) get_cpu_power(const char *power);
#include "surf/surf_resource.h"
XBT_PUBLIC(double) get_cpu_power(const char *power);
#include "surf/surf_resource.h"
+#include "surf/surf_resource_lmm.h"
SG_END_DECL()
#endif /* _SURF_SURF_H */
SG_END_DECL()
#endif /* _SURF_SURF_H */
#ifndef SURF_RESOURCE_H
#define SURF_RESOURCE_H
#ifndef SURF_RESOURCE_H
#define SURF_RESOURCE_H
+static XBT_INLINE
+surf_resource_t surf_resource_new(size_t childsize,
+ surf_model_t model, char *name, xbt_dict_t props) {
+ surf_resource_t res = xbt_malloc0(childsize);
+ res->model = model;
+ res->name = name;
+ res->properties = props;
+ return res;
+}
+
static XBT_INLINE void surf_resource_free(void* r) {
surf_resource_t resource = r;
if (resource->name)
static XBT_INLINE void surf_resource_free(void* r) {
surf_resource_t resource = r;
if (resource->name)
e_surf_link_sharing_policy_t
policy, xbt_dict_t properties)
{
e_surf_link_sharing_policy_t
policy, xbt_dict_t properties)
{
- link_CM02_t nw_link = xbt_new0(s_link_CM02_t, 1);
+ link_CM02_t nw_link = (link_CM02_t)
+ surf_resource_lmm_new(sizeof(s_link_CM02_t),
+ surf_network_model,name,properties,
+ lmm_constraint_new(network_maxmin_system, nw_link, bandwidth_factor * bw_initial),
+ history,
+ state_initial,state_trace,
+ bw_initial,bw_trace);
+
xbt_assert1(!xbt_dict_get_or_null(surf_network_model->resource_set, name),
"Link '%s' declared several times in the platform file.", name);
xbt_assert1(!xbt_dict_get_or_null(surf_network_model->resource_set, name),
"Link '%s' declared several times in the platform file.", name);
- nw_link->generic_resource.model = surf_network_model;
- nw_link->generic_resource.name = name;
- current_property_set = nw_link->generic_resource.properties = properties;
- nw_link->bw_current = bw_initial;
- if (bw_trace)
- nw_link->bw_event =
- tmgr_history_add_trace(history, bw_trace, 0.0, 0, nw_link);
nw_link->lat_current = lat_initial;
if (lat_trace)
nw_link->lat_event =
tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
nw_link->lat_current = lat_initial;
if (lat_trace)
nw_link->lat_event =
tmgr_history_add_trace(history, lat_trace, 0.0, 0, nw_link);
- nw_link->state_current = state_initial;
- if (state_trace)
- nw_link->state_event =
- tmgr_history_add_trace(history, state_trace, 0.0, 0, nw_link);
-
- nw_link->constraint =
- lmm_constraint_new(network_maxmin_system, nw_link,
- bandwidth_factor * nw_link->bw_current);
if (policy == SURF_LINK_FATPIPE)
if (policy == SURF_LINK_FATPIPE)
- lmm_constraint_shared(nw_link->constraint);
+ lmm_constraint_shared(nw_link->lmm_resource.constraint);
xbt_dict_set(surf_network_model->resource_set, name, nw_link, surf_resource_free);
xbt_dict_set(surf_network_model->resource_set, name, nw_link, surf_resource_free);
xbt_assert2(trace, "Cannot connect trace %s to link %s: trace undefined",
trace_name, elm);
xbt_assert2(trace, "Cannot connect trace %s to link %s: trace undefined",
trace_name, elm);
- link->state_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+ link->lmm_resource.state_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
}
xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
}
xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
xbt_assert2(trace, "Cannot connect trace %s to link %s: trace undefined",
trace_name, elm);
xbt_assert2(trace, "Cannot connect trace %s to link %s: trace undefined",
trace_name, elm);
- link->bw_event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+ link->lmm_resource.power.event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
}
xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
}
xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
static int resource_used(void *resource_id)
{
return lmm_constraint_used(network_maxmin_system,
static int resource_used(void *resource_id)
{
return lmm_constraint_used(network_maxmin_system,
- ((link_CM02_t) resource_id)->constraint);
+ ((surf_resource_lmm_t) resource_id)->constraint);
}
static int action_unref(surf_action_t action)
}
static int action_unref(surf_action_t action)
/* "%lg" " for event %p\n", surf_get_clock(), nw_link->name, */
/* value, event_type); */
/* "%lg" " for event %p\n", surf_get_clock(), nw_link->name, */
/* value, event_type); */
- if (event_type == nw_link->bw_event) {
+ if (event_type == nw_link->lmm_resource.power.event) {
- weight_S_parameter / value - weight_S_parameter / nw_link->bw_current;
+ weight_S_parameter / value - weight_S_parameter / nw_link->lmm_resource.power.current;
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
surf_action_network_CM02_t action = NULL;
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
surf_action_network_CM02_t action = NULL;
- nw_link->bw_current = value;
- lmm_update_constraint_bound(network_maxmin_system, nw_link->constraint,
- bandwidth_factor * nw_link->bw_current);
+ nw_link->lmm_resource.power.current = value;
+ lmm_update_constraint_bound(network_maxmin_system, nw_link->lmm_resource.constraint,
+ bandwidth_factor * nw_link->lmm_resource.power.current);
if (weight_S_parameter > 0) {
while ((var = lmm_get_var_from_cnst
if (weight_S_parameter > 0) {
while ((var = lmm_get_var_from_cnst
- (network_maxmin_system, nw_link->constraint, &elem))) {
+ (network_maxmin_system, nw_link->lmm_resource.constraint, &elem))) {
action = lmm_variable_id(var);
action->weight += delta;
if (!(action->suspended))
action = lmm_variable_id(var);
action->weight += delta;
if (!(action->suspended))
nw_link->lat_current = value;
while ((var = lmm_get_var_from_cnst
nw_link->lat_current = value;
while ((var = lmm_get_var_from_cnst
- (network_maxmin_system, nw_link->constraint, &elem))) {
+ (network_maxmin_system, nw_link->lmm_resource.constraint, &elem))) {
action = lmm_variable_id(var);
action->lat_current += delta;
action->weight += delta;
action = lmm_variable_id(var);
action->lat_current += delta;
action->weight += delta;
- } else if (event_type == nw_link->state_event) {
+ } else if (event_type == nw_link->lmm_resource.state_event) {
- nw_link->state_current = SURF_RESOURCE_ON;
+ nw_link->lmm_resource.state_current = SURF_RESOURCE_ON;
- lmm_constraint_t cnst = nw_link->constraint;
+ lmm_constraint_t cnst = nw_link->lmm_resource.constraint;
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
lmm_variable_t var = NULL;
lmm_element_t elem = NULL;
- nw_link->state_current = SURF_RESOURCE_OFF;
+ nw_link->lmm_resource.state_current = SURF_RESOURCE_OFF;
while ((var = lmm_get_var_from_cnst
(network_maxmin_system, cnst, &elem))) {
surf_action_t action = lmm_variable_id(var);
while ((var = lmm_get_var_from_cnst
(network_maxmin_system, cnst, &elem))) {
surf_action_t action = lmm_variable_id(var);
link_CM02_t link;
int failed=0;
xbt_dynar_foreach(route,i,link) {
link_CM02_t link;
int failed=0;
xbt_dynar_foreach(route,i,link) {
- if (link->state_current == SURF_RESOURCE_OFF) {
+ if (link->lmm_resource.state_current == SURF_RESOURCE_OFF) {
xbt_dynar_foreach(route,i,link) {
action->latency += link->lat_current;
action->weight +=
xbt_dynar_foreach(route,i,link) {
action->latency += link->lat_current;
action->weight +=
- link->lat_current + weight_S_parameter / link->bw_current;
+ link->lat_current + weight_S_parameter / link->lmm_resource.power.current;
}
/* LARGE PLATFORMS HACK:
Add src->link and dst->link latencies */
}
/* LARGE PLATFORMS HACK:
Add src->link and dst->link latencies */
}
xbt_dynar_foreach(route,i,link) {
}
xbt_dynar_foreach(route,i,link) {
- lmm_expand(network_maxmin_system, link->constraint,
+ lmm_expand(network_maxmin_system, link->lmm_resource.constraint,
action->variable, 1.0);
}
/* LARGE PLATFORMS HACK:
action->variable, 1.0);
}
/* LARGE PLATFORMS HACK:
static double get_link_bandwidth(const void *link)
{
static double get_link_bandwidth(const void *link)
{
- return ((link_CM02_t) link)->bw_current;
+ return ((link_CM02_t) link)->lmm_resource.power.current;
}
static double get_link_latency(const void *link)
}
static double get_link_latency(const void *link)
static int link_shared(const void *link)
{
static int link_shared(const void *link)
{
- return lmm_constraint_is_shared(((link_CM02_t) link)->constraint);
+ return lmm_constraint_is_shared(((surf_resource_lmm_t) link)->constraint);
}
static void action_suspend(surf_action_t action)
}
static void action_suspend(surf_action_t action)
#include "xbt/dict.h"
typedef struct network_link_CM02 {
#include "xbt/dict.h"
typedef struct network_link_CM02 {
- s_surf_resource_t generic_resource; /* must remain first to be added to a trace */
+ s_surf_resource_lmm_t lmm_resource; /* must remain first to be added to a trace */
/* Using this object with the public part of
model does not make sense */
/* Using this object with the public part of
model does not make sense */
- double bw_current;
- tmgr_trace_event_t bw_event;
double lat_current;
tmgr_trace_event_t lat_event;
double lat_current;
tmgr_trace_event_t lat_event;
- e_surf_resource_state_t state_current;
- tmgr_trace_event_t state_event;
- lmm_constraint_t constraint;
} s_link_CM02_t, *link_CM02_t;
} s_link_CM02_t, *link_CM02_t;