else if(!strcmp(mode,"none")) mode_int = A_surfxml_AS_routing_None;
else xbt_die("Don't have the model name '%s'",mode);
- s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
+ s_sg_platf_AS_cbarg_t AS;
AS.id = id;
AS.routing = mode_int;
-
sg_platf_new_AS_begin(&AS);
return 0;
double process_start_time,
double process_kill_time)
{
- s_sg_platf_process_cbarg_t process = SG_PLATF_PROCESS_INITIALIZER;
+ s_sg_platf_process_cbarg_t process;
+ memset(&process,0,sizeof(process));
sg_host_t host = sg_host_by_name(process_host);
if (!host)
process.host = process_host;
process.kill_time = process_kill_time;
process.start_time = process_start_time;
+ process.on_failure = SURF_PROCESS_ON_FAILURE_DIE;
sg_platf_new_process(&process);
}
}
void AsCluster::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int , int position){
- s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
s_surf_parsing_link_up_down_t info;
char* link_id = bprintf("%s_link_%d", cluster->id, id);
+ s_sg_platf_link_cbarg_t link;
memset(&link, 0, sizeof(link));
link.id = link_id;
link.bandwidth = cluster->bw;
if (link.policy == SURF_LINK_FULLDUPLEX) {
char *tmp_link = bprintf("%s_UP", link_id);
- info.link_up = sg_link_by_name(tmp_link);
+ info.link_up = Link::byName(tmp_link);
xbt_free(tmp_link);
tmp_link = bprintf("%s_DOWN", link_id);
- info.link_down = sg_link_by_name(tmp_link);
+ info.link_down = Link::byName(tmp_link);
xbt_free(tmp_link);
} else {
- info.link_up = sg_link_by_name(link_id);
- info.link_down = info.link_up;
+ info.link_up = info.link_down = Link::byName(link_id);
}
xbt_dynar_set(privateLinks_, position, &info);
xbt_free(link_id);
FatTreeNode::FatTreeNode(sg_platf_cluster_cbarg_t cluster, int id, int level,
int position) : id(id), level(level),
position(position) {
- s_sg_platf_link_cbarg_t linkTemplate = SG_PLATF_LINK_INITIALIZER;
+ s_sg_platf_link_cbarg_t linkTemplate;
if(cluster->limiter_link) {
memset(&linkTemplate, 0, sizeof(linkTemplate));
linkTemplate.bandwidth = cluster->limiter_link;
FatTreeNode *upNode) : upNode(upNode),
downNode(downNode) {
static int uniqueId = 0;
- s_sg_platf_link_cbarg_t linkTemplate = SG_PLATF_LINK_INITIALIZER;
+ s_sg_platf_link_cbarg_t linkTemplate;
memset(&linkTemplate, 0, sizeof(linkTemplate));
linkTemplate.bandwidth = cluster->bw;
linkTemplate.latency = cluster->lat;
linkTemplate.policy = cluster->sharing_policy; // sthg to do with that ?
- linkTemplate.id = bprintf("link_from_%d_to_%d_%d", downNode->id, upNode->id,
- uniqueId);
+ linkTemplate.id = bprintf("link_from_%d_to_%d_%d", downNode->id, upNode->id, uniqueId);
sg_platf_new_link(&linkTemplate);
Link* link;
std::string tmpID;
}
void AsClusterTorus::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int rank, int position) {
- s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
char *link_id;
unsigned int j = 0;
/**
dim_product = 1; // Needed to calculate the next neighbour_id
for (j = 0; j < xbt_dynar_length(dimensions_); j++) {
+ s_sg_platf_link_cbarg_t link;
memset(&link, 0, sizeof(link));
current_dimension = xbt_dynar_get_as(dimensions_, j, int);
neighbour_rank_id =
static int surf_parse_models_setup_already_called = 0;
+/* Build the list of hostnames in a cluster or in a cabinet */
+static std::vector<char*> *makeHostnames(const char*prefix, const char*radicals, const char *suffix){
+ std::vector<char*> *hostnames = new std::vector<char*>();
+ char *groups;
+ unsigned int iter;
+
+ //Make all hosts
+ xbt_dynar_t radical_elements = xbt_str_split(radicals, ",");
+ xbt_dynar_foreach(radical_elements, iter, groups) {
+
+ xbt_dynar_t radical_ends = xbt_str_split(groups, "-");
+ int start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
+ int end=0;
+
+ switch (xbt_dynar_length(radical_ends)) {
+ case 1:
+ end = start;
+ break;
+ case 2:
+ end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
+ break;
+ default:
+ surf_parse_error("Malformed radical: %s", groups);
+ break;
+ }
+
+ for (int i = start; i <= end; i++)
+ hostnames->push_back( bprintf("%s%d%s",prefix,i,suffix) );
+
+ xbt_dynar_free(&radical_ends);
+ }
+ xbt_dynar_free(&radical_elements);
+
+ return hostnames;
+}
+
+
/** The current AS in the parsing */
static simgrid::surf::AsImpl *current_routing = NULL;
static simgrid::surf::AsImpl* routing_get_current()
xbt_dict_t patterns = NULL;
int rankId=0;
- s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
- s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+ s_sg_platf_link_cbarg_t link;
unsigned int iter;
/* Parse the topology attributes.
* Nothing to do in a vanilla cluster, but that's another story for torus and flat_trees */
- s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
+ s_sg_platf_AS_cbarg_t AS;
AS.id = cluster->id;
switch (cluster->topology) {
XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\">", host_id, cluster->speed);
+ s_sg_platf_host_cbarg_t host;
memset(&host, 0, sizeof(host));
host.id = host_id;
if ((cluster->properties != NULL) && (!xbt_dict_is_empty(cluster->properties))) {
XBT_DEBUG(" ");
XBT_DEBUG("<router id=\"%s\"/>", cluster->router_id);
char *newid = NULL;
- s_sg_platf_router_cbarg_t router = SG_PLATF_ROUTER_INITIALIZER;
+ s_sg_platf_router_cbarg_t router;
memset(&router, 0, sizeof(router));
router.id = cluster->router_id;
router.coord = "";
void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet)
{
- int start, end, i;
- char *groups , *host_id , *link_id = NULL;
- unsigned int iter;
- xbt_dynar_t radical_elements;
- xbt_dynar_t radical_ends;
-
- //Make all hosts
- radical_elements = xbt_str_split(cabinet->radical, ",");
- xbt_dynar_foreach(radical_elements, iter, groups) {
+ std::vector<char*> *hostnames = makeHostnames(cabinet->prefix, cabinet->radical, cabinet->suffix);
- radical_ends = xbt_str_split(groups, "-");
- start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
-
- switch (xbt_dynar_length(radical_ends)) {
- case 1:
- end = start;
- break;
- case 2:
- end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
- break;
- default:
- surf_parse_error("Malformed radical");
- break;
- }
- s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
+ for (char* hostname : *hostnames) {
+ s_sg_platf_host_cbarg_t host;
memset(&host, 0, sizeof(host));
- host.pstate = 0;
- host.core_amount = 1;
-
- s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+ host.pstate = 0;
+ host.core_amount = 1;
+ host.id = hostname;
+ host.speed_per_pstate = xbt_dynar_new(sizeof(double), NULL);
+ xbt_dynar_push(host.speed_per_pstate,&cabinet->speed);
+ sg_platf_new_host(&host);
+ xbt_dynar_free(&host.speed_per_pstate);
+
+ s_sg_platf_link_cbarg_t link;
memset(&link, 0, sizeof(link));
link.policy = SURF_LINK_FULLDUPLEX;
link.latency = cabinet->lat;
link.bandwidth = cabinet->bw;
+ link.id = bprintf("link_%s",hostname);
+ sg_platf_new_link(&link);
+ free((char*)link.id);
- s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
+ s_sg_platf_host_link_cbarg_t host_link;
memset(&host_link, 0, sizeof(host_link));
-
- for (i = start; i <= end; i++) {
- host_id = bprintf("%s%d%s",cabinet->prefix,i,cabinet->suffix);
- link_id = bprintf("link_%s%d%s",cabinet->prefix,i,cabinet->suffix);
- host.id = host_id;
- link.id = link_id;
- host.speed_per_pstate = xbt_dynar_new(sizeof(double), NULL);
- xbt_dynar_push(host.speed_per_pstate,&cabinet->speed);
- sg_platf_new_host(&host);
- xbt_dynar_free(&host.speed_per_pstate);
- sg_platf_new_link(&link);
-
- char* link_up = bprintf("%s_UP",link_id);
- char* link_down = bprintf("%s_DOWN",link_id);
- host_link.id = host_id;
- host_link.link_up = link_up;
- host_link.link_down = link_down;
- sg_platf_new_hostlink(&host_link);
-
- free(host_id);
- free(link_id);
- free(link_up);
- free(link_down);
- }
-
- xbt_dynar_free(&radical_ends);
+ host_link.id = hostname;
+ host_link.link_up = bprintf("link_%s_UP",hostname);
+ host_link.link_down = bprintf("link_%s_DOWN",hostname);
+ sg_platf_new_hostlink(&host_link);
+ free((char*)host_link.link_up);
+ free((char*)host_link.link_down);
+
+ free(hostname);
}
- xbt_dynar_free(&radical_elements);
+ delete(hostnames);
}
void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
XBT_DEBUG(" ");
XBT_DEBUG("<AS id=\"%s\"\trouting=\"Cluster\">", peer->id);
- s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
- AS.id = peer->id;
- AS.routing = A_surfxml_AS_routing_Cluster;
+ s_sg_platf_AS_cbarg_t AS;
+ AS.id = peer->id;
+ AS.routing = A_surfxml_AS_routing_Cluster;
sg_platf_new_AS_begin(&AS);
XBT_DEBUG("<host\tid=\"%s\"\tpower=\"%f\"/>", host_id, peer->speed);
- s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
+ s_sg_platf_host_cbarg_t host;
memset(&host, 0, sizeof(host));
host.id = host_id;
sg_platf_new_host(&host);
xbt_dynar_free(&host.speed_per_pstate);
- s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+ s_sg_platf_link_cbarg_t link;
memset(&link, 0, sizeof(link));
link.policy = SURF_LINK_SHARED;
link.latency = peer->lat;
sg_platf_new_link(&link);
XBT_DEBUG("<host_link\tid=\"%s\"\tup=\"%s\"\tdown=\"%s\" />", host_id,link_up,link_down);
- s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
+ s_sg_platf_host_link_cbarg_t host_link;
memset(&host_link, 0, sizeof(host_link));
host_link.id = host_id;
host_link.link_up = link_up;
free(link_down);
XBT_DEBUG("<router id=\"%s\"/>", router_id);
- s_sg_platf_router_cbarg_t router = SG_PLATF_ROUTER_INITIALIZER;
+ s_sg_platf_router_cbarg_t router;
memset(&router, 0, sizeof(router));
router.id = router_id;
router.coord = peer->coord;
xbt_dict_t properties;
} s_sg_platf_host_cbarg_t, *sg_platf_host_cbarg_t;
-#define SG_PLATF_HOST_INITIALIZER { \
- NULL, 0, 1, 1, NULL, NULL, NULL, NULL \
-}
-
typedef struct {
const char* id;
const char* link_up;
const char* link_down;
} s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
-#define SG_PLATF_HOST_LINK_INITIALIZER {NULL,NULL,NULL}
-
typedef struct {
const char* id;
const char* coord;
} s_sg_platf_router_cbarg_t, *sg_platf_router_cbarg_t;
-#define SG_PLATF_ROUTER_INITIALIZER {NULL,NULL}
-
typedef struct {
const char* id;
double bandwidth;
xbt_dict_t properties;
} s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
-#define SG_PLATF_LINK_INITIALIZER {\
- NULL, 0., NULL, 0., NULL, NULL, SURF_LINK_SHARED, NULL \
-}
-
typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
typedef struct s_sg_platf_peer_cbarg {
const char* id;
tmgr_trace_t state_trace;
} s_sg_platf_peer_cbarg_t;
-#define SG_PLATF_PEER_INITIALIZER {NULL,0.0,0.0,0.0,0.0,NULL,NULL,NULL}
-
typedef struct s_sg_platf_route_cbarg *sg_platf_route_cbarg_t;
typedef struct s_sg_platf_route_cbarg {
bool symmetrical;
std::vector<Link*> *link_list;
} s_sg_platf_route_cbarg_t;
-#define SG_PLATF_ROUTE_INITIALIZER {1,NULL,NULL,NULL,NULL,NULL}
-
typedef struct s_sg_platf_cluster_cbarg *sg_platf_cluster_cbarg_t;
typedef struct s_sg_platf_cluster_cbarg {
const char* id;
const char* state_trace;
} s_sg_platf_cluster_cbarg_t;
-#define SG_PLATF_CLUSTER_INITIALIZER {NULL,NULL,NULL,NULL,0.0,1 \
- ,1.,1.,0.,0.,0.,0.,0. \
- ,SURF_CLUSTER_FLAT,NULL,NULL,NULL, \
- SURF_LINK_SHARED,SURF_LINK_SHARED,NULL \
- ,NULL}
-
typedef struct s_sg_platf_cabinet_cbarg *sg_platf_cabinet_cbarg_t;
typedef struct s_sg_platf_cabinet_cbarg {
const char* id;
double lat;
} s_sg_platf_cabinet_cbarg_t;
-#define SG_PLATF_CABINET_INITIALIZER {NULL,NULL,NULL,NULL,0.0,0.0,0.0}
-
typedef struct {
const char* id;
const char* type_id;
const char* attach;
} s_sg_platf_storage_cbarg_t, *sg_platf_storage_cbarg_t;
-#define SG_PLATF_STORAGE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL}
-
typedef struct {
const char* id;
const char* model;
sg_size_t size;
} s_sg_platf_storage_type_cbarg_t, *sg_platf_storage_type_cbarg_t;
-#define SG_PLATF_STORAGE_TYPE_INITIALIZER {NULL,NULL,NULL,NULL,NULL,NULL,0}
-
typedef struct {
const char* storageId;
const char* name;
} s_sg_platf_mount_cbarg_t, *sg_platf_mount_cbarg_t;
-#define SG_PLATF_MOUNT_INITIALIZER {NULL,NULL}
-
typedef struct s_sg_platf_prop_cbarg *sg_platf_prop_cbarg_t;
typedef struct s_sg_platf_prop_cbarg {
const char *id;
const char *value;
} s_sg_platf_prop_cbarg_t;
-#define SG_PLATF_PROP_INITIALIZER {NULL,NULL}
-
typedef struct s_sg_platf_trace_cbarg *sg_platf_trace_cbarg_t;
typedef struct s_sg_platf_trace_cbarg {
const char *id;
const char *pc_data;
} s_sg_platf_trace_cbarg_t;
-#define SG_PLATF_TRACE_INITIALIZER {NULL,NULL,0.0,NULL}
-
typedef struct s_sg_platf_trace_connect_cbarg *sg_platf_trace_connect_cbarg_t;
typedef struct s_sg_platf_trace_connect_cbarg {
e_surf_trace_connect_kind_t kind;
const char *element;
} s_sg_platf_trace_connect_cbarg_t;
-#define SG_PLATF_TRACE_CONNECT_INITIALIZER {SURF_TRACE_CONNECT_KIND_LATENCY,NULL,NULL}
-
typedef struct s_sg_platf_process_cbarg *sg_platf_process_cbarg_t;
typedef struct s_sg_platf_process_cbarg {
const char **argv;
e_surf_process_on_failure_t on_failure;
} s_sg_platf_process_cbarg_t;
-#define SG_PLATF_PROCESS_INITIALIZER {NULL,0,NULL,NULL,NULL,-1.0,-1.0,SURF_PROCESS_ON_FAILURE_DIE}
-
typedef struct s_sg_platf_AS_cbarg *sg_platf_AS_cbarg_t;
typedef struct s_sg_platf_AS_cbarg {
const char *id;
}
void ETag_surfxml_storage(void)
{
- s_sg_platf_storage_cbarg_t storage = SG_PLATF_STORAGE_INITIALIZER;
+ s_sg_platf_storage_cbarg_t storage;
memset(&storage,0,sizeof(storage));
storage.id = A_surfxml_storage_id;
}
void ETag_surfxml_storage___type(void)
{
- s_sg_platf_storage_type_cbarg_t storage_type = SG_PLATF_STORAGE_TYPE_INITIALIZER;
+ s_sg_platf_storage_type_cbarg_t storage_type;
memset(&storage_type,0,sizeof(storage_type));
storage_type.content = A_surfxml_storage___type_content;
}
void ETag_surfxml_mount(void)
{
- s_sg_platf_mount_cbarg_t mount = SG_PLATF_MOUNT_INITIALIZER;
+ s_sg_platf_mount_cbarg_t mount;
memset(&mount,0,sizeof(mount));
mount.name = A_surfxml_mount_name;
}
void ETag_surfxml_host(void) {
- s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
- char* buf;
+ s_sg_platf_host_cbarg_t host;
memset(&host,0,sizeof(host));
+ char* buf;
host.properties = current_property_set;
else {
xbt_dynar_t pstate_list = xbt_str_split(buf, ",");
unsigned int i;
- for (i = 0; i < xbt_dynar_length(pstate_list); i++) {
- double speed;
- char* speed_str;
-
- xbt_dynar_get_cpy(pstate_list, i, &speed_str);
+ char* speed_str;
+ xbt_dynar_foreach(pstate_list, i, speed_str) {
xbt_str_trim(speed_str, nullptr);
- speed = surf_parse_get_speed(speed_str,"speed of host", host.id);
+ double speed = surf_parse_get_speed(speed_str,"speed of host", host.id);
xbt_dynar_push_as(host.speed_per_pstate, double, speed);
XBT_DEBUG("Speed value: %f", speed);
}
void STag_surfxml_host___link(void){
XBT_DEBUG("Create a Host_link for %s",A_surfxml_host___link_id);
- s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
+ s_sg_platf_host_link_cbarg_t host_link;
memset(&host_link,0,sizeof(host_link));
host_link.id = A_surfxml_host___link_id;
}
void STag_surfxml_router(void){
- s_sg_platf_router_cbarg_t router = SG_PLATF_ROUTER_INITIALIZER;
+ s_sg_platf_router_cbarg_t router;
memset(&router, 0, sizeof(router));
router.id = A_surfxml_router_id;
}
void ETag_surfxml_cluster(void){
- s_sg_platf_cluster_cbarg_t cluster = SG_PLATF_CLUSTER_INITIALIZER;
+ s_sg_platf_cluster_cbarg_t cluster;
memset(&cluster,0,sizeof(cluster));
cluster.properties = as_current_property_set;
void STag_surfxml_cabinet(void){
parse_after_config();
- s_sg_platf_cabinet_cbarg_t cabinet = SG_PLATF_CABINET_INITIALIZER;
+ s_sg_platf_cabinet_cbarg_t cabinet;
memset(&cabinet,0,sizeof(cabinet));
cabinet.id = A_surfxml_cabinet_id;
cabinet.prefix = A_surfxml_cabinet_prefix;
void STag_surfxml_peer(void){
parse_after_config();
- s_sg_platf_peer_cbarg_t peer = SG_PLATF_PEER_INITIALIZER;
+ s_sg_platf_peer_cbarg_t peer;
memset(&peer,0,sizeof(peer));
peer.id = A_surfxml_peer_id;
peer.speed = surf_parse_get_speed(A_surfxml_peer_speed, "speed of peer", peer.id);
}
void ETag_surfxml_link(void){
- s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+ s_sg_platf_link_cbarg_t link;
memset(&link,0,sizeof(link));
link.properties = current_property_set;
}
void ETag_surfxml_backbone(void){
- s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+ s_sg_platf_link_cbarg_t link;
memset(&link,0,sizeof(link));
link.properties = nullptr;
-
link.id = A_surfxml_backbone_id;
link.bandwidth = surf_parse_get_bandwidth(A_surfxml_backbone_bandwidth, "bandwidth of backbone", link.id);
link.latency = surf_parse_get_time(A_surfxml_backbone_latency, "latency of backbone", link.id);
}
void ETag_surfxml_trace(void){
- s_sg_platf_trace_cbarg_t trace = SG_PLATF_TRACE_INITIALIZER;
+ s_sg_platf_trace_cbarg_t trace;
memset(&trace,0,sizeof(trace));
trace.id = A_surfxml_trace_id;
void STag_surfxml_trace___connect(void){
parse_after_config();
- s_sg_platf_trace_connect_cbarg_t trace_connect = SG_PLATF_TRACE_CONNECT_INITIALIZER;
+ s_sg_platf_trace_connect_cbarg_t trace_connect;
memset(&trace_connect,0,sizeof(trace_connect));
trace_connect.element = A_surfxml_trace___connect_element;
void STag_surfxml_AS(void){
parse_after_config();
AS_TAG = 1;
- s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
- AS.id = A_surfxml_AS_id;
- AS.routing = (int)A_surfxml_AS_routing;
+ s_sg_platf_AS_cbarg_t AS = { A_surfxml_AS_id, (int)A_surfxml_AS_routing};
as_current_property_set = nullptr;
}
void ETag_surfxml_process(void){
- s_sg_platf_process_cbarg_t process = SG_PLATF_PROCESS_INITIALIZER;
+ s_sg_platf_process_cbarg_t process;
memset(&process,0,sizeof(process));
process.argc = argc;