#ifdef __cplusplus
extern "C" {
#endif
+char *surf_routing_edge_name(sg_routing_edge_t edge);
const char *surf_model_name(surf_model_t model);
xbt_swag_t surf_model_done_action_set(surf_model_t model);
surf_action_t surf_workstation_communicate(surf_workstation_t workstation_src, surf_workstation_t workstation_dst, double size, double rate);
surf_action_t surf_workstation_open(surf_workstation_t workstation, const char* mount, const char* path);
surf_action_t surf_workstation_close(surf_workstation_t workstation, surf_file_t fd);
+const char *surf_cpu_name(surf_cpu_t resource);
surf_action_t surf_cpu_execute(surf_cpu_t cpu, double size);
surf_action_t surf_cpu_sleep(surf_cpu_t cpu, double duration);
int surf_workstation_unlink(surf_workstation_t workstation, surf_file_t fd);
/* ********************************************************************* */
/* TUTORIAL: New model */
- int new_model_id = -1;
+ /*FIXME:UPDATE: int new_model_id = -1;
char *new_model_name = NULL;
new_model_name = xbt_cfg_get_string(_sg_cfg_set, "new_model/model");
XBT_DEBUG("Call new model_init");
new_model_id = find_model_description(surf_new_model_description, new_model_name);
- surf_new_model_description[new_model_id].model_init_preparse();
+ surf_new_model_description[new_model_id].model_init_preparse();*/
/* ********************************************************************* */
}
static xbt_swag_t
cpu_running_action_set_that_does_not_need_being_checked = NULL;
+/*************
+ * CallBacks *
+ *************/
+
+static void parse_cpu_init(sg_platf_host_cbarg_t host){
+ ((CpuCas01ModelPtr)surf_cpu_model)->parseInit(host);
+}
+
+static void cpu_add_traces_cpu(){
+ surf_cpu_model->addTraces();
+}
+
+static void cpu_define_callbacks()
+{
+ sg_platf_host_add_cb(parse_cpu_init);
+ sg_platf_postparse_add_cb(cpu_add_traces_cpu);
+}
+
/*********
* Model *
*********/
}
surf_cpu_model = new CpuCas01Model();
- xbt_dynar_push(model_list, &surf_cpu_model);
+ cpu_define_callbacks();
+ ModelPtr model = static_cast<ModelPtr>(surf_cpu_model);
+ xbt_dynar_push(model_list, &model);
}
CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
if (p_updateMechanism == UM_LAZY) {
p_actionHeap = xbt_heap_new(8, NULL);
xbt_heap_set_update_callback(p_actionHeap, surf_action_lmm_update_index_heap);
- p_modifiedSet = xbt_swag_new(xbt_swag_offset(action, p_actionListHookup));
- //TOREPAIR: cpu_model->model_private->maxmin_system->m_keepTrack = cpu_model->model_private->modified_set;
+ ActionLmmPtr _actionlmm;
+ CpuCas01ActionLmmPtr _actioncpu;
+ int j = xbt_swag_offset(*_actionlmm, p_actionListHookup);
+ int k = xbt_swag_offset(*_actioncpu, p_actionListHookup);
+ j = ((char *)&( (*_actionlmm).p_actionListHookup ) - (char *)(_actionlmm));
+ k = ((char *)&( (*_actioncpu).p_actionListHookup ) - (char *)(_actioncpu));
+ void *toto = &(*_actionlmm).p_actionListHookup;
+ void *tata = _actionlmm;
+ ActionLmm aieu;
+ ActionLmmPtr actionBase = &aieu;
+ void *actionBaseVoid = actionBase;
+ void *actionBaseCVoid = static_cast<void*>(actionBase);
+ ActionLmmPtr actionBaseVoidBase = (ActionLmmPtr)actionBaseVoid;
+ ActionLmmPtr actionBaseCVoidCBase = static_cast<ActionLmmPtr>(actionBaseCVoid);
+ p_modifiedSet = xbt_swag_new(xbt_swag_offset(*_actionlmm, p_actionListHookup));
+ p_maxminSystem->keep_track = p_modifiedSet;
}
- /* Define callbacks */
- //TODO sg_platf_host_add_cb(parse_cpu_init);
- //TODO sg_platf_postparse_add_cb(cpu_add_traces_cpu);
}
CpuCas01Model::~CpuCas01Model()
tmgr_trace_t state_trace,
xbt_dict_t cpu_properties)
{
- CpuCas01LmmPtr cpu = NULL;
-
+ CpuPtr cpu = NULL;
xbt_assert(!surf_cpu_resource_priv(surf_cpu_resource_by_name(name)),
"Host '%s' declared several times in the platform file",
name);
xbt_assert(core > 0, "Invalid number of cores %d", core);
cpu = new CpuCas01Lmm(this, name, power_peak, power_scale, power_trace, core, state_initial, state_trace, cpu_properties);
-
- xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, this);
+ xbt_lib_set(host_lib, name, SURF_CPU_LEVEL, cpu);
return (CpuCas01LmmPtr) xbt_lib_get_elm_or_null(host_lib, name);;
}
/* connect all traces relative to hosts */
xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuCas01LmmPtr host = (CpuCas01LmmPtr) surf_cpu_resource_by_name(elm);
+ CpuCas01LmmPtr host = (CpuCas01LmmPtr) surf_cpu_resource_priv(surf_cpu_resource_by_name(elm));
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
host->p_stateEvent =
- tmgr_history_add_trace(history, trace, 0.0, 0, host);
+ tmgr_history_add_trace(history, trace, 0.0, 0, (ResourcePtr) host);
}
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
- CpuCas01LmmPtr host = (CpuCas01LmmPtr) surf_cpu_resource_by_name(elm);
+ CpuCas01LmmPtr host = (CpuCas01LmmPtr) surf_cpu_resource_priv(surf_cpu_resource_by_name(elm));
xbt_assert(host, "Host %s undefined", elm);
xbt_assert(trace, "Trace %s undefined", trace_name);
host->p_powerEvent =
- tmgr_history_add_trace(history, trace, 0.0, 0, host);
+ tmgr_history_add_trace(history, trace, 0.0, 0, (ResourcePtr) host);
}
}
CpuCas01Lmm::CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, double powerPeak,
double powerScale, tmgr_trace_t powerTrace, int core,
e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace,
- xbt_dict_t properties) :
- CpuLmm(model, name, properties) {
+ xbt_dict_t properties) :
+ CpuLmm(model, name, properties), Resource(model, name, properties) {
m_powerPeak = powerPeak;
m_powerScale = powerScale;
m_core = core;
p_stateCurrent = stateInitial;
if (powerTrace)
- p_powerEvent = tmgr_history_add_trace(history, powerTrace, 0.0, 0, this);
+ p_powerEvent = tmgr_history_add_trace(history, powerTrace, 0.0, 0, static_cast<ResourcePtr>(this));
if (stateTrace)
- p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, this);
+ p_stateEvent = tmgr_history_add_trace(history, stateTrace, 0.0, 0, static_cast<ResourcePtr>(this));
p_constraint = lmm_constraint_new(p_model->p_maxminSystem, this, m_core * m_powerScale * m_powerPeak);
}
#endif
while ((var = lmm_get_var_from_cnst
(surf_cpu_model->p_maxminSystem, p_constraint, &elem))) {
- CpuCas01ActionLmmPtr action = (CpuCas01ActionLmmPtr) lmm_variable_id(var);
+ CpuCas01ActionLmmPtr action = static_cast<CpuCas01ActionLmmPtr>(static_cast<ActionLmmPtr>(lmm_variable_id(var)));
+
lmm_update_variable_bound(surf_cpu_model->p_maxminSystem,
action->p_variable,
m_powerScale * m_powerPeak);
p_stateCurrent = SURF_RESOURCE_OFF;
while ((var = lmm_get_var_from_cnst(surf_cpu_model->p_maxminSystem, cnst, &elem))) {
- ActionPtr action = (ActionPtr) lmm_variable_id(var);
+ ActionLmmPtr action = static_cast<ActionLmmPtr>(lmm_variable_id(var));
if (action->getState() == SURF_ACTION_RUNNING ||
action->getState() == SURF_ACTION_READY ||
calloc but it seems to help valgrind... */
action->p_variable =
- lmm_variable_new(surf_cpu_model->p_maxminSystem, action,
+ lmm_variable_new(surf_cpu_model->p_maxminSystem, static_cast<ActionLmmPtr>(action),
action->m_priority,
m_powerScale * m_powerPeak, 1);
if (surf_cpu_model->p_updateMechanism == UM_LAZY) {
if (duration == NO_MAX_DURATION) {
/* Move to the *end* of the corresponding action set. This convention
is used to speed up update_resource_state */
- xbt_swag_remove(action, action->p_stateSet);
+ xbt_swag_remove(static_cast<ActionPtr>(action), action->p_stateSet);
action->p_stateSet = cpu_running_action_set_that_does_not_need_being_checked;
- xbt_swag_insert(action, action->p_stateSet);
+ xbt_swag_insert(static_cast<ActionPtr>(action), action->p_stateSet);
}
lmm_update_variable_weight(surf_cpu_model->p_maxminSystem,
class CpuCas01ActionLmm: public CpuActionLmm {
public:
CpuCas01ActionLmm() {};
- CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): CpuActionLmm(model, cost, failed) {};
- int unref() {return 0;};//TODO
- void cancel() {};//TODO
- void recycle() {};//TODO
+ CpuCas01ActionLmm(ModelPtr model, double cost, bool failed): Action(model, cost, failed), CpuActionLmm(model, cost, failed) {};
};
if (duration == NO_MAX_DURATION) {
/* Move to the *end* of the corresponding action set. This convention
is used to speed up update_resource_state */
- xbt_swag_remove(action, action->p_stateSet);
+ xbt_swag_remove(static_cast<ActionPtr>(action), action->p_stateSet);
action->p_stateSet = cpu_ti_running_action_set_that_does_not_need_being_checked;
- xbt_swag_insert(action, action->p_stateSet);
+ xbt_swag_insert(static_cast<ActionPtr>(action), action->p_stateSet);
}
XBT_OUT();
return action;
{
m_refcount--;
if (!m_refcount) {
- xbt_swag_remove(this, p_stateSet);
+ xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
/* remove from action_set */
xbt_swag_remove(this, ((CpuTiPtr)surf_cpu_resource_priv(p_cpu))->p_actionSet);
/* remove from heap */
double sg_tcp_gamma = 0.0;
int sg_network_crosstraffic = 0;
+/*************
+ * CallBacks *
+ *************/
+
+static void net_parse_link_init(sg_platf_link_cbarg_t link){
+ if (link->policy == SURF_LINK_FULLDUPLEX) {
+ char *link_id;
+ link_id = bprintf("%s_UP", link->id);
+ surf_network_model->createResource(link_id,
+ link->bandwidth,
+ link->bandwidth_trace,
+ link->latency,
+ link->latency_trace,
+ link->state,
+ link->state_trace, link->policy, link->properties);
+ xbt_free(link_id);
+ link_id = bprintf("%s_DOWN", link->id);
+ surf_network_model->createResource(link_id,
+ link->bandwidth,
+ link->bandwidth_trace,
+ link->latency,
+ link->latency_trace,
+ link->state,
+ link->state_trace, link->policy, link->properties);
+ xbt_free(link_id);
+ } else {
+ surf_network_model->createResource(link->id,
+ link->bandwidth,
+ link->bandwidth_trace,
+ link->latency,
+ link->latency_trace,
+ link->state,
+ link->state_trace, link->policy, link->properties);
+ }
+}
+
+static void net_add_traces(void){
+ xbt_dict_cursor_t cursor = NULL;
+ char *trace_name, *elm;
+
+ static int called = 0;
+ if (called)
+ return;
+ called = 1;
+
+ /* connect all traces relative to network */
+ xbt_dict_foreach(trace_connect_list_link_avail, cursor, trace_name, elm) {
+ tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
+ NetworkCm02LinkLmmPtr link = static_cast<NetworkCm02LinkLmmPtr>(
+ static_cast<NetworkCm02LinkPtr>(
+ xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
+
+ xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
+ trace_name, elm);
+ xbt_assert(trace,
+ "Cannot connect trace %s to link %s: trace undefined",
+ trace_name, elm);
+
+ link->p_stateEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+ }
+
+ xbt_dict_foreach(trace_connect_list_bandwidth, cursor, trace_name, elm) {
+ tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
+ NetworkCm02LinkLmmPtr link = static_cast<NetworkCm02LinkLmmPtr>(
+ static_cast<NetworkCm02LinkPtr>(
+ xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
+
+ xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
+ trace_name, elm);
+ xbt_assert(trace,
+ "Cannot connect trace %s to link %s: trace undefined",
+ trace_name, elm);
+
+ link->p_power.event = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+ }
+
+ xbt_dict_foreach(trace_connect_list_latency, cursor, trace_name, elm) {
+ tmgr_trace_t trace = (tmgr_trace_t) xbt_dict_get_or_null(traces_set_list, trace_name);
+ NetworkCm02LinkLmmPtr link = static_cast<NetworkCm02LinkLmmPtr>(
+ static_cast<NetworkCm02LinkPtr>(
+ xbt_lib_get_or_null(link_lib, elm, SURF_LINK_LEVEL)));
+
+ xbt_assert(link, "Cannot connect trace %s to link %s: link undefined",
+ trace_name, elm);
+ xbt_assert(trace,
+ "Cannot connect trace %s to link %s: trace undefined",
+ trace_name, elm);
+
+ link->p_latEvent = tmgr_history_add_trace(history, trace, 0.0, 0, link);
+ }
+}
+
+static void net_define_callbacks(void)
+{
+ /* Figuring out the network links */
+ sg_platf_link_add_cb(net_parse_link_init);
+ sg_platf_postparse_add_cb(net_add_traces);
+}
+
/*********
* Model *
*********/
return;
surf_network_model = new NetworkCm02Model();
- xbt_dynar_push(model_list, &surf_network_model);
+ net_define_callbacks();
+ ModelPtr model = static_cast<ModelPtr>(surf_network_model);
+ xbt_dynar_push(model_list, &model);
xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor",
13.01);
return;
surf_network_model = new NetworkCm02Model();
- xbt_dynar_push(model_list, &surf_network_model);
+ net_define_callbacks();
+ ModelPtr model = static_cast<ModelPtr>(surf_network_model);
+ xbt_dynar_push(model_list, &model);
xbt_cfg_setdefault_double(_sg_cfg_set, "network/latency_factor", 1.0);
xbt_cfg_setdefault_double(_sg_cfg_set, "network/bandwidth_factor",
return;
surf_network_model = new NetworkCm02Model();
- xbt_dynar_push(model_list, &surf_network_model);
+ net_define_callbacks();
+ ModelPtr model = static_cast<ModelPtr>(surf_network_model);
+ xbt_dynar_push(model_list, &model);
lmm_set_default_protocol_function(func_reno_f, func_reno_fp,
func_reno_fpi);
surf_network_model->f_networkSolve = lagrange_solve;
return;
surf_network_model = new NetworkCm02Model();
- xbt_dynar_push(model_list, &surf_network_model);
+ net_define_callbacks();
+ ModelPtr model = static_cast<ModelPtr>(surf_network_model);
+ xbt_dynar_push(model_list, &model);
lmm_set_default_protocol_function(func_reno2_f, func_reno2_fp,
func_reno2_fpi);
surf_network_model->f_networkSolve = lagrange_solve;
return;
surf_network_model = new NetworkCm02Model();
- xbt_dynar_push(model_list, &surf_network_model);
+ net_define_callbacks();
+ ModelPtr model = static_cast<ModelPtr>(surf_network_model);
+ xbt_dynar_push(model_list, &model);
lmm_set_default_protocol_function(func_vegas_f, func_vegas_fp,
func_vegas_fpi);
surf_network_model->f_networkSolve = lagrange_solve;
state_initial, state_trace, bw_initial, bw_trace, lat_initial, lat_trace, policy);
- xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, nw_link);
+ xbt_lib_set(link_lib, name, SURF_LINK_LEVEL, static_cast<NetworkCm02LinkPtr>(nw_link));
XBT_DEBUG("Create link '%s'",name);
return nw_link;
double size, double rate)
{
unsigned int i;
+ void *_link;
NetworkCm02LinkLmmPtr link;
int failed = 0;
NetworkCm02ActionLmmPtr action = NULL;
"You're trying to send data from %s to %s but there is no connection at all between these two hosts.",
src->p_name, dst->p_name);
- xbt_dynar_foreach(route, i, link) {
+ xbt_dynar_foreach(route, i, _link) {
+ link = static_cast<NetworkCm02LinkLmmPtr>(static_cast<NetworkCm02LinkPtr>(_link));
if (link->p_stateCurrent == SURF_RESOURCE_OFF) {
failed = 1;
break;
}
if (sg_network_crosstraffic == 1) {
routing_platf->getRouteAndLatency(dst, src, &back_route, NULL);
- xbt_dynar_foreach(back_route, i, link) {
+ xbt_dynar_foreach(back_route, i, _link) {
+ link = static_cast<NetworkCm02LinkLmmPtr>(static_cast<NetworkCm02LinkPtr>(_link));
if (link->p_stateCurrent == SURF_RESOURCE_OFF) {
failed = 1;
break;
#endif
action->m_weight = action->m_latency = latency;
- xbt_swag_insert(action, action->p_stateSet);
+ //FIXME:REMOVxbt_swag_insert(action, action->p_stateSet);
action->m_rate = rate;
if (p_updateMechanism == UM_LAZY) {
action->m_indexHeap = -1;
(link->p_power.peak * link->p_power.scale);
}
}
- xbt_dynar_foreach(route, i, link) {
- double bb = bandwidthFactor(size) *
- (link->p_power.peak * link->p_power.scale);
+ xbt_dynar_foreach(route, i, _link) {
+ link = static_cast<NetworkCm02LinkLmmPtr>(static_cast<NetworkCm02LinkPtr>(_link));
+ double bb = bandwidthFactor(size) * (link->p_power.peak * link->p_power.scale);
bandwidth_bound =
(bandwidth_bound < 0.0) ? bb : min(bandwidth_bound, bb);
}
xbt_assert(!xbt_dynar_is_empty(route),
"Using a model with a gap (e.g., SMPI) with a platform without links (e.g. vivaldi)!!!");
- link = *(NetworkCm02LinkLmmPtr *) xbt_dynar_get_ptr(route, 0);
+ //link = *(NetworkCm02LinkLmmPtr *) xbt_dynar_get_ptr(route, 0);
+ link = static_cast<NetworkCm02LinkLmmPtr>(*static_cast<NetworkCm02LinkPtr *>(xbt_dynar_get_ptr(route, 0)));
gapAppend(size, link, action);
XBT_DEBUG("Comm %p: %s -> %s gap=%f (lat=%f)",
action, src->p_name, dst->p_name, action->m_senderGap,
lmm_update_variable_bound(p_maxminSystem, action->p_variable, (action->m_latCurrent > 0) ? min(action->m_rate, sg_tcp_gamma / (2.0 * action->m_latCurrent)) : action->m_rate);
}
- xbt_dynar_foreach(route, i, link) {
+ xbt_dynar_foreach(route, i, _link) {
+ link = static_cast<NetworkCm02LinkLmmPtr>(static_cast<NetworkCm02LinkPtr>(_link));
lmm_expand(p_maxminSystem, link->p_constraint, action->p_variable, 1.0);
}
if (sg_network_crosstraffic == 1) {
XBT_DEBUG("Fullduplex active adding backward flow using 5%%");
- xbt_dynar_foreach(back_route, i, link) {
+ xbt_dynar_foreach(back_route, i, _link) {
+ link = static_cast<NetworkCm02LinkLmmPtr>(static_cast<NetworkCm02LinkPtr>(_link));
lmm_expand(p_maxminSystem, link->p_constraint, action->p_variable, .05);
}
}
double lat_initial,
tmgr_trace_t lat_trace,
e_surf_link_sharing_policy_t policy)
-: ResourceLmm(model, name, props, system, constraint_value, history, state_init, state_trace, metric_peak, metric_trace)
+: Resource(model, name, props),
+ ResourceLmm(model, name, props, system, constraint_value, history, state_init, state_trace, metric_peak, metric_trace),
+ NetworkCm02Link(model, name, props)
{
m_latCurrent = lat_initial;
if (lat_trace)
e_surf_link_sharing_policy_t policy,
xbt_dict_t properties);
void updateActionsStateLazy(double now, double delta);
- void updateActionsStateFull(double now, double delta);
virtual void gapAppend(double size, const NetworkCm02LinkLmmPtr link, NetworkCm02ActionLmmPtr action) {};
NetworkCm02ActionPtr communicate(RoutingEdgePtr src, RoutingEdgePtr dst,
double size, double rate);
**********/
class NetworkCm02Action : virtual public Action {
public:
- NetworkCm02Action(ModelPtr model, double cost, bool failed): Action(model, cost, failed) {};
+ NetworkCm02Action(ModelPtr model, double cost, bool failed)
+ : Action(model, cost, failed) {};
double m_latency;
double m_latCurrent;
double m_weight;
class NetworkCm02ActionLmm : public ActionLmm, public NetworkCm02Action {
public:
- NetworkCm02ActionLmm(ModelPtr model, double cost, bool failed): ActionLmm(model, cost, failed), NetworkCm02Action(model, cost, failed) {};
+ NetworkCm02ActionLmm(ModelPtr model, double cost, bool failed)
+ : Action(model, cost, failed),
+ ActionLmm(model, cost, failed),
+ NetworkCm02Action(model, cost, failed) {};
void updateRemainingLazy(double now);
void recycle();
};
//FIXME:sg_platf_host_add_cb(netcste_count_hosts);
- xbt_dynar_push(model_list, &surf_network_model);
+ ModelPtr model = static_cast<ModelPtr>(surf_network_model);
+ xbt_dynar_push(model_list, &model);
//FIXME:routing_model_create(NULL);
}
{
m_refcount--;
if (!m_refcount) {
- xbt_swag_remove(this, p_stateSet);
+ xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
delete this;
return 1;
}
m_latency = latency;
if (m_latency <= 0.0) {
p_stateSet = p_model->p_doneActionSet;
- xbt_swag_insert(this, p_stateSet);
+ xbt_swag_insert(static_cast<ActionPtr>(this), p_stateSet);
}
};
int unref();
static int storage_selective_update = 0;
static xbt_swag_t storage_running_action_set_that_does_not_need_being_checked = NULL;
-void storage_register_callbacks() {
+/*************
+ * CallBacks *
+ *************/
- /*FIXME:ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,xbt_free);
- ROUTING_STORAGE_HOST_LEVEL = xbt_lib_add_level(storage_lib,routing_storage_host_free);
- ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib,routing_storage_type_free);
- SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_resource_free);
+static XBT_INLINE void routing_storage_type_free(void *r)
+{
+ storage_type_t stype = (storage_type_t) r;
+ free(stype->model);
+ free(stype->type_id);
+ free(stype->content);
+ xbt_dict_free(&(stype->properties));
+ free(stype);
+}
- sg_platf_storage_add_cb(storage_parse_storage);
- sg_platf_mstorage_add_cb(storage_parse_mstorage);
- sg_platf_storage_type_add_cb(storage_parse_storage_type);
- sg_platf_mount_add_cb(storage_parse_mount);*/
+static XBT_INLINE void surf_storage_resource_free(void *r)
+{
+ // specific to storage
+ StoragePtr storage = (StoragePtr) r;
+ xbt_dict_free(&storage->p_content);
+ xbt_dynar_free(&storage->p_writeActions);
+ // generic resource
+ delete storage;
}
-/***********
- * PARSING *
- ***********/
+static XBT_INLINE void routing_storage_host_free(void *r)
+{
+ xbt_dynar_t dyn = (xbt_dynar_t) r;
+ xbt_dynar_free(&dyn);
+}
static void parse_storage_init(sg_platf_storage_cbarg_t storage)
{
xbt_dynar_push(mount_list,&mnt);
}
-static XBT_INLINE void routing_storage_type_free(void *r)
+static void storage_define_callbacks()
{
- storage_type_t stype = (storage_type_t) r;
- free(stype->model);
- free(stype->type_id);
- free(stype->content);
- xbt_dict_free(&(stype->properties));
- free(stype);
+ sg_platf_storage_add_cb(parse_storage_init);
+ sg_platf_storage_type_add_cb(parse_storage_type_init);
+ sg_platf_mstorage_add_cb(parse_mstorage_init);
+ sg_platf_mount_add_cb(parse_mount_init);
}
-static XBT_INLINE void surf_storage_resource_free(void *r)
-{
- // specific to storage
- StoragePtr storage = (StoragePtr) r;
- xbt_dict_free(&storage->p_content);
- xbt_dynar_free(&storage->p_writeActions);
- // generic resource
- delete storage;
-}
+void storage_register_callbacks() {
-static XBT_INLINE void routing_storage_host_free(void *r)
-{
- xbt_dynar_t dyn = (xbt_dynar_t) r;
- xbt_dynar_free(&dyn);
+ ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,xbt_free);
+ ROUTING_STORAGE_HOST_LEVEL = xbt_lib_add_level(storage_lib, routing_storage_host_free);
+ ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib, routing_storage_type_free);
+ SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, surf_storage_resource_free);
+
+ sg_platf_storage_add_cb(storage_parse_storage);
+ sg_platf_mstorage_add_cb(storage_parse_mstorage);
+ sg_platf_storage_type_add_cb(storage_parse_storage_type);
+ sg_platf_mount_add_cb(storage_parse_mount);
}
/*********
void surf_storage_model_init_default(void)
{
- new StorageModel();
+ surf_storage_model = new StorageModel();
+ storage_define_callbacks();
+ xbt_dynar_push(model_list, &surf_storage_model);
}
StorageModel::StorageModel() : Model("Storage"){
StorageActionLmm action;
+
+ XBT_DEBUG("surf_storage_model_init_internal");
+
storage_running_action_set_that_does_not_need_being_checked =
xbt_swag_new(xbt_swag_offset(action, p_stateHookup));
if (!storage_maxmin_system) {
storage_maxmin_system = lmm_system_new(storage_selective_update);
}
- xbt_dynar_push(model_list, this);
-
- sg_platf_storage_add_cb(parse_storage_init);
- sg_platf_storage_type_add_cb(parse_storage_type_init);
- sg_platf_mstorage_add_cb(parse_mstorage_init);
- sg_platf_mount_add_cb(parse_mount_init);
-
- ROUTING_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,xbt_free);
- ROUTING_STORAGE_HOST_LEVEL = xbt_lib_add_level(storage_lib,routing_storage_host_free);
- ROUTING_STORAGE_TYPE_LEVEL = xbt_lib_add_level(storage_type_lib,routing_storage_type_free);
- SURF_STORAGE_LEVEL = xbt_lib_add_level(storage_lib,surf_storage_resource_free);
-
- sg_platf_storage_add_cb(storage_parse_storage);
- sg_platf_mstorage_add_cb(storage_parse_mstorage);
- sg_platf_storage_type_add_cb(storage_parse_storage_type);
- sg_platf_mount_add_cb(storage_parse_mount);
}
"Storage '%s' declared several times in the platform file",
id);
- StoragePtr storage ;//= new Storage();
-
storage_type_t storage_type = (storage_type_t) xbt_lib_get_or_null(storage_type_lib, type_id,ROUTING_STORAGE_TYPE_LEVEL);
+
double Bread = atof((char*)xbt_dict_get(storage_type->properties, "Bread"));
double Bwrite = atof((char*)xbt_dict_get(storage_type->properties, "Bwrite"));
- double Bconnection = atof((char*)xbt_dict_get(storage_type->properties, "Bconnection"));
- XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%lu'", Bconnection, Bread, Bwrite, (unsigned long)storage_type->size);
- storage->p_constraint = lmm_constraint_new(storage_maxmin_system, storage, Bconnection);
- /* TOREPAIR: storage->constraint = lmm_constraint_new(storage_maxmin_system, storage, Bconnection);
- storage->constraint_read = lmm_constraint_new(storage_maxmin_system, storage, Bread);
- storage->constraint_write = lmm_constraint_new(storage_maxmin_system, storage, Bwrite);*/
- storage->p_content = parseContent((char*)content_name, &(storage->m_usedSize));
- storage->m_size = storage_type->size;
+ double Bconnection = atof((char*)xbt_dict_get(storage_type->properties, "Bconnection"));
+
+ StoragePtr storage = new StorageLmm(this, NULL, NULL, p_maxminSystem,
+ Bread, Bwrite, Bconnection,
+ parseContent((char*)content_name, &(storage->m_usedSize)),
+ storage_type->size);
xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);
p_writeActions = xbt_dynar_new(sizeof(char *),NULL);
}
+StorageLmm::StorageLmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
+ lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
+ xbt_dict_t content, size_t size)
+ : ResourceLmm(), Storage(model, name, properties) {
+ XBT_DEBUG("Create resource with Bconnection '%f' Bread '%f' Bwrite '%f' and Size '%lu'", bconnection, bread, bwrite, ((unsigned long)size));
+
+ p_constraint = lmm_constraint_new(maxminSystem, this, bconnection);
+ p_constraintRead = lmm_constraint_new(maxminSystem, this, bread);
+ p_constraintWrite = lmm_constraint_new(maxminSystem, this, bwrite);
+ p_content = content;
+ m_size = size;
+}
+
bool Storage::isUsed()
{
THROW_UNIMPLEMENTED;
THROW_UNIMPLEMENTED;
}
-StorageActionLmmPtr Storage::ls(const char* path)
+StorageActionPtr StorageLmm::ls(const char* path)
{
- StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, m_stateCurrent != SURF_RESOURCE_ON, this, LS);
+ StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, LS);
action->p_lsDict = NULL;
xbt_dict_t ls_dict = xbt_dict_new();
return action;
}
-StorageActionLmmPtr Storage::open(const char* mount, const char* path)
+StorageActionPtr StorageLmm::open(const char* mount, const char* path)
{
XBT_DEBUG("\tOpen file '%s'",path);
size_t size = (size_t) xbt_dict_get_or_null(p_content, path);
file->size = size;
file->storage = xbt_strdup(mount);
- StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, m_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
+ StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, OPEN);
action->p_file = file;
return action;
}
-StorageActionLmmPtr Storage::close(surf_file_t fd)
+StorageActionPtr StorageLmm::close(surf_file_t fd)
{
char *filename = fd->name;
XBT_DEBUG("\tClose file '%s' size '%zu'", filename, fd->size);
free(fd->name);
free(fd->storage);
xbt_free(fd);
- StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, m_stateCurrent != SURF_RESOURCE_ON, this, CLOSE);
+ StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, CLOSE);
return action;
}
-StorageActionLmmPtr Storage::read(void* ptr, size_t size, surf_file_t fd)
+StorageActionPtr StorageLmm::read(void* ptr, size_t size, surf_file_t fd)
{
if(size > fd->size)
size = fd->size;
- StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, m_stateCurrent != SURF_RESOURCE_ON, this, READ);
+ StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, READ);
return action;
}
-StorageActionLmmPtr Storage::write(const void* ptr, size_t size, surf_file_t fd)
+StorageActionPtr StorageLmm::write(const void* ptr, size_t size, surf_file_t fd)
{
char *filename = fd->name;
XBT_DEBUG("\tWrite file '%s' size '%zu/%zu'",filename,size,fd->size);
- StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, m_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
+ StorageActionLmmPtr action = new StorageActionLmm(p_model, 0, p_stateCurrent != SURF_RESOURCE_ON, this, WRITE);
action->p_file = fd;
// If the storage is full
* Action *
**********/
-StorageActionLmm::StorageActionLmm(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type)
- : ActionLmm(model, cost, failed), p_storage(storage), m_type(type) {
+StorageActionLmm::StorageActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type)
+ : ActionLmm(model, cost, failed), StorageAction(model, cost, failed, storage, type) {
XBT_IN("(%s,%zu", storage->m_name, cost);
// Must be less than the max bandwidth for all actions
lmm_expand(storage_maxmin_system, storage->p_constraint, p_variable, 1.0);
{
m_refcount--;
if (!m_refcount) {
- xbt_swag_remove(this, p_stateSet);
+ xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
if (p_variable)
lmm_variable_free(storage_maxmin_system, p_variable);
#ifdef HAVE_TRACING
return;
}
-
-
void StorageActionLmm::suspend()
{
XBT_IN("(%p)", this);
class Storage;
typedef Storage *StoragePtr;
+class StorageLmm;
+typedef StorageLmm *StorageLmmPtr;
+
+class StorageAction;
+typedef StorageAction *StorageActionPtr;
+
class StorageActionLmm;
typedef StorageActionLmm *StorageActionLmmPtr;
+
/*********
* Model *
*********/
* Resource *
************/
-class Storage : public ResourceLmm {
+class Storage : virtual public Resource {
public:
Storage(StorageModelPtr model, const char* name, xbt_dict_t properties);
bool isUsed();
void updateState(tmgr_trace_event_t event_type, double value, double date);
- lmm_constraint_t p_constraintWrite; /* Constraint for maximum write bandwidth*/
- lmm_constraint_t p_constraintRead; /* Constraint for maximum write bandwidth*/
xbt_dict_t p_content; /* char * -> s_surf_file_t */
- StorageActionLmmPtr open(const char* mount, const char* path);
- StorageActionLmmPtr close(surf_file_t fd);
- StorageActionLmmPtr unlink(surf_file_t fd);
- StorageActionLmmPtr ls(const char *path);
- size_t getSize(surf_file_t fd);
- StorageActionLmmPtr read(void* ptr, size_t size, surf_file_t fd);//FIXME:why we have a useless param ptr ??
- StorageActionLmmPtr write(const void* ptr, size_t size, surf_file_t fd);//FIXME:why we have a useless param ptr ??
+ virtual StorageActionPtr open(const char* mount, const char* path)=0;
+ virtual StorageActionPtr close(surf_file_t fd)=0;
+ //virtual StorageActionPtr unlink(surf_file_t fd)=0;
+ virtual StorageActionPtr ls(const char *path)=0;
+ //virtual size_t getSize(surf_file_t fd);
+ virtual StorageActionPtr read(void* ptr, size_t size, surf_file_t fd)=0;//FIXME:why we have a useless param ptr ??
+ virtual StorageActionPtr write(const void* ptr, size_t size, surf_file_t fd)=0;//FIXME:why we have a useless param ptr ??
size_t m_size;
size_t m_usedSize;
xbt_dynar_t p_writeActions;
};
+class StorageLmm : public ResourceLmm, public Storage {
+public:
+ StorageLmm(StorageModelPtr model, const char* name, xbt_dict_t properties,
+ lmm_system_t maxminSystem, double bread, double bwrite, double bconnection,
+ xbt_dict_t content, size_t size);
+
+ StorageActionPtr open(const char* mount, const char* path);
+ StorageActionPtr close(surf_file_t fd);
+ //StorageActionPtr unlink(surf_file_t fd);
+ StorageActionPtr ls(const char *path);
+ //size_t getSize(surf_file_t fd);
+ StorageActionPtr read(void* ptr, size_t size, surf_file_t fd);//FIXME:why we have a useless param ptr ??
+ StorageActionPtr write(const void* ptr, size_t size, surf_file_t fd);//FIXME:why we have a useless param ptr ??
+
+ lmm_constraint_t p_constraintWrite; /* Constraint for maximum write bandwidth*/
+ lmm_constraint_t p_constraintRead; /* Constraint for maximum write bandwidth*/
+};
+
/**********
* Action *
**********/
READ=0, WRITE, STAT, OPEN, CLOSE, LS
} e_surf_action_storage_type_t;
-class StorageActionLmm : public ActionLmm {
+
+class StorageAction : virtual public Action {
public:
- StorageActionLmm(){};
- StorageActionLmm(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type);
+ StorageAction(){};
+ StorageAction(ModelPtr model, double cost, bool failed, StoragePtr storage, e_surf_action_storage_type_t type){};
+
+
+ e_surf_action_storage_type_t m_type;
+ StoragePtr p_storage;
+ surf_file_t p_file;
+ xbt_dict_t p_lsDict;
+};
+
+class StorageActionLmm : public ActionLmm, public StorageAction {
+public:
+ StorageActionLmm(){};
+ StorageActionLmm(ModelPtr model, double cost, bool failed, StorageLmmPtr storage, e_surf_action_storage_type_t type);
+ void suspend();
int unref();
void cancel();
//FIXME:??void recycle();
- void suspend();
void resume();
bool isSuspended();
void setMaxDuration(double duration);
void setPriority(double priority);
- e_surf_action_storage_type_t m_type;
- StoragePtr p_storage;
- surf_file_t p_file;
- xbt_dict_t p_lsDict;
};
#include "surf_private.h"
#include "surf.hpp"
+#include "network.hpp"
#include "cpu.hpp"
+#include "workstation.hpp"
#include "simix/smx_host_private.h"
#include "surf_routing.hpp"
#include "simgrid/sg_config.h"
xbt_dict_free(&elm);
}
-static XBT_INLINE void surf_resource_free(void *r)
+static XBT_INLINE void surf_cpu_free(void *r)
{
- ResourcePtr resource = (ResourcePtr) r;
- delete resource;
+ delete static_cast<CpuPtr>(r);
}
+static XBT_INLINE void surf_link_free(void *r)
+{
+ delete static_cast<NetworkCm02LinkPtr>(r);
+}
+
+static XBT_INLINE void surf_workstation_free(void *r)
+{
+ delete static_cast<WorkstationCLM03Ptr>(r);
+}
+
+
void sg_version(int *ver_major,int *ver_minor,int *ver_patch) {
*ver_major = SIMGRID_VERSION_MAJOR;
*ver_minor = SIMGRID_VERSION_MINOR;
ROUTING_PROP_ASR_LEVEL = xbt_lib_add_level(as_router_lib,routing_asr_prop_free);
XBT_DEBUG("Add SURF levels");
- SURF_CPU_LEVEL = xbt_lib_add_level(host_lib,surf_resource_free);
- SURF_WKS_LEVEL = xbt_lib_add_level(host_lib,surf_resource_free);
- SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_resource_free);
+ SURF_CPU_LEVEL = xbt_lib_add_level(host_lib,surf_cpu_free);
+ SURF_WKS_LEVEL = xbt_lib_add_level(host_lib,surf_workstation_free);
+ SURF_LINK_LEVEL = xbt_lib_add_level(link_lib,surf_link_free);
xbt_init(argc, argv);
if (!model_list)
double Model::shareResources(double now)
{
- //FIXME: to implement
+ //FIXME: set the good function once and for all
+ if (p_updateMechanism == UM_LAZY)
+ shareResourcesLazy(now);
+ else if (p_updateMechanism == UM_FULL)
+ shareResourcesFull(now);
+ else
+ xbt_die("Invalid cpu update mechanism!");
}
double Model::shareResourcesLazy(double now)
return min;
}
+double Model::shareResourcesFull(double now) {
+ THROW_UNIMPLEMENTED;
+}
+
+
double Model::shareResourcesMaxMin(xbt_swag_t running_actions,
size_t offset,
lmm_system_t sys,
Resource::Resource(){
//FIXME:free(m_name);
- xbt_dict_free(&m_properties);
+ //FIXME:xbt_dict_free(&m_properties);
}
const char *Resource::getName()
e_surf_resource_state_t Resource::getState()
{
- return m_stateCurrent;
+ return p_stateCurrent;
}
bool Resource::isOn()
return m_remains == 0 ? m_finish : -1;
}
+double Action::getRemains()
+{
+ XBT_IN("(%p)", this);
+ XBT_OUT();
+ return m_remains;
+}
+
void Action::setData(void* data)
{
p_data = data;
int ActionLmm::unref(){
m_refcount--;
if (!m_refcount) {
- xbt_swag_remove(this, p_stateSet);
+ xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
if (p_variable)
lmm_variable_free(p_model->p_maxminSystem, p_variable);
if (p_model->p_updateMechanism == UM_LAZY) {
m_indexHeap = i;
}
-
double ActionLmm::getRemains()
{
XBT_IN("(%p)", this);
/* update remains before return it */
- if (p_updateMechanism == UM_LAZY) /* update remains before return it */
+ if (p_model->p_updateMechanism == UM_LAZY) /* update remains before return it */
updateRemainingLazy(surf_get_clock());
XBT_OUT();
return m_remains;
}
+//FIXME split code in the right places
+void ActionLmm::updateRemainingLazy(double now)
+{
+ double delta = 0.0;
+
+ if(p_model == static_cast<ModelPtr>(surf_network_model))
+ {
+ if (m_suspended != 0)
+ return;
+ }
+ else
+ {
+ xbt_assert(p_stateSet == p_model->p_runningActionSet,
+ "You're updating an action that is not running.");
+
+ /* bogus priority, skip it */
+ xbt_assert(m_priority > 0,
+ "You're updating an action that seems suspended.");
+ }
+
+ delta = now - m_lastUpdate;
+
+ if (m_remains > 0) {
+ XBT_DEBUG("Updating action(%p): remains was %lf, last_update was: %lf", this, m_remains, m_lastUpdate);
+ double_update(&m_remains, m_lastValue * delta);
+
+#ifdef HAVE_TRACING
+ if (p_model == static_cast<ModelPtr>(surf_cpu_model) && TRACE_is_enabled()) {
+ ResourcePtr cpu = static_cast<ResourcePtr>(lmm_constraint_id(lmm_get_cnst_from_var(p_model->p_maxminSystem, p_variable, 0)));
+ TRACE_surf_host_set_utilization(cpu->m_name, p_category, m_lastValue, m_lastUpdate, now - m_lastUpdate);
+ }
+#endif
+ XBT_DEBUG("Updating action(%p): remains is now %lf", this, m_remains);
+ }
+
+ if(p_model == static_cast<ModelPtr>(surf_network_model))
+ {
+ if (m_maxDuration != NO_MAX_DURATION)
+ double_update(&m_maxDuration, delta);
+
+ //FIXME: duplicated code
+ if ((m_remains <= 0) &&
+ (lmm_get_variable_weight(p_variable) > 0)) {
+ m_finish = surf_get_clock();
+ setState(SURF_ACTION_DONE);
+ heapRemove(p_model->p_actionHeap);
+ } else if (((m_maxDuration != NO_MAX_DURATION)
+ && (m_maxDuration <= 0))) {
+ m_finish = surf_get_clock();
+ setState(SURF_ACTION_DONE);
+ heapRemove(p_model->p_actionHeap);
+ }
+ }
+
+ m_lastUpdate = now;
+ m_lastValue = lmm_variable_getvalue(p_variable);
+}
+
/*void Action::cancel()
{
p_model->notifyActionCancel(this);
ResourcePtr createResource(string name);
ActionPtr createAction(double _cost, bool _failed);
virtual double shareResources(double now);
- double shareResourcesLazy(double now);
- //double shareResourcesFull(double now);
+ virtual double shareResourcesLazy(double now);
+ virtual double shareResourcesFull(double now);
double shareResourcesMaxMin(xbt_swag_t running_actions,
size_t offset,
lmm_system_t sys,
void (*solve) (lmm_system_t));
- void updateActionsState(double now, double delta);
- void updateActionsStateLazy(double now, double delta);
- void updateActionsStateFull(double now, double delta);
+ virtual void updateActionsState(double now, double delta);
+ virtual void updateActionsStateLazy(double now, double delta);
+ virtual void updateActionsStateFull(double now, double delta);
string getName() {return m_name;};
//private
virtual bool isUsed()=0;
- //TODOupdateActionState();
- //TODOupdateResourceState();
- //TODOfinilize();
+ //FIXME:updateActionState();
+ //FIXME:updateResourceState();
+ //FIXME:finilize();
bool isOn();
void turnOn();
e_surf_resource_state_t getState();
void printModel() { std::cout << p_model->getName() << "<<plop"<<std::endl;};
void *p_resource;
- e_surf_resource_state_t m_stateCurrent;
const char *m_name;
xbt_dict_t m_properties;
ModelPtr p_model;
+ e_surf_resource_state_t p_stateCurrent;
protected:
double metric_peak,
tmgr_trace_t metric_trace);
lmm_constraint_t p_constraint;
- e_surf_resource_state_t p_stateCurrent;
tmgr_trace_event_t p_stateEvent;
s_surf_metric_t p_power;
};
#ifdef HAVE_TRACING
void setCategory(const char *category); /**< Set the category of an action */
#endif
- double getRemains(); /**< Get the remains of an action */
+ virtual double getRemains(); /**< Get the remains of an action */
#ifdef HAVE_LATENCY_BOUND_TRACKING
int getLatencyLimited(); /**< Return 1 if action is limited by latency, 0 otherwise */
#endif
ActionLmm() : m_suspended(false) {};
ActionLmm(ModelPtr model, double cost, bool failed) : m_suspended(false) {};
- void updateRemainingLazy(double now) {};//FIXME:
+ virtual void updateRemainingLazy(double now);
void heapInsert(xbt_heap_t heap, double key, enum heap_action_type hat);
void heapRemove(xbt_heap_t heap);
double getRemains(); /**< Get the remains of an action */
void updateIndexHeap(int i);
- int unref();
+ virtual int unref();
void cancel();
void suspend();
void resume();
*********/
extern double NOW;
+char *surf_routing_edge_name(sg_routing_edge_t edge){
+ return edge->p_name;
+}
+
#ifdef CONTEXT_THREADS
static xbt_parmap_t surf_parmap = NULL; /* parallel map on models */
#endif
/* sequential version */
xbt_dynar_foreach(model_list, iter, model) {
- surf_share_resources(model);
+ surf_share_resources(static_cast<ModelPtr>(model));
}
unsigned i;
return link->getLatency();
}
+const char *surf_cpu_name(surf_cpu_t resource){
+ return resource->m_name;
+}
+
surf_action_t surf_cpu_execute(surf_cpu_t cpu, double size){
return cpu->execute(size);
}
/* Check whether a direct bypass is defined */
sg_platf_route_cbarg_t e_route_bypass = NULL;
//FIXME:REMOVE:if (common_father->get_bypass_route)
+ common_father->test();
+
e_route_bypass = common_father->getBypassRoute(src, dst, latency);
/* Common ancestor is kind enough to declare a bypass route from src to dst -- use it and bail out */
As(){};
~As(){};
+ int test(){return 3;};
virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency)=0;
virtual xbt_dynar_t getOneLinkRoutes()=0;
virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges)=0;
#include "surf_routing_private.h"
+#include "surf_routing_full.hpp"
+#include "network.hpp"
extern "C" {
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route_full, surf, "Routing part of surf");
}
+/* Global vars */
+extern routing_platf_t routing_platf;
+extern int surf_parse_lineno;
+
+#define TO_ROUTE_FULL(i,j) p_routingTable[(i)+(j)*table_size]
+
AS_t model_full_create(void)
-{//FIXME:
+{
+ return new AsFull();
+}
+
+void model_full_end(AS_t _routing)
+{
+ unsigned int i;
+ sg_platf_route_cbarg_t e_route;
+
+ /* set utils vars */
+ AsFullPtr routing = ((AsFullPtr) _routing);
+ size_t table_size = xbt_dynar_length(routing->p_indexNetworkElm);
+
+ /* Create table if necessary */
+ if (!routing->p_routingTable)
+ routing->p_routingTable = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
+
+ /* Add the loopback if needed */
+ if (routing_platf->p_loopback && routing->p_hierarchy == SURF_ROUTING_BASE) {
+ for (i = 0; i < table_size; i++) {
+ e_route = routing->TO_ROUTE_FULL(i, i);
+ if (!e_route) {
+ e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
+ e_route->gw_src = NULL;
+ e_route->gw_dst = NULL;
+ e_route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+ xbt_dynar_push(e_route->link_list, &routing_platf->p_loopback);
+ routing->TO_ROUTE_FULL(i, i) = e_route;
+ }
+ }
+ }
+}
+
+AsFull::AsFull(){
+}
+
+AsFull::~AsFull(){
+ size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+ int i, j;
+ /* Delete routing table */
+ for (i = 0; i < table_size; i++)
+ for (j = 0; j < table_size; j++)
+ delete TO_ROUTE_FULL(i,j);
+ xbt_free(p_routingTable);
+}
+
+xbt_dynar_t AsFull::getOneLinkRoutes()
+{
+ xbt_dynar_t ret = xbt_dynar_new(sizeof(onelink_t), xbt_free);
+
+ int src, dst;
+ int table_size = xbt_dynar_length(p_indexNetworkElm);
+
+ for(src=0; src < table_size; src++) {
+ for(dst=0; dst< table_size; dst++) {
+ sg_platf_route_cbarg_t route = TO_ROUTE_FULL(src,dst);
+ if (route) {
+ if (xbt_dynar_length(route->link_list) == 1) {
+ void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);
+ onelink_t onelink = xbt_new0(s_onelink_t, 1);
+ onelink->link_ptr = link;
+ if (p_hierarchy == SURF_ROUTING_BASE) {
+ onelink->src = xbt_dynar_get_as(p_indexNetworkElm, src, sg_routing_edge_t);
+ onelink->src->m_id = src;
+ onelink->dst = xbt_dynar_get_as(p_indexNetworkElm, dst, sg_routing_edge_t);
+ onelink->dst->m_id = dst;
+ } else if (p_hierarchy == SURF_ROUTING_RECURSIVE) {
+ onelink->src = route->gw_src;
+ onelink->dst = route->gw_dst;
+ }
+ xbt_dynar_push(ret, &onelink);
+ XBT_DEBUG("Push route from '%d' to '%d'",
+ src,
+ dst);
+ }
+ }
+ }
+ }
+ return ret;
+}
+
+void AsFull::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t res, double *lat)
+{
+ XBT_DEBUG("full_get_route_and_latency from %s[%d] to %s[%d]",
+ src->p_name,
+ src->m_id,
+ dst->p_name,
+ dst->m_id );
+
+ /* set utils vars */
+ size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+
+ sg_platf_route_cbarg_t e_route = NULL;
+ NetworkCm02LinkPtr link;
+ unsigned int cpt = 0;
+
+ e_route = TO_ROUTE_FULL(src->m_id, dst->m_id);
+
+ if (e_route) {
+ res->gw_src = e_route->gw_src;
+ res->gw_dst = e_route->gw_dst;
+ xbt_dynar_foreach(e_route->link_list, cpt, link) {
+ xbt_dynar_push(res->link_list, &link);
+ if (lat)
+ *lat += link->getLatency();
+ }
+ }
+}
+
+void AsFull::parseASroute(sg_platf_route_cbarg_t route){
+ parseRoute(route);
+}
+
+static int full_pointer_resource_cmp(const void *a, const void *b)
+{
+ return a != b;
+}
+
+void AsFull::parseRoute(sg_platf_route_cbarg_t route)
+{
+ int as_route = 0;
+ char *src = (char*)(route->src);
+ char *dst = (char*)(route->dst);
+ RoutingEdgePtr src_net_elm, dst_net_elm;
+ src_net_elm = sg_routing_edge_by_name_or_null(src);
+ dst_net_elm = sg_routing_edge_by_name_or_null(dst);
+
+ xbt_assert(src_net_elm, "Network elements %s not found", src);
+ xbt_assert(dst_net_elm, "Network elements %s not found", dst);
+
+ size_t table_size = xbt_dynar_length(p_indexNetworkElm);
+
+ xbt_assert(!xbt_dynar_is_empty(route->link_list),
+ "Invalid count of links, must be greater than zero (%s,%s)",
+ src, dst);
+
+ if (!p_routingTable)
+ p_routingTable = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);
+
+ if (TO_ROUTE_FULL(src_net_elm->m_id, dst_net_elm->m_id)) {
+ char *link_name;
+ unsigned int i;
+ xbt_dynar_t link_route_to_test =
+ xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+ xbt_dynar_foreach(route->link_list, i, link_name) {
+ void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL);
+ xbt_assert(link, "Link : '%s' doesn't exists.", link_name);
+ xbt_dynar_push(link_route_to_test, &link);
+ }
+ if (xbt_dynar_compare(TO_ROUTE_FULL(src_net_elm->m_id, dst_net_elm->m_id)->link_list,
+ link_route_to_test, full_pointer_resource_cmp)) {
+ surf_parse_error("A route between \"%s\" and \"%s\" already exists "
+ "with a different content. "
+ "If you are trying to define a reverse route, "
+ "you must set the symmetrical=no attribute to "
+ "your routes tags.", src, dst);
+ } else {
+ surf_parse_warn("Ignoring the identical redefinition of the route "
+ "between \"%s\" and \"%s\"", src, dst);
+ }
+ } else {
+ if (!route->gw_dst && !route->gw_dst)
+ XBT_DEBUG("Load Route from \"%s\" to \"%s\"", src, dst);
+ else {
+ // FIXME We can call a gw which is down the current AS (cf g5k.xml) but not upper.
+ // AS_t subas = xbt_dict_get_or_null(rc->routing_sons, src);
+ // if (subas == NULL)
+ // surf_parse_error("The source of an ASroute must be a sub-AS "
+ // "declared within the current AS, "
+ // "but '%s' is not an AS within '%s'", src, rc->name);
+ // if (subas->to_index
+ // && xbt_dict_get_or_null(subas->to_index, route->src_gateway) == NULL)
+ // surf_parse_error("In an ASroute, source gateway must be part of "
+ // "the source sub-AS (in particular, being in a "
+ // "sub-sub-AS is not allowed), "
+ // "but '%s' is not in '%s'.",
+ // route->src_gateway, subas->name);
+ //
+ // subas = xbt_dict_get_or_null(rc->routing_sons, dst);
+ // if (subas == NULL)
+ // surf_parse_error("The destination of an ASroute must be a sub-AS "
+ // "declared within the current AS, "
+ // "but '%s' is not an AS within '%s'", dst, rc->name);
+ // if (subas->to_index
+ // && xbt_dict_get_or_null(subas->to_index, route->dst_gateway) == NULL)
+ // surf_parse_error("In an ASroute, destination gateway must be "
+ // "part of the destination sub-AS (in particular, "
+ // "in a sub-sub-AS is not allowed), "
+ // "but '%s' is not in '%s'.",
+ // route->dst_gateway, subas->name);
+ as_route = 1;
+ XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",
+ src, route->gw_src->p_name, dst, route->gw_dst->p_name);
+ if (route->gw_dst->p_rcType == SURF_NETWORK_ELEMENT_NULL)
+ xbt_die("The dst_gateway '%s' does not exist!", route->gw_dst->p_name);
+ if (route->gw_src->p_rcType == SURF_NETWORK_ELEMENT_NULL)
+ xbt_die("The src_gateway '%s' does not exist!", route->gw_src->p_name);
+ }
+ TO_ROUTE_FULL(src_net_elm->m_id, dst_net_elm->m_id) = newExtendedRoute(p_hierarchy, route, 1);
+ xbt_dynar_shrink(TO_ROUTE_FULL(src_net_elm->m_id, dst_net_elm->m_id)->link_list, 0);
+ }
+
+ if ( (route->symmetrical == TRUE && as_route == 0)
+ || (route->symmetrical == TRUE && as_route == 1)
+ ) {
+ if (route->gw_dst && route->gw_src) {
+ sg_routing_edge_t gw_tmp;
+ gw_tmp = route->gw_src;
+ route->gw_src = route->gw_dst;
+ route->gw_dst = gw_tmp;
+ }
+ if (TO_ROUTE_FULL(dst_net_elm->m_id, src_net_elm->m_id)) {
+ char *link_name;
+ unsigned int i;
+ xbt_dynar_t link_route_to_test =
+ xbt_dynar_new(sizeof(sg_routing_link_t), NULL);
+ for (i = xbt_dynar_length(route->link_list); i > 0; i--) {
+ link_name = xbt_dynar_get_as(route->link_list, i - 1, char *);
+ void *link = xbt_lib_get_or_null(link_lib, link_name, SURF_LINK_LEVEL);
+ xbt_assert(link, "Link : '%s' doesn't exists.", link_name);
+ xbt_dynar_push(link_route_to_test, &link);
+ }
+ xbt_assert(!xbt_dynar_compare(TO_ROUTE_FULL(dst_net_elm->m_id, src_net_elm->m_id)->link_list,
+ link_route_to_test,
+ full_pointer_resource_cmp),
+ "The route between \"%s\" and \"%s\" already exists", src,
+ dst);
+ } else {
+ if (!route->gw_dst && !route->gw_src)
+ XBT_DEBUG("Load Route from \"%s\" to \"%s\"", dst, src);
+ else
+ XBT_DEBUG("Load ASroute from \"%s(%s)\" to \"%s(%s)\"",
+ dst, route->gw_src->p_name, src, route->gw_dst->p_name);
+ TO_ROUTE_FULL(dst_net_elm->m_id, src_net_elm->m_id) = newExtendedRoute(p_hierarchy, route, 0);
+ xbt_dynar_shrink(TO_ROUTE_FULL(dst_net_elm->m_id, src_net_elm->m_id)->link_list, 0);
+ }
+ }
+ xbt_dynar_free(&route->link_list);
}
-void model_full_end(AS_t current_routing)
-{}
+
+
+
--- /dev/null
+#include "surf_routing_generic.hpp"
+
+#ifndef SURF_ROUTING_FULL_HPP_
+#define SURF_ROUTING_FULL_HPP_
+
+/***********
+ * Classes *
+ ***********/
+class AsFull;
+typedef AsFull *AsFullPtr;
+
+class AsFull: public AsGeneric {
+public:
+ sg_platf_route_cbarg_t *p_routingTable;
+
+ AsFull();
+ ~AsFull();
+ int test(){return 1;};
+
+ void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
+ xbt_dynar_t getOneLinkRoutes();
+ void parseRoute(sg_platf_route_cbarg_t route);
+ void parseASroute(sg_platf_route_cbarg_t route);
+
+ //void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
+ //sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
+
+ /* The parser calls the following functions to inform the routing models
+ * that a new element is added to the AS currently built.
+ *
+ * Of course, only the routing model of this AS is informed, not every ones */
+ //virtual int parsePU(RoutingEdgePtr elm)=0; /* A host or a router, whatever */
+ //virtual int parseAS( RoutingEdgePtr elm)=0;
+
+ //virtual void parseBypassroute(sg_platf_route_cbarg_t e_route)=0;
+};
+
+
+#endif /* SURF_ROUTING_FULL_HPP_ */
THROW_IMPOSSIBLE;
}
-xbt_dynar_t AsGeneric::getOneLinkRoutes(){
- THROW_IMPOSSIBLE;
-}
-
AsGeneric::AsGeneric() {
p_bypassRoutes = xbt_dict_new_homogeneous((void (*)(void *)) generic_free_route);
}
/* ************************************************************************** */
/* *********************** GENERIC BUSINESS METHODS ************************* */
-xbt_dynar_t AsGeneric::getOnelinkRoutes() { // FIXME: kill that stub
+xbt_dynar_t AsGeneric::getOneLinkRoutes() { // FIXME: kill that stub
xbt_die("\"generic_get_onelink_routes\" not implemented yet");
return NULL;
}
public:
AsGeneric();
~AsGeneric();
- void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
- xbt_dynar_t getOneLinkRoutes();
- void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
- sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
- void finalize();
+ int test(){return 2;};
+
+ virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
+ virtual xbt_dynar_t getOneLinkRoutes();
+ virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
+ virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
/* The parser calls the following functions to inform the routing models
* that a new element is added to the AS currently built.
*
* Of course, only the routing model of this AS is informed, not every ones */
- int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */
- int parseAS( RoutingEdgePtr elm);
- void parseRoute(sg_platf_route_cbarg_t route);
- void parseASroute(sg_platf_route_cbarg_t route);
- void parseBypassroute(sg_platf_route_cbarg_t e_route);
+ virtual int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */
+ virtual int parseAS( RoutingEdgePtr elm);
+ virtual void parseRoute(sg_platf_route_cbarg_t route);
+ virtual void parseASroute(sg_platf_route_cbarg_t route);
+ virtual void parseBypassroute(sg_platf_route_cbarg_t e_route);
- xbt_dynar_t getOnelinkRoutes();
- sg_platf_route_cbarg_t getBypassroute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
- sg_platf_route_cbarg_t newExtendedRoute(e_surf_routing_hierarchy_t hierarchy, sg_platf_route_cbarg_t routearg, int change_order);
- AsPtr asExist(AsPtr to_find);
- AsPtr autonomousSystemExist(char *element);
- AsPtr processingUnitsExist(char *element);
- void srcDstCheck(RoutingEdgePtr src, RoutingEdgePtr dst);
+ virtual sg_platf_route_cbarg_t newExtendedRoute(e_surf_routing_hierarchy_t hierarchy, sg_platf_route_cbarg_t routearg, int change_order);
+ virtual AsPtr asExist(AsPtr to_find);
+ virtual AsPtr autonomousSystemExist(char *element);
+ virtual AsPtr processingUnitsExist(char *element);
+ virtual void srcDstCheck(RoutingEdgePtr src, RoutingEdgePtr dst);
};
#endif /* SURF_ROUTING_GENERIC_HPP_ */
public:
AsNone();
~AsNone();
- void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
- xbt_dynar_t getOneLinkRoutes();
- void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
- sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
- void finalize();
+ virtual void getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t into, double *latency);
+ virtual xbt_dynar_t getOneLinkRoutes();
+ virtual void getGraph(xbt_graph_t graph, xbt_dict_t nodes, xbt_dict_t edges);
+ virtual sg_platf_route_cbarg_t getBypassRoute(RoutingEdgePtr src, RoutingEdgePtr dst, double *lat);
/* The parser calls the following functions to inform the routing models
* that a new element is added to the AS currently built.
*
* Of course, only the routing model of this AS is informed, not every ones */
- int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */
- int parseAS( RoutingEdgePtr elm);
- void parseRoute(sg_platf_route_cbarg_t route);
- void parseASroute(sg_platf_route_cbarg_t route);
- void parseBypassroute(sg_platf_route_cbarg_t e_route);
+ virtual int parsePU(RoutingEdgePtr elm); /* A host or a router, whatever */
+ virtual int parseAS( RoutingEdgePtr elm);
+ virtual void parseRoute(sg_platf_route_cbarg_t route);
+ virtual void parseASroute(sg_platf_route_cbarg_t route);
+ virtual void parseBypassroute(sg_platf_route_cbarg_t e_route);
};
//FIXME:Faire hériter ou composer de cup et network
+/*************
+ * CallBacks *
+ *************/
+
+static void workstation_new(sg_platf_host_cbarg_t host){
+ surf_workstation_model->createResource(host->id);
+}
+
/*********
* Model *
*********/
surf_cpu_model_init_Cas01();
surf_network_model_init_LegrandVelho();
- xbt_dynar_push(model_list, &surf_workstation_model);
- //FIXME:sg_platf_host_add_cb(workstation_new);
+ ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
+ xbt_dynar_push(model_list, &model);
+ sg_platf_host_add_cb(workstation_new);
}
void surf_workstation_model_init_compound()
xbt_assert(surf_cpu_model, "No CPU model defined yet!");
xbt_assert(surf_network_model, "No network model defined yet!");
surf_workstation_model = new WorkstationModel();
- xbt_dynar_push(model_list, &surf_workstation_model);
- //FIXME:sg_platf_host_add_cb(workstation_new);
+
+ ModelPtr model = static_cast<ModelPtr>(surf_workstation_model);
+ xbt_dynar_push(model_list, &model);
+ sg_platf_host_add_cb(workstation_new);
}
WorkstationModel::WorkstationModel() : Model("Workstation") {
- //FIXME:xbt_cfg_setdefault_boolean(_sg_cfg_set, "network/crosstraffic", xbt_strdup("yes"));
- //FIXME:surf_cpu_model_init_Cas01();
- //FIXME:surf_network_model_init_LegrandVelho();
-
- xbt_dynar_push(model_list, this);
- //FIXME:sg_platf_host_add_cb(workstation_new);
}
+WorkstationModel::~WorkstationModel() {
+}
void WorkstationModel::parseInit(sg_platf_host_cbarg_t host){
createResource(host->id);
return fd->size;
}
+e_surf_resource_state_t WorkstationCLM03Lmm::getState() {
+ return WorkstationCLM03::getState();
+}
/**********
* Action *
**********/
class WorkstationCLM03;
typedef WorkstationCLM03 *WorkstationCLM03Ptr;
+class WorkstationCLM03Lmm;
+typedef WorkstationCLM03Lmm *WorkstationCLM03LmmPtr;
+
class WorkstationAction;
typedef WorkstationAction *WorkstationActionPtr;
public:
WorkstationModel(string name): Model(name) {};
WorkstationModel();
+ ~WorkstationModel();
void parseInit(sg_platf_host_cbarg_t host);
WorkstationCLM03Ptr createResource(string name);
double shareResources(double now);
class WorkstationCLM03Lmm : public WorkstationCLM03, public ResourceLmm {
public:
WorkstationCLM03Lmm(WorkstationModelPtr model, const char* name, xbt_dict_t props): WorkstationCLM03(model, name, props, NULL, NULL, NULL){};
+ e_surf_resource_state_t getState();
};
/**********
i++))) {
constraint_id = lmm_constraint_id(cnst);
- if (((WorkstationCLM03Ptr)constraint_id)->m_stateCurrent == SURF_RESOURCE_OFF) {
+ if (((WorkstationCLM03LmmPtr)constraint_id)->p_stateCurrent == SURF_RESOURCE_OFF) {
XBT_DEBUG("Action (%p) Failed!!", action);
action->m_finish = surf_get_clock();
action->setState(SURF_ACTION_FAILED);
cpu->p_power.event =
tmgr_history_add_trace(history, power_trace, 0.0, 0, cpu);
- cpu->m_stateCurrent = state_initial;
+ cpu->p_stateCurrent = state_initial;
if (state_trace)
cpu->p_stateEvent =
tmgr_history_add_trace(history, state_trace, 0.0, 0, cpu);
{
m_refcount--;
if (!m_refcount) {
- xbt_swag_remove(this, p_stateSet);
+ xbt_swag_remove(static_cast<ActionPtr>(this), p_stateSet);
if (p_variable)
lmm_variable_free(ptask_maxmin_system, p_variable);
delete this;
cpuB = surf_cpu_resource_by_name("Cpu B");
/* Let's check that those two processors exist */
- XBT_DEBUG("%s : %p", surf_resource_name(cpuA), cpuA);
- XBT_DEBUG("%s : %p", surf_resource_name(cpuB), cpuB);
-
+ XBT_DEBUG("%s : %p", surf_cpu_name(surf_cpu_resource_priv(cpuA)), cpuA);
+ XBT_DEBUG("%s : %p", surf_cpu_name(surf_cpu_resource_priv(cpuB)), cpuB);
+ surf_cpu_resource_priv(cpuA);
/* Let's do something on it */
- actionA = surf_cpu_execute(cpuA, 1000.0);
- actionB = surf_cpu_execute(cpuB, 1000.0);
- actionC = surf_cpu_sleep(cpuB, 7.32);
+ actionA = surf_cpu_execute(surf_cpu_resource_priv(cpuA), 1000.0);
+ actionB = surf_cpu_execute(surf_cpu_resource_priv(cpuB), 1000.0);
+ actionC = surf_cpu_sleep(surf_cpu_resource_priv(cpuB), 7.32);
/* Use whatever calling style you want... */
stateActionA = surf_action_get_state(actionA); /* When you know actionA model type */
cardB = sg_routing_edge_by_name_or_null("Cpu B");
/* Let's check that those two processors exist */
- XBT_DEBUG("%s : %p", surf_resource_name(cardA), cardA);
- XBT_DEBUG("%s : %p", surf_resource_name(cardB), cardB);
+ XBT_DEBUG("%s : %p", surf_routing_edge_name(cardA), cardA);
+ XBT_DEBUG("%s : %p", surf_routing_edge_name(cardB), cardB);
/* Let's do something on it */
surf_network_model_communicate(surf_network_model, cardA, cardB, 150.0, -1.0);