git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/simgrid/simgrid/trunk@6436
48e7efb5-ca39-0410-a469-
dd3cf9ba447f
13 files changed:
* Implement a generic resource; use it as ancestor to specific ones
(allows to kill duplicated code in models)
* Implement a generic resource; use it as ancestor to specific ones
(allows to kill duplicated code in models)
- TODO: integrate the properties into that ancestor
+ Drawback: timer command don't need no name nor properties;
+ workstation_CLM03 don't need no properties
+ (but I guess we can live with those few bytes wasted)
XBT:
* Add xbt_set_get_by_name_or_null() [Silas De Munck]
XBT:
* Add xbt_set_get_by_name_or_null() [Silas De Munck]
void (*set_max_duration) (surf_action_t action, double duration);/**< Set the max duration of an action*/
void (*set_priority) (surf_action_t action, double priority);/**< Set the priority of an action */
void (*set_max_duration) (surf_action_t action, double duration);/**< Set the max duration of an action*/
void (*set_priority) (surf_action_t action, double priority);/**< Set the priority of an action */
- xbt_dict_t(*get_properties) (void *resource_id);/**< Return the properties dictionary */
typedef struct surf_resource {
surf_model_t model;
char *name;
typedef struct surf_resource {
surf_model_t model;
char *name;
} s_surf_resource_t, *surf_resource_t;
} s_surf_resource_t, *surf_resource_t;
-XBT_PUBLIC(const char*) surf_resource_name(const void *resource);
+ XBT_PUBLIC(const char*) surf_resource_name(const void *resource);
+ XBT_PUBLIC(xbt_dict_t) surf_resource_properties(const void *resource);
XBT_PUBLIC(void) surf_resource_free(void* resource);
/**************************************/
/* Implementations of model object */
XBT_PUBLIC(void) surf_resource_free(void* resource);
/**************************************/
/* Implementations of model object */
SD_CHECK_INIT_DONE();
xbt_assert0((link != NULL), "Invalid parameters");
SD_CHECK_INIT_DONE();
xbt_assert0((link != NULL), "Invalid parameters");
- return (surf_workstation_model->get_properties(link->surf_link));
+ return surf_resource_properties(link->surf_link);
SD_CHECK_INIT_DONE();
xbt_assert0((workstation != NULL), "Invalid parameters");
SD_CHECK_INIT_DONE();
xbt_assert0((workstation != NULL), "Invalid parameters");
- return (surf_workstation_model->get_properties
- (workstation->surf_workstation));
+ return surf_resource_properties(workstation->surf_workstation);
{
xbt_assert0((host != NULL), "Invalid parameters");
{
xbt_assert0((host != NULL), "Invalid parameters");
- return (surf_workstation_model->get_properties(host->simdata->host));
+ return surf_resource_properties(host->simdata->host);
e_surf_cpu_state_t state_current;
tmgr_trace_event_t state_event;
lmm_constraint_t constraint;
e_surf_cpu_state_t state_current;
tmgr_trace_event_t state_event;
lmm_constraint_t constraint;
- /*Handles the properties that can be added to cpu's */
- xbt_dict_t properties;
} s_cpu_Cas01_t, *cpu_Cas01_t;
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
} s_cpu_Cas01_t, *cpu_Cas01_t;
XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_cpu, surf,
static xbt_swag_t running_action_set_that_does_not_need_being_checked = NULL;
static xbt_swag_t running_action_set_that_does_not_need_being_checked = NULL;
-static void cpu_free(void *cpu)
-{
- xbt_dict_free(&(((cpu_Cas01_t) cpu)->properties));
- surf_resource_free(cpu);
-}
-
static cpu_Cas01_t cpu_new(char *name, double power_scale,
double power_initial,
tmgr_trace_t power_trace,
static cpu_Cas01_t cpu_new(char *name, double power_scale,
double power_initial,
tmgr_trace_t power_trace,
"Host '%s' declared several times in the platform file", name);
cpu->generic_resource.model = surf_cpu_model;
cpu->generic_resource.name = name;
"Host '%s' declared several times in the platform file", name);
cpu->generic_resource.model = surf_cpu_model;
cpu->generic_resource.name = name;
+ current_property_set = cpu->generic_resource.properties = cpu_properties;
cpu->power_scale = power_scale;
xbt_assert0(cpu->power_scale > 0, "Power has to be >0");
cpu->power_current = power_initial;
cpu->power_scale = power_scale;
xbt_assert0(cpu->power_scale > 0, "Power has to be >0");
cpu->power_current = power_initial;
lmm_constraint_new(cpu_maxmin_system, cpu,
cpu->power_current * cpu->power_scale);
lmm_constraint_new(cpu_maxmin_system, cpu,
cpu->power_current * cpu->power_scale);
- /*add the property set */
- cpu->properties = cpu_properties;
-
- current_property_set = cpu_properties;
-
- xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu, cpu_free);
+ xbt_dict_set(surf_model_resource_set(surf_cpu_model), name, cpu, surf_resource_free);
return ((cpu_Cas01_t) cpu)->power_current;
}
return ((cpu_Cas01_t) cpu)->power_current;
}
-static xbt_dict_t get_properties(void *cpu)
-{
- return ((cpu_Cas01_t) cpu)->properties;
-}
-
static void finalize(void)
{
lmm_system_free(cpu_maxmin_system);
static void finalize(void)
{
lmm_system_free(cpu_maxmin_system);
surf_cpu_model->extension.cpu.get_state = get_state;
surf_cpu_model->extension.cpu.get_speed = get_speed;
surf_cpu_model->extension.cpu.get_available_speed = get_available_speed;
surf_cpu_model->extension.cpu.get_state = get_state;
surf_cpu_model->extension.cpu.get_speed = get_speed;
surf_cpu_model->extension.cpu.get_available_speed = get_available_speed;
- /*manage the properties of the cpu */
- surf_cpu_model->get_properties = get_properties;
if (!cpu_maxmin_system)
cpu_maxmin_system = lmm_system_new();
if (!cpu_maxmin_system)
cpu_maxmin_system = lmm_system_new();
double sg_tcp_gamma = 0.0;
double sg_tcp_gamma = 0.0;
-static void link_free(void *nw_link)
-{
- xbt_dict_free(&(((link_CM02_t) nw_link)->properties));
- surf_resource_free(nw_link);
-}
static link_CM02_t link_new(char *name,
double bw_initial,
static link_CM02_t link_new(char *name,
double bw_initial,
nw_link->generic_resource.model = surf_network_model;
nw_link->generic_resource.name = 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 =
nw_link->bw_current = bw_initial;
if (bw_trace)
nw_link->bw_event =
if (policy == SURF_LINK_FATPIPE)
lmm_constraint_shared(nw_link->constraint);
if (policy == SURF_LINK_FATPIPE)
lmm_constraint_shared(nw_link->constraint);
- nw_link->properties = properties;
-
- current_property_set = properties;
-
- xbt_dict_set(surf_network_model->resource_set, name, nw_link, link_free);
+ xbt_dict_set(surf_network_model->resource_set, name, nw_link, surf_resource_free);
return lmm_constraint_is_shared(((link_CM02_t) link)->constraint);
}
return lmm_constraint_is_shared(((link_CM02_t) link)->constraint);
}
-static xbt_dict_t get_properties(void *link)
-{
- return ((link_CM02_t) link)->properties;
-}
-
static void action_suspend(surf_action_t action)
{
((surf_action_network_CM02_t) action)->suspended = 1;
static void action_suspend(surf_action_t action)
{
((surf_action_network_CM02_t) action)->suspended = 1;
surf_network_model->extension.network.get_link_latency = get_link_latency;
surf_network_model->extension.network.link_shared = link_shared;
surf_network_model->extension.network.get_link_latency = get_link_latency;
surf_network_model->extension.network.link_shared = link_shared;
- surf_network_model->get_properties = get_properties;
-
if (!network_maxmin_system)
network_maxmin_system = lmm_system_new();
if (!network_maxmin_system)
network_maxmin_system = lmm_system_new();
-static xbt_dict_t get_properties(void *link)
-{
- DIE_IMPOSSIBLE;
-}
-
static void action_suspend(surf_action_t action)
{
((surf_action_network_Constant_t) action)->suspended = 1;
static void action_suspend(surf_action_t action)
{
((surf_action_network_Constant_t) action)->suspended = 1;
surf_network_model->extension.network.get_link_latency = get_link_latency;
surf_network_model->extension.network.link_shared = link_shared;
surf_network_model->extension.network.get_link_latency = get_link_latency;
surf_network_model->extension.network.link_shared = link_shared;
- surf_network_model->get_properties = get_properties;
-
if (!random_latency)
random_latency = random_new(RAND, 100, 0.0, 1.0, .125, .034);
}
if (!random_latency)
random_latency = random_new(RAND, 100, 0.0, 1.0, .125, .034);
}
double bw_current;
double lat_current;
int id;
double bw_current;
double lat_current;
int id;
- /*holds the properties associated with the link */
- xbt_dict_t properties;
} s_network_link_GTNETS_t, *network_link_GTNETS_t;
typedef struct network_card_GTNETS {
char *name;
int id;
} s_network_link_GTNETS_t, *network_link_GTNETS_t;
typedef struct network_card_GTNETS {
char *name;
int id;
- /*holds the properties associated with the card */
- xbt_dict_t properties;
} s_network_card_GTNETS_t, *network_card_GTNETS_t;
typedef struct surf_action_network_GTNETS {
} s_network_card_GTNETS_t, *network_card_GTNETS_t;
typedef struct surf_action_network_GTNETS {
typedef struct network_link_CM02 {
s_surf_resource_t generic_resource; /* must remain first to be added to a trace */
typedef struct network_link_CM02 {
s_surf_resource_t generic_resource; /* must remain first to be added to a trace */
/* Using this object with the public part of
model does not make sense */
double bw_current;
/* Using this object with the public part of
model does not make sense */
double bw_current;
surf_resource_t resource = r;
if (resource->name)
free(resource->name);
surf_resource_t resource = r;
if (resource->name)
free(resource->name);
+ if (resource->properties)
+ xbt_dict_free(&resource->properties);
-static xbt_dict_t get_properties(void *workstation)
-{
- return surf_cpu_model->get_properties(((workstation_CLM03_t) workstation)->
- cpu);
-}
-
static surf_action_t execute_parallel_task(int workstation_nb,
void **workstation_list,
double *computation_amount,
static surf_action_t execute_parallel_task(int workstation_nb,
void **workstation_list,
double *computation_amount,
surf_workstation_model->extension.workstation.get_available_speed =
get_available_speed;
surf_workstation_model->extension.workstation.get_available_speed =
get_available_speed;
- /*manage the properties of the workstation */
- surf_workstation_model->get_properties = get_properties;
-
surf_workstation_model->extension.workstation.communicate = communicate;
surf_workstation_model->extension.workstation.get_route = get_route;
surf_workstation_model->extension.workstation.execute_parallel_task =
surf_workstation_model->extension.workstation.communicate = communicate;
surf_workstation_model->extension.workstation.get_route = get_route;
surf_workstation_model->extension.workstation.execute_parallel_task =
/**************************************/
typedef struct cpu_L07 {
s_surf_resource_t generic_resource; /* Do not move this field: must match surf_resource_t */
/**************************************/
typedef struct cpu_L07 {
s_surf_resource_t generic_resource; /* Do not move this field: must match surf_resource_t */
- xbt_dict_t properties; /* Do not move this field: must match link_L07_t */
e_surf_workstation_model_type_t type; /* Do not move this field: must match link_L07_t */
lmm_constraint_t constraint; /* Do not move this field: must match link_L07_t */
double power_scale;
e_surf_workstation_model_type_t type; /* Do not move this field: must match link_L07_t */
lmm_constraint_t constraint; /* Do not move this field: must match link_L07_t */
double power_scale;
typedef struct link_L07 {
s_surf_resource_t generic_resource; /* Do not move this field: must match surf_resource_t */
typedef struct link_L07 {
s_surf_resource_t generic_resource; /* Do not move this field: must match surf_resource_t */
- xbt_dict_t properties; /* Do not move this field: must match link_L07_t */
e_surf_workstation_model_type_t type; /* Do not move this field: must match cpu_L07_t */
lmm_constraint_t constraint; /* Do not move this field: must match cpu_L07_t */
double lat_current;
e_surf_workstation_model_type_t type; /* Do not move this field: must match cpu_L07_t */
lmm_constraint_t constraint; /* Do not move this field: must match cpu_L07_t */
double lat_current;
/******* Resource Public **********/
/**************************************/
/******* Resource Public **********/
/**************************************/
-static xbt_dict_t get_properties(void *r)
-{
- /* We can freely cast as a cpu_L07_t since it has the same prefix than link_L07_t */
- return ((cpu_L07_t) r)->properties;
-}
-
static int action_unref(surf_action_t action)
{
action->refcount--;
static int action_unref(surf_action_t action)
{
action->refcount--;
/*** Resource Creation & Destruction **/
/**************************************/
/*** Resource Creation & Destruction **/
/**************************************/
-static void cpu_free(void *cpu)
-{
- xbt_dict_free(&(((cpu_L07_t) cpu)->properties));
- surf_resource_free(cpu);
-}
-
static cpu_L07_t cpu_new(const char *name, double power_scale,
double power_initial,
tmgr_trace_t power_trace,
static cpu_L07_t cpu_new(const char *name, double power_scale,
double power_initial,
tmgr_trace_t power_trace,
cpu->generic_resource.model = surf_workstation_model;
cpu->type = SURF_WORKSTATION_RESOURCE_CPU;
cpu->generic_resource.name = xbt_strdup(name);
cpu->generic_resource.model = surf_workstation_model;
cpu->type = SURF_WORKSTATION_RESOURCE_CPU;
cpu->generic_resource.name = xbt_strdup(name);
+ cpu->generic_resource.properties = current_property_set;
cpu->id = host_count++;
cpu->power_scale = power_scale;
cpu->id = host_count++;
cpu->power_scale = power_scale;
lmm_constraint_new(ptask_maxmin_system, cpu,
cpu->power_current * cpu->power_scale);
lmm_constraint_new(ptask_maxmin_system, cpu,
cpu->power_current * cpu->power_scale);
- /*add the property set */
- cpu->properties = current_property_set;
-
xbt_dict_set(surf_model_resource_set(surf_workstation_model), name, cpu,
xbt_dict_set(surf_model_resource_set(surf_workstation_model), name, cpu,
state_initial, state_trace, current_property_set);
}
state_initial, state_trace, current_property_set);
}
-static void link_free(void *nw_link)
-{
- xbt_dict_free(&(((link_L07_t) nw_link)->properties));
- surf_resource_free(nw_link);
-}
-
static link_L07_t link_new(char *name,
double bw_initial,
tmgr_trace_t bw_trace,
static link_L07_t link_new(char *name,
double bw_initial,
tmgr_trace_t bw_trace,
"Link '%s' declared several times in the platform file.", name);
nw_link->generic_resource.model = surf_workstation_model;
"Link '%s' declared several times in the platform file.", name);
nw_link->generic_resource.model = surf_workstation_model;
- nw_link->type = SURF_WORKSTATION_RESOURCE_LINK;
+ nw_link->generic_resource.properties = properties;
nw_link->generic_resource.name = name;
nw_link->generic_resource.name = name;
+ nw_link->type = SURF_WORKSTATION_RESOURCE_LINK;
nw_link->bw_current = bw_initial;
if (bw_trace)
nw_link->bw_event =
nw_link->bw_current = bw_initial;
if (bw_trace)
nw_link->bw_event =
if (policy == SURF_LINK_FATPIPE)
lmm_constraint_shared(nw_link->constraint);
if (policy == SURF_LINK_FATPIPE)
lmm_constraint_shared(nw_link->constraint);
- nw_link->properties = properties;
- xbt_dict_set(surf_network_model->resource_set, name, nw_link, link_free);
+ xbt_dict_set(surf_network_model->resource_set, name, nw_link, surf_resource_free);
get_link_latency;
surf_workstation_model->extension.workstation.link_shared = link_shared;
get_link_latency;
surf_workstation_model->extension.workstation.link_shared = link_shared;
- surf_workstation_model->get_properties = get_properties;
-
if (!ptask_maxmin_system)
ptask_maxmin_system = lmm_system_new();
if (!ptask_maxmin_system)
ptask_maxmin_system = lmm_system_new();