int (*get_latency_limited) (surf_action_t action); /**< Return 1 if action is limited by latency, 0 otherwise */
#endif
- xbt_dict_t resource_set;
-
-
surf_model_private_t model_private;
-
union extension {
s_surf_model_extension_cpu_t cpu;
s_surf_model_extension_network_t network;
surf_model_t surf_model_init(void);
void surf_model_exit(surf_model_t model);
-void *surf_model_resource_by_name(surf_model_t model, const char *name);
-#define surf_model_resource_set(model) (model)->resource_set
+static inline void *surf_cpu_resource_by_name(const char *name) {
+ return xbt_lib_get_or_null(host_lib, name, SURF_CPU_LEVEL);
+}
+static inline void *surf_workstation_resource_by_name(const char *name){
+ return xbt_lib_get_or_null(host_lib, name, SURF_WKS_LEVEL);
+}
+static inline void *surf_network_resource_by_name(const char *name){
+ return xbt_lib_get_or_null(link_lib, name, SURF_LINK_LEVEL);
+}
typedef struct surf_resource {
surf_model_t model;
xbt_dict_t cpu_properties)
{
cpu_Cas01_t cpu = xbt_new0(s_cpu_Cas01_t, 1);
- xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
+ xbt_assert1(!surf_cpu_resource_by_name(name),
"Host '%s' declared several times in the platform file",
name);
cpu->generic_resource.model = surf_cpu_model;
/* connect all traces relative to hosts */
xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- cpu_Cas01_t host = surf_model_resource_by_name(surf_cpu_model, elm);
+ cpu_Cas01_t host = surf_cpu_resource_by_name(elm);
xbt_assert1(host, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- cpu_Cas01_t host = surf_model_resource_by_name(surf_cpu_model, elm);
+ cpu_Cas01_t host = surf_cpu_resource_by_name(elm);
xbt_assert1(host, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
s_surf_action_cpu_Cas01_im_t action;
cpu = xbt_new0(s_cpu_Cas01_im_t, 1);
- xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
+ xbt_assert1(!surf_cpu_resource_by_name(name),
"Host '%s' declared several times in the platform file",
name);
cpu->generic_resource.model = surf_cpu_model;
/* connect all traces relative to hosts */
xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- cpu_Cas01_im_t host = surf_model_resource_by_name(surf_cpu_model, elm);
+ cpu_Cas01_im_t host = surf_cpu_resource_by_name(elm);
xbt_assert1(host, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- cpu_Cas01_im_t host = surf_model_resource_by_name(surf_cpu_model, elm);
+ cpu_Cas01_im_t host = surf_cpu_resource_by_name(elm);
xbt_assert1(host, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
s_tmgr_event_t val;
cpu_ti_t cpu = xbt_new0(s_cpu_ti_t, 1);
s_surf_action_cpu_ti_t ti_action;
- xbt_assert1(!surf_model_resource_by_name(surf_cpu_model, name),
+ xbt_assert1(!surf_cpu_resource_by_name(name),
"Host '%s' declared several times in the platform file",
name);
xbt_assert0(core==1,"Multi-core not handled with this model yet");
/* connect all traces relative to hosts */
xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- cpu_ti_t cpu = surf_model_resource_by_name(surf_cpu_model, elm);
+ cpu_ti_t cpu = surf_cpu_resource_by_name(elm);
xbt_assert1(cpu, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- cpu_ti_t cpu = surf_model_resource_by_name(surf_cpu_model, elm);
+ cpu_ti_t cpu = surf_cpu_resource_by_name(elm);
xbt_assert1(cpu, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
xbt_swag_free(model->states.running_action_set);
xbt_swag_free(model->states.failed_action_set);
xbt_swag_free(model->states.done_action_set);
- xbt_dict_free(&model->resource_set);
free(model->model_private);
free(model);
}
-
-void *surf_model_resource_by_name(surf_model_t model, const char *name)
-{
- return xbt_dict_get_or_null(model->resource_set, name);
-}
xbt_dict_t cpu_properties)
{
cpu_L07_t cpu = xbt_new0(s_cpu_L07_t, 1);
- xbt_assert1(!surf_model_resource_by_name(surf_workstation_model, name),
+ xbt_assert1(!surf_workstation_resource_by_name(name),
"Host '%s' declared several times in the platform file.",
name);
/* Connect traces relative to cpu */
xbt_dict_foreach(trace_connect_list_host_avail, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- cpu_L07_t host =
- surf_model_resource_by_name(surf_workstation_model, elm);
+ cpu_L07_t host = surf_workstation_resource_by_name(elm);
xbt_assert1(host, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
xbt_dict_foreach(trace_connect_list_power, cursor, trace_name, elm) {
tmgr_trace_t trace = xbt_dict_get_or_null(traces_set_list, trace_name);
- cpu_L07_t host =
- surf_model_resource_by_name(surf_workstation_model, elm);
+ cpu_L07_t host = surf_workstation_resource_by_name(elm);
xbt_assert1(host, "Host %s undefined", elm);
xbt_assert1(trace, "Trace %s undefined", trace_name);
/*********************** CPU ***********************************/
XBT_DEBUG("%p", surf_cpu_model);
- cpuA = surf_model_resource_by_name(surf_cpu_model, "Cpu A");
- cpuB = surf_model_resource_by_name(surf_cpu_model, "Cpu B");
+ cpuA = surf_cpu_resource_by_name("Cpu A");
+ 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);
/*********************** Network *******************************/
XBT_DEBUG("%p", surf_network_model);
- cardA = surf_model_resource_by_name(surf_network_model, "Cpu A");
- cardB = surf_model_resource_by_name(surf_network_model, "Cpu B");
+ cardA = surf_network_resource_by_name("Cpu A");
+ cardB = surf_network_resource_by_name("Cpu B");
/* Let's check that those two processors exist */
XBT_DEBUG("%s : %p", surf_resource_name(cardA), cardA);
/*********************** WORKSTATION ***********************************/
workstationA =
- surf_model_resource_by_name(surf_workstation_model, "Cpu A");
+ surf_workstation_resource_by_name("Cpu A");
workstationB =
- surf_model_resource_by_name(surf_workstation_model, "Cpu B");
+ surf_workstation_resource_by_name("Cpu B");
/* Let's check that those two processors exist */
XBT_DEBUG("%s : %p", surf_resource_name(workstationA), workstationA);