MPI_Waitany, MPI_Waitall, MPI_Allreduce
SURF:
+ * Extract the routing logic into its own object.
+ - Was dupplicated in network.c and workstation_LV07.c
+ - We may want to implement other ways of storing that info
+ => kill now useless network_card concept
* Declare common_public as an embeeded struct to reduce redirections
and mallocs
* Factorize model_init/exit between models
* Embeed every fields of common_public directly into s_surf_model_t
* Implement a generic resource; use it as ancestor to specific ones
Allows to kill duplicated code in models
- The drawback is that network cards are more fat since they don't
- use the model field of their ancestor.
- But hell, we wont fight for 8 bytes per host, will we?
TODO: integrate the properties into that ancestor
* Rename model methods:
action_free -> action_unref
surf/surf_model.c \
surf/surf_resource.c \
surf/surf_action.c \
+ surf/surf_routing.c \
surf/surf_config.c \
surf/maxmin.c \
surf/fair_bottleneck.c \
/***************************/
/* Generic model object */
/***************************/
+ typedef struct s_routing s_routing_t, *routing_t;
+ XBT_PUBLIC_DATA(routing_t) used_routing;
/** \brief Private data available on all models
* \ingroup SURF_models
* Public functions specific to the network model
*/
typedef struct surf_network_model_extension_public {
- surf_action_t(*communicate) (void *src, void *dst, double size,
- double max_rate);
- xbt_dynar_t (*get_route) (void *src, void *dst);
+ surf_action_t(*communicate) (const char *src_name,const char *dst_name,int src, int dst, double size,
+ double rate);
+ xbt_dynar_t (*get_route) (int src, int dst);
double (*get_link_bandwidth) (const void *link);
double (*get_link_latency) (const void *link);
int (*link_shared) (const void *link);
surf_action_t(*communicate) (void *workstation_src, /**< Execute a communication amount between two workstations */
void *workstation_dst, double size,
double max_rate);
+ xbt_dynar_t(*get_route)(void *workstation_src,void *workstation_dst); /**< Get the list of links between two ws */
surf_action_t(*execute_parallel_task) (int workstation_nb, /**< Execute a parallel task on several workstations */
void **workstation_list,
double *computation_amount,
double *communication_amount,
double amount, double rate);
- xbt_dynar_t (*get_route) (void *src, void *dst); /**< Return the network link list between two workstations */
double (*get_link_bandwidth) (const void *link); /**< Return the current bandwidth of a network link */
double (*get_link_latency) (const void *link); /**< Return the current latency of a network link */
int (*link_shared) (const void *link);
XBT_PUBLIC_DATA(xbt_dict_t) trace_connect_list_latency;
-XBT_PUBLIC_DATA(double) get_cpu_power(const char *power);
+XBT_PUBLIC(double) get_cpu_power(const char *power);
SG_END_DECL()
double weight_S_parameter = 0.0; /* default value */
int card_number = 0;
-int host_number = 0;
-xbt_dynar_t *routing_table = NULL;
-static link_CM02_t loopback = NULL;
+int host_count = 0;
double sg_tcp_gamma = 0.0;
-static void create_routing_table(void)
-{
- int i,j;
- routing_table = xbt_new0(xbt_dynar_t, /*card_number * card_number */
- host_number * host_number);
- for (i=0;i<host_number;i++)
- for (j=0;j<host_number;j++)
- ROUTE(i,j) = xbt_dynar_new(sizeof(link_CM02_t),NULL);
-
-}
-
static void link_free(void *nw_link)
{
xbt_dict_free(&(((link_CM02_t) nw_link)->properties));
return nw_link;
}
-static int network_card_new(const char *card_name)
-{
- network_card_CM02_t card =
- surf_model_resource_by_name(surf_network_model, card_name);
-
- if (!card) {
- card = xbt_new0(s_network_card_CM02_t, 1);
- card->generic_resource.name = xbt_strdup(card_name);
- card->id = host_number++;
- xbt_dict_set(surf_model_resource_set(surf_network_model), card_name, card,
- surf_resource_free);
- }
- return card->id;
-}
-
static void parse_link_init(void)
{
char *name_link;
}
-static int src_id = -1;
-static int dst_id = -1;
-
-static void parse_route_set_endpoints(void)
-{
- src_id = network_card_new(A_surfxml_route_src);
- dst_id = network_card_new(A_surfxml_route_dst);
- route_action = A_surfxml_route_action;
-}
-
-static void parse_route_set_route(void)
-{
- char *name;
- if (src_id != -1 && dst_id != -1) {
- name = bprintf("%x#%x", src_id, dst_id);
- manage_route(route_table, name, route_action, 0);
- free(name);
- }
-}
-
-static void add_loopback(void)
-{
- int i;
- /* Adding loopback if needed */
- for (i = 0; i < host_number; i++)
- if (!xbt_dynar_length(ROUTE(i, i))) {
- if (!loopback)
- loopback = link_new(xbt_strdup("__MSG_loopback__"),
- 498000000, NULL, 0.000015, NULL,
- SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL);
- ROUTE(i, i) = xbt_dynar_new(sizeof(link_CM02_t),NULL);
- xbt_dynar_push(ROUTE(i,i),&loopback);
- }
-}
-
-static void add_route(void)
-{
- xbt_ex_t e;
- int nb_link = 0;
- unsigned int cpt = 0;
- xbt_dict_cursor_t cursor = NULL;
- char *key, *data, *end;
- const char *sep = "#";
- xbt_dynar_t links, keys;
-
- if (routing_table == NULL)
- create_routing_table();
-
- xbt_dict_foreach(route_table, cursor, key, data) {
- char *link_name = NULL;
- nb_link = 0;
- links = (xbt_dynar_t) data;
- keys = xbt_str_split_str(key, sep);
-
- src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 16);
- dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 16);
- xbt_dynar_free(&keys);
-
- xbt_dynar_foreach(links, cpt, link_name) {
- TRY {
- link_CM02_t link = xbt_dict_get(link_set, link_name);
- xbt_dynar_push(ROUTE(src_id,dst_id),&link);
- }
- CATCH(e) {
- RETHROW1("Link %s not found (dict raised this exception: %s)", link_name);
- }
- }
- }
-
- int i,j;
- for (i=0;i<host_number;i++)
- for (j=0;j<host_number;j++)
- xbt_dynar_shrink(ROUTE(i,j),0);
-}
-
-static void count_hosts(void)
-{
- host_number++;
-}
-
-
static void add_traces(void)
{
xbt_dict_cursor_t cursor = NULL;
static void define_callbacks(const char *file)
{
/* Figuring out the network links */
- surfxml_add_callback(STag_surfxml_host_cb_list, &count_hosts);
surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
- surfxml_add_callback(STag_surfxml_route_cb_list,
- &parse_route_set_endpoints);
- surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces);
- surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_route);
- surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_loopback);
}
static int resource_used(void *resource_id)
return;
}
-static surf_action_t communicate(void *src, void *dst, double size,
+static surf_action_t communicate(const char *src_name, const char *dst_name,int src, int dst, double size,
double rate)
{
surf_action_network_CM02_t action = NULL;
/* LARGE PLATFORMS HACK:
Add a link_CM02_t *link and a int link_nb to network_card_CM02_t. It will represent local links for this node
Use the cluster_id for ->id */
- network_card_CM02_t card_src = src;
- network_card_CM02_t card_dst = dst;
- xbt_dynar_t route = ROUTE(card_src->id, card_dst->id);
+ xbt_dynar_t route = used_routing->get_route(src, dst);
/* LARGE PLATFORMS HACK:
total_route_size = route_size + src->link_nb + dst->nb */
unsigned int i;
- XBT_IN4("(%s,%s,%g,%g)", card_src->generic_resource.name, card_dst->generic_resource.name, size, rate);
+ XBT_IN4("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
/* LARGE PLATFORMS HACK:
assert on total_route_size */
xbt_assert2(xbt_dynar_length(route),
- "You're trying to send data from %s to %s but there is no connection between these two cards.",
- card_src->generic_resource.name, card_dst->generic_resource.name);
+ "You're trying to send data from %s to %s but there is no connection between these two hosts.",
+ src_name, dst_name);
action = xbt_new0(s_surf_action_network_CM02_t, 1);
return (surf_action_t) action;
}
-/* returns an array of link_CM02_t */
-static xbt_dynar_t get_route(void *src, void *dst)
-{
- network_card_CM02_t card_src = src;
- network_card_CM02_t card_dst = dst;
- return ROUTE(card_src->id, card_dst->id);
-}
-
static double get_link_bandwidth(const void *link)
{
return ((link_CM02_t) link)->bw_current;
static void finalize(void)
{
- int i, j;
-
xbt_dict_free(&link_set);
surf_model_exit(surf_network_model);
surf_network_model = NULL;
- loopback = NULL;
- for (i = 0; i < host_number; i++)
- for (j = 0; j < host_number; j++)
- xbt_dynar_free(&ROUTE(i, j));
- free(routing_table);
- routing_table = NULL;
- host_number = 0;
+ used_routing->finalize();
+ host_count = 0;
lmm_system_free(network_maxmin_system);
network_maxmin_system = NULL;
}
static void surf_network_model_init_internal(void)
{
+ link_set = xbt_dict_new();
surf_network_model = surf_model_init();
surf_network_model->name = "network";
surf_cpu_model->set_max_duration = action_set_max_duration;
surf_network_model->extension.network.communicate = communicate;
- surf_network_model->extension.network.get_route = get_route;
surf_network_model->extension.network.get_link_bandwidth =
get_link_bandwidth;
surf_network_model->extension.network.get_link_latency = get_link_latency;
surf_network_model->get_properties = get_properties;
- link_set = xbt_dict_new();
-
if (!network_maxmin_system)
network_maxmin_system = lmm_system_new();
+
+ routing_model_full_create(sizeof(link_CM02_t),
+ link_new(xbt_strdup("__loopback__"),
+ 498000000, NULL, 0.000015, NULL,
+ SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL));
}
/************************************************************************/
DIE_IMPOSSIBLE;
}
-static surf_action_t communicate(void *src, void *dst, double size,
- double rate)
+static surf_action_t communicate(const char *src_name,const char *dst_name,int src, int dst, double size,
+ double rate)
{
surf_action_network_Constant_t action = NULL;
- network_card_Constant_t card_src = src;
- network_card_Constant_t card_dst = dst;
- XBT_IN4("(%s,%s,%g,%g)", card_src->generic_resource.name, card_dst->generic_resource.name, size, rate);
+ XBT_IN4("(%s,%s,%g,%g)", src_name, dst_name, size, rate);
action = xbt_new0(s_surf_action_network_Constant_t, 1);
surf_cpu_model->set_max_duration = action_set_max_duration;
surf_network_model->extension.network.communicate = communicate;
- surf_network_model->extension.network.get_route = get_route;
surf_network_model->extension.network.get_link_bandwidth =
get_link_bandwidth;
surf_network_model->extension.network.get_link_latency = get_link_latency;
} s_link_CM02_t, *link_CM02_t;
-typedef struct network_card_CM02 {
- s_surf_resource_t generic_resource; /* must remain first to allow casts */
- int id;
-} s_network_card_CM02_t, *network_card_CM02_t;
-
typedef struct surf_action_network_CM02 {
s_surf_action_t generic_action;
double latency;
lmm_variable_t variable;
double rate;
int suspended;
- network_card_CM02_t src;
- network_card_CM02_t dst;
+#ifdef KILLME
+ int src;
+ int dst;
+#endif
} s_surf_action_network_CM02_t, *surf_action_network_CM02_t;
-extern int card_number;
-extern xbt_dynar_t *routing_table;
-
-#define ROUTE(i,j) routing_table[(i)+(j)*host_number]
-
#endif /* _SURF_NETWORK_PRIVATE_H */
*/
int __surf_is_absolute_file_path(const char *file_path);
+/*
+ * Routing logic
+ */
+struct s_routing {
+ const char *name;
+ xbt_dict_t host_id; /* char* -> int* */
+
+ xbt_dynar_t (*get_route)(int src, int dst);
+ void (*finalize)(void);
+ int host_count;
+};
+XBT_PUBLIC(routing_t) routing_model_full_create(size_t size_of_link,void *loopback);
+
#endif /* _SURF_SURF_PRIVATE_H */
--- /dev/null
+/* Copyright (c) 2009 The SimGrid team. All rights reserved. */
+
+/* This program is free software; you can redistribute it and/or modify it
+ * under the terms of the license (GNU LGPL) which comes with this package. */
+
+#include "surf_private.h"
+#include "xbt/dynar.h"
+#include "xbt/str.h"
+
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_route,surf,"Routing part of surf");// FIXME: connect this under windows
+
+typedef struct {
+ s_routing_t generic_routing;
+ xbt_dynar_t *routing_table;
+ void *loopback;
+ size_t size_of_link;
+}s_routing_full_t,*routing_full_t;
+
+routing_t used_routing = NULL;
+/* ************************************************************************** */
+/* *************************** FULL ROUTING ********************************* */
+
+#define ROUTE_FULL(i,j) ((routing_full_t)used_routing)->routing_table[(i)+(j)*(used_routing)->host_count]
+
+/*
+ * Parsing
+ */
+static void routing_full_parse_Shost(void) {
+ int *val = xbt_malloc(sizeof(int));
+ DEBUG2("Seen host %s (#%d)",A_surfxml_host_id,used_routing->host_count);
+ *val = used_routing->host_count++;
+ xbt_dict_set(used_routing->host_id,A_surfxml_host_id,val,xbt_free);
+}
+static int src_id = -1;
+static int dst_id = -1;
+static void routing_full_parse_Sroute_set_endpoints(void)
+{
+ src_id = *(int*)xbt_dict_get(used_routing->host_id,A_surfxml_route_src);
+ dst_id = *(int*)xbt_dict_get(used_routing->host_id,A_surfxml_route_dst);
+ DEBUG4("Route %s %d -> %s %d",A_surfxml_route_src,src_id,A_surfxml_route_dst,dst_id);
+ route_action = A_surfxml_route_action;
+}
+static void routing_full_parse_Eroute(void)
+{
+ char *name;
+ if (src_id != -1 && dst_id != -1) {
+ name = bprintf("%x#%x", src_id, dst_id);
+ manage_route(route_table, name, route_action, 0);
+ free(name);
+ }
+}
+
+
+static void routing_full_parse_end(void) {
+ routing_full_t routing = (routing_full_t) used_routing;
+ int nb_link = 0;
+ unsigned int cpt = 0;
+ xbt_dict_cursor_t cursor = NULL;
+ char *key, *data, *end;
+ const char *sep = "#";
+ xbt_dynar_t links, keys;
+ char *link_name = NULL;
+ int i,j;
+
+ int host_count = routing->generic_routing.host_count;
+
+ /* Create the routing table */
+ routing->routing_table = xbt_new0(xbt_dynar_t, host_count * host_count);
+ for (i=0;i<host_count;i++)
+ for (j=0;j<host_count;j++)
+ ROUTE_FULL(i,j) = xbt_dynar_new(routing->size_of_link,NULL);
+
+ /* Put the routes in position */
+ xbt_dict_foreach(route_table, cursor, key, data) {
+ nb_link = 0;
+ links = (xbt_dynar_t) data;
+ keys = xbt_str_split_str(key, sep);
+
+ src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 16);
+ dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 16);
+ xbt_dynar_free(&keys);
+
+ DEBUG4("Handle %d %d (from %d hosts): %ld links",
+ src_id,dst_id,routing->generic_routing.host_count,xbt_dynar_length(links));
+ xbt_dynar_foreach(links, cpt, link_name) {
+ void* link = xbt_dict_get_or_null(link_set, link_name);
+ if (link)
+ xbt_dynar_push(ROUTE_FULL(src_id,dst_id),&link);
+ else
+ THROW1(mismatch_error,0,"Link %s not found", link_name);
+ }
+ }
+
+ /* Add the loopback if needed */
+ for (i = 0; i < host_count; i++)
+ if (!xbt_dynar_length(ROUTE_FULL(i, i)))
+ xbt_dynar_push(ROUTE_FULL(i,i),&routing->loopback);
+
+ /* Shrink the dynar routes (save unused slots) */
+ for (i=0;i<host_count;i++)
+ for (j=0;j<host_count;j++)
+ xbt_dynar_shrink(ROUTE_FULL(i,j),0);
+}
+
+/*
+ * Business methods
+ */
+static xbt_dynar_t routing_full_get_route(int src,int dst) {
+ return ROUTE_FULL(src,dst);
+}
+
+static void routing_full_finalize(void) {
+ routing_full_t routing = (routing_full_t)used_routing;
+ int i,j;
+
+ if (routing) {
+ for (i = 0; i < used_routing->host_count; i++)
+ for (j = 0; j < used_routing->host_count; j++)
+ xbt_dynar_free(&ROUTE_FULL(i, j));
+ free(routing->routing_table);
+ xbt_dict_free(&used_routing->host_id);
+ free(routing);
+ routing=NULL;
+ }
+}
+
+routing_t routing_model_full_create(size_t size_of_link,void *loopback) {
+ /* initialize our structure */
+ routing_full_t res = xbt_new0(s_routing_full_t,1);
+ res->generic_routing.name = "Full";
+ res->generic_routing.host_count = 0;
+ res->generic_routing.get_route = routing_full_get_route;
+ res->generic_routing.finalize = routing_full_finalize;
+ res->size_of_link = size_of_link;
+ res->loopback = loopback;
+
+ /* Set it in position */
+ used_routing = (routing_t) res;
+
+ /* Setup the parsing callbacks we need */
+ used_routing->host_id = xbt_dict_new();
+ surfxml_add_callback(STag_surfxml_host_cb_list, &routing_full_parse_Shost);
+ surfxml_add_callback(ETag_surfxml_platform_cb_list, &routing_full_parse_end);
+ surfxml_add_callback(STag_surfxml_route_cb_list,
+ &routing_full_parse_Sroute_set_endpoints);
+ surfxml_add_callback(ETag_surfxml_route_cb_list, &routing_full_parse_Eroute);
+
+ return used_routing;
+}
surf_model_t surf_workstation_model = NULL;
static workstation_CLM03_t workstation_new(const char *name,
- void *cpu, void *card)
+ void *cpu, int id)
{
workstation_CLM03_t workstation = xbt_new0(s_workstation_CLM03_t, 1);
workstation->generic_resource.model = surf_workstation_model;
workstation->generic_resource.name = xbt_strdup(name);
workstation->cpu = cpu;
- workstation->network_card = card;
+ workstation->id = id;
xbt_dict_set(surf_model_resource_set(surf_workstation_model), name,
workstation, surf_resource_free);
xbt_dict_cursor_t cursor = NULL;
char *name = NULL;
void *cpu = NULL;
- void *nw_card = NULL;
xbt_dict_foreach(surf_model_resource_set(surf_cpu_model), cursor, name, cpu) {
- nw_card = surf_model_resource_by_name(surf_network_model, name);
- xbt_assert1(nw_card, "No corresponding card found for %s", name);
+ int *id = xbt_dict_get_or_null(used_routing->host_id,name);
+ xbt_assert1(id, "No host %s found in the platform file", name);
- workstation_new(name, cpu, nw_card);
+ workstation_new(name, cpu, *id);
}
}
void *workstation_dst, double size,
double rate)
{
+ workstation_CLM03_t src = (workstation_CLM03_t) workstation_src;
+ workstation_CLM03_t dst = (workstation_CLM03_t) workstation_dst;
return surf_network_model->extension.
- network.communicate(((workstation_CLM03_t) workstation_src)->network_card,
- ((workstation_CLM03_t) workstation_dst)->network_card,
- size, rate);
+ network.communicate(surf_resource_name(src->cpu),surf_resource_name(dst->cpu),
+ src->id,dst->id,
+ size, rate);
}
static e_surf_cpu_state_t get_state(void *workstation)
{
workstation_CLM03_t workstation_src = (workstation_CLM03_t) src;
workstation_CLM03_t workstation_dst = (workstation_CLM03_t) dst;
- return surf_network_model->extension.network.get_route(workstation_src->
- network_card,
- workstation_dst->
- network_card);
+ return surf_network_model->extension.network.get_route(workstation_src->id,
+ workstation_dst->id);
}
static double get_link_bandwidth(const void *link)
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 =
execute_parallel_task;
- surf_workstation_model->extension.workstation.get_route = get_route;
surf_workstation_model->extension.workstation.get_link_bandwidth =
get_link_bandwidth;
surf_workstation_model->extension.workstation.get_link_latency =
typedef struct workstation_CLM03 {
s_surf_resource_t generic_resource; /* Must remain first to add this to a trace */
void *cpu;
- void *network_card;
+ int id;
} s_workstation_CLM03_t, *workstation_CLM03_t;
typedef struct surf_action_parallel_task_CSL05 {
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(surf_workstation);
-static int nb_workstation = 0;
-static xbt_dynar_t *routing_table = NULL;
-#define ROUTE(i,j) routing_table[(i)+(j)*nb_workstation]
-static link_L07_t loopback = NULL;
+static int host_count = 0;
static xbt_dict_t parallel_task_link_set = NULL;
lmm_system_t ptask_maxmin_system = NULL;
for (j = 0; j < workstation_nb; j++) {
cpu_L07_t card_src = action->workstation_list[i];
cpu_L07_t card_dst = action->workstation_list[j];
- xbt_dynar_t route = ROUTE(card_src->id, card_dst->id);
+ xbt_dynar_t route = used_routing->get_route(card_src->id, card_dst->id);
double lat = 0.0;
if (action->communication_amount[i * workstation_nb + j] > 0) {
static void finalize(void)
{
- int i, j;
-
xbt_dict_free(&link_set);
if (parallel_task_link_set != NULL) {
xbt_dict_free(¶llel_task_link_set);
surf_model_exit(surf_workstation_model);
surf_workstation_model = NULL;
+ used_routing->finalize();
- for (i = 0; i < nb_workstation; i++)
- for (j = 0; j < nb_workstation; j++)
- xbt_dynar_free(&ROUTE(i, j));
- free(routing_table);
- routing_table = NULL;
- nb_workstation = 0;
+ host_count = 0; // FIXME: KILLME?
if (ptask_maxmin_system) {
lmm_system_free(ptask_maxmin_system);
cpu_L07_t card_src = workstation_list[i];
cpu_L07_t card_dst = workstation_list[j];
link_L07_t link;
- xbt_dynar_t route = ROUTE(card_src->id, card_dst->id);
+ xbt_dynar_t route = used_routing->get_route(card_src->id, card_dst->id);
double lat = 0.0;
if (communication_amount[i * workstation_nb + j] > 0)
cpu_L07_t card_src = workstation_list[i];
cpu_L07_t card_dst = workstation_list[j];
link_L07_t link;
- xbt_dynar_t route = ROUTE(card_src->id, card_dst->id);
+ xbt_dynar_t route = used_routing->get_route(card_src->id, card_dst->id);
if (communication_amount[i * workstation_nb + j] == 0.0)
continue;
return (surf_action_t) action;
}
-/* returns a dynar of link_L07_t */
static xbt_dynar_t get_route(void *src, void *dst)
{
- cpu_L07_t card_src = src;
- cpu_L07_t card_dst = dst;
+ cpu_L07_t host_src = src;
+ cpu_L07_t host_dst = dst;
- return ROUTE(card_src->id, card_dst->id);
+ return used_routing->get_route(host_src->id, host_dst->id);
}
static double get_link_bandwidth(const void *link)
cpu->generic_resource.model = surf_workstation_model;
cpu->type = SURF_WORKSTATION_RESOURCE_CPU;
cpu->generic_resource.name = xbt_strdup(name);
- cpu->id = nb_workstation++;
+ cpu->id = host_count++;
cpu->power_scale = power_scale;
xbt_assert0(cpu->power_scale > 0, "Power has to be >0");
return cpu;
}
-static void create_routing_table(void)
-{
- int i,j;
- routing_table = xbt_new0(xbt_dynar_t, /*card_number * card_number */
- nb_workstation * nb_workstation);
- for (i=0;i<nb_workstation;i++)
- for (j=0;j<nb_workstation;j++)
- ROUTE(i,j) = xbt_dynar_new(sizeof(link_L07_t),NULL);
-}
-
static void parse_cpu_init(void)
{
double power_scale = 0.0;
current_property_set);
}
-static int src_id = -1;
-static int dst_id = -1;
-
-static void parse_route_set_endpoints(void)
-{
- cpu_L07_t cpu_tmp = NULL;
-
- cpu_tmp =
- (cpu_L07_t) surf_model_resource_by_name(surf_workstation_model,
- A_surfxml_route_src);
- xbt_assert1(cpu_tmp, "Invalid cpu %s", A_surfxml_route_src);
- if (cpu_tmp != NULL)
- src_id = cpu_tmp->id;
-
- cpu_tmp =
- (cpu_L07_t) surf_model_resource_by_name(surf_workstation_model,
- A_surfxml_route_dst);
- xbt_assert1(cpu_tmp, "Invalid cpu %s", A_surfxml_route_dst);
- if (cpu_tmp != NULL)
- dst_id = cpu_tmp->id;
-
- route_action = A_surfxml_route_action;
-}
-
-static void parse_route_set_route(void)
-{
- char *name;
- if (src_id != -1 && dst_id != -1) {
- name = bprintf("%x#%x", src_id, dst_id);
- manage_route(route_table, name, route_action, 0);
- free(name);
- }
-}
-
-static void add_loopback(void)
-{
- int i;
-
- /* Adding loopback if needed */
- for (i = 0; i < nb_workstation; i++)
- if (!xbt_dynar_length(ROUTE(i, i))) {
- if (!loopback)
- loopback = link_new(xbt_strdup("__MSG_loopback__"),
- 498000000, NULL, 0.000015, NULL,
- SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL);
-
- xbt_dynar_push(ROUTE(i,i),&loopback);
- }
-}
-
-static void add_route(void)
-{
- xbt_ex_t e;
- int nb_link = 0;
- unsigned int cpt = 0;
- xbt_dict_cursor_t cursor = NULL;
- char *key, *data, *end;
- const char *sep = "#";
- xbt_dynar_t links, keys;
- char *link_name = NULL;
-
- if (routing_table == NULL)
- create_routing_table();
-
- xbt_dict_foreach(route_table, cursor, key, data) {
- nb_link = 0;
- links = (xbt_dynar_t) data;
- keys = xbt_str_split_str(key, sep);
-
- src_id = strtol(xbt_dynar_get_as(keys, 0, char *), &end, 16);
- dst_id = strtol(xbt_dynar_get_as(keys, 1, char *), &end, 16);
- xbt_dynar_free(&keys);
-
- xbt_dynar_foreach(links, cpt, link_name) {
- TRY {
- link_L07_t link = xbt_dict_get(link_set, link_name);
- xbt_dynar_push(ROUTE(src_id,dst_id),&link);
- }
- CATCH(e) {
- RETHROW1("Link %s not found (dict raised this exception: %s)", link_name);
- }
- }
- }
-}
-
static void add_traces(void)
{
xbt_dict_cursor_t cursor = NULL;
surf_parse_reset_parser();
surfxml_add_callback(STag_surfxml_host_cb_list, &parse_cpu_init);
surfxml_add_callback(STag_surfxml_link_cb_list, &parse_link_init);
- surfxml_add_callback(STag_surfxml_route_cb_list,
- &parse_route_set_endpoints);
- surfxml_add_callback(ETag_surfxml_route_cb_list, &parse_route_set_route);
- surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_route);
- surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_loopback);
surfxml_add_callback(ETag_surfxml_platform_cb_list, &add_traces);
}
surf_workstation_model->extension.workstation.get_available_speed =
get_available_speed;
surf_workstation_model->extension.workstation.communicate = communicate;
+ surf_workstation_model->extension.workstation.get_route = get_route;
surf_workstation_model->extension.workstation.execute_parallel_task =
execute_parallel_task;
- surf_workstation_model->extension.workstation.get_route = get_route;
surf_workstation_model->extension.workstation.get_link_bandwidth =
get_link_bandwidth;
surf_workstation_model->extension.workstation.get_link_latency =
if (!ptask_maxmin_system)
ptask_maxmin_system = lmm_system_new();
+
+ routing_model_full_create(sizeof(link_L07_t),
+ link_new(xbt_strdup("__MSG_loopback__"),
+ 498000000, NULL, 0.000015, NULL,
+ SURF_LINK_ON, NULL, SURF_LINK_FATPIPE, NULL));
+
}
/**************************************/
{
xbt_assert0(!surf_cpu_model, "CPU model type already defined");
xbt_assert0(!surf_network_model, "network model type already defined");
- model_init_internal();
define_callbacks(filename);
+ model_init_internal();
update_model_description(surf_workstation_model_description,
"ptask_L07", surf_workstation_model);