-}
-
-void surf_parse_reset_parser(void)
-{
- surf_parse_free_callbacks();
- STag_surfxml_platform_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_platform_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_host_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_router_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_link_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_route_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_link_c_ctn_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_link_c_ctn_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_process_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_process_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_argument_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_argument_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_prop_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_trace_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_trace_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_trace_c_connect_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_trace_c_connect_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_random_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_AS_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_AS_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_ASroute_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_ASroute_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- STag_surfxml_bypassRoute_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
- ETag_surfxml_bypassRoute_cb_list = xbt_dynar_new(sizeof(void_f_void_t), NULL);
-}
-
-void STag_surfxml_include(void)
-{
- xbt_dynar_push(surf_input_buffer_stack, &surf_input_buffer);
- xbt_dynar_push(surf_file_to_parse_stack, &surf_file_to_parse);
-
- surf_file_to_parse = surf_fopen(A_surfxml_include_file, "r");
- xbt_assert1((surf_file_to_parse), "Unable to open \"%s\"\n", A_surfxml_include_file);
- surf_input_buffer = surf_parse__create_buffer(surf_file_to_parse, 10);
- surf_parse__switch_to_buffer(surf_input_buffer);
- printf("STAG\n");
- fflush(NULL);
-}
-
-void ETag_surfxml_include(void)
-{
- printf("ETAG\n");
- fflush(NULL);
- surf_parse__delete_buffer(surf_input_buffer);
- fclose(surf_file_to_parse);
- xbt_dynar_pop(surf_file_to_parse_stack, &surf_file_to_parse);
- xbt_dynar_pop(surf_input_buffer_stack, &surf_input_buffer);
-}
-
-void STag_surfxml_platform(void)
-{
- double version = 0.0;
-
- sscanf(A_surfxml_platform_version, "%lg", &version);
-
- xbt_assert0((version >= 1.0), "******* BIG FAT WARNING *********\n "
- "You're using an ancient XML file. "
- "Since SimGrid 3.1, units are Bytes, Flops, and seconds "
- "instead of MBytes, MFlops and seconds. "
- "A script (surfxml_update.pl) to help you convert your old "
- "platform files "
- "is available in the contrib/platform_generation directory "
- "of the simgrid repository. Please check also out the "
- "SURF section of the ChangeLog for the 3.1 version. "
- "Last, do not forget to also update your values for "
- "the calls to MSG_task_create (if any).");
- xbt_assert0((version >= 2.0), "******* BIG FAT WARNING *********\n "
- "You're using an old XML file. "
- "A script (surfxml_update.pl) to help you convert your old "
- "platform files "
- "is available in the contrib/platform_generation directory "
- "of the simgrid repository.");
-
- surfxml_call_cb_functions(STag_surfxml_platform_cb_list);
-
-}
-
-void ETag_surfxml_platform(void)
-{
- surfxml_call_cb_functions(ETag_surfxml_platform_cb_list);
- xbt_dict_free(&random_data_list); // FIXME: DUPLICATE
-}
-
-#define parse_method(type,name) void type##Tag_surfxml_##name(void) { surfxml_call_cb_functions(type##Tag_surfxml_##name##_cb_list); }
-
-parse_method(S,host); parse_method(E,host);
-parse_method(S,router); parse_method(E,router);
-parse_method(S,link); parse_method(E,link);
-parse_method(S,route); parse_method(E,route);
-parse_method(S,link_c_ctn); parse_method(E,link_c_ctn);
-parse_method(S,process); parse_method(E,process);
-parse_method(S,argument); parse_method(E,argument);
-parse_method(S,prop); parse_method(E,prop);
-parse_method(S,trace); parse_method(E,trace);
-parse_method(S,trace_c_connect); parse_method(E,trace_c_connect);
-parse_method(S,random); parse_method(E,random);
-parse_method(S,AS); parse_method(E,AS);
-parse_method(S,ASroute); parse_method(E,ASroute);
-parse_method(S,bypassRoute); parse_method(E,bypassRoute);
+ xbt_dynar_free(&STag_surfxml_cluster_cb_list);
+ xbt_dynar_free(&ETag_surfxml_cluster_cb_list);
+ xbt_dynar_free(&STag_surfxml_peer_cb_list);
+ xbt_dynar_free(&ETag_surfxml_peer_cb_list);
+ xbt_dynar_free(&STag_surfxml_include_cb_list);
+ xbt_dynar_free(&ETag_surfxml_include_cb_list);
+}
+
+/* Stag and Etag parse functions */
+void ETag_surfxml_router(void) { /* ignored -- do not add content here */ }
+
+void STag_surfxml_platform(void) {
+ _XBT_GNUC_UNUSED double version = surf_parse_get_double(A_surfxml_platform_version);
+
+ xbt_assert((version >= 1.0), "******* BIG FAT WARNING *********\n "
+ "You're using an ancient XML file.\n"
+ "Since SimGrid 3.1, units are Bytes, Flops, and seconds "
+ "instead of MBytes, MFlops and seconds.\n"
+
+ "Use simgrid_update_xml to update your file automatically. "
+ "This program is installed automatically with SimGrid, or "
+ "available in the tools/ directory of the source archive.\n"
+
+ "Please check also out the SURF section of the ChangeLog for "
+ "the 3.1 version for more information. \n"
+
+ "Last, do not forget to also update your values for "
+ "the calls to MSG_task_create (if any).");
+ xbt_assert((version >= 3.0), "******* BIG FAT WARNING *********\n "
+ "You're using an old XML file.\n"
+ "Use simgrid_update_xml to update your file automatically. "
+ "This program is installed automatically with SimGrid, or "
+ "available in the tools/ directory of the source archive.");
+
+ sg_platf_open();
+}
+void ETag_surfxml_platform(void){
+ sg_platf_close();
+}
+
+void STag_surfxml_host(void){
+ s_sg_platf_host_cbarg_t host;
+ memset(&host,0,sizeof(host));
+
+ xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
+ host.properties = current_property_set = xbt_dict_new();
+
+ host.id = A_surfxml_host_id;
+ host.power_peak = get_cpu_power(A_surfxml_host_power);
+ host.power_scale = surf_parse_get_double( A_surfxml_host_availability);
+ host.core_amount = surf_parse_get_int(A_surfxml_host_core);
+ host.power_trace = tmgr_trace_new(A_surfxml_host_availability_file);
+ host.state_trace = tmgr_trace_new(A_surfxml_host_state_file);
+ xbt_assert((A_surfxml_host_state == A_surfxml_host_state_ON) ||
+ (A_surfxml_host_state == A_surfxml_host_state_OFF), "Invalid state");
+ if (A_surfxml_host_state == A_surfxml_host_state_ON)
+ host.initial_state = SURF_RESOURCE_ON;
+ if (A_surfxml_host_state == A_surfxml_host_state_OFF)
+ host.initial_state = SURF_RESOURCE_OFF;
+ host.coord = A_surfxml_host_coordinates;
+
+ sg_platf_new_host(&host);
+}
+void ETag_surfxml_host(void) {
+ current_property_set = NULL;
+}
+
+void STag_surfxml_router(void){
+ s_sg_platf_router_cbarg_t router;
+ memset(&router, 0, sizeof(router));
+
+ router.id = A_surfxml_router_id;
+ router.coord = A_surfxml_router_coordinates;
+
+ sg_platf_new_router(&router);
+}
+
+void STag_surfxml_cluster(void){
+ struct_cluster = xbt_new0(s_surf_parsing_cluster_arg_t, 1);
+ struct_cluster->V_cluster_id = A_surfxml_cluster_id;
+ struct_cluster->V_cluster_prefix = A_surfxml_cluster_prefix;
+ struct_cluster->V_cluster_suffix = A_surfxml_cluster_suffix;
+ struct_cluster->V_cluster_radical = A_surfxml_cluster_radical;
+ struct_cluster->S_cluster_power= surf_parse_get_double(A_surfxml_cluster_power);
+ struct_cluster->S_cluster_core = surf_parse_get_int(A_surfxml_cluster_core);
+ struct_cluster->S_cluster_bw = surf_parse_get_double(A_surfxml_cluster_bw);
+ struct_cluster->S_cluster_lat = surf_parse_get_double(A_surfxml_cluster_lat);
+ if(strcmp(A_surfxml_cluster_bb_bw,""))
+ struct_cluster->S_cluster_bb_bw = surf_parse_get_double(A_surfxml_cluster_bb_bw);
+ if(strcmp(A_surfxml_cluster_bb_lat,""))
+ struct_cluster->S_cluster_bb_lat = surf_parse_get_double(A_surfxml_cluster_bb_lat);
+ if(!strcmp(A_surfxml_cluster_router_id,""))
+ struct_cluster->S_cluster_router_id = bprintf("%s%s_router%s",
+ struct_cluster->V_cluster_prefix,
+ struct_cluster->V_cluster_id,
+ struct_cluster->V_cluster_suffix);
+ else
+ struct_cluster->S_cluster_router_id = A_surfxml_cluster_router_id;
+
+ struct_cluster->V_cluster_sharing_policy = AX_surfxml_cluster_sharing_policy;
+ struct_cluster->V_cluster_bb_sharing_policy = AX_surfxml_cluster_bb_sharing_policy;
+
+ struct_cluster->V_cluster_availability_file = xbt_strdup(A_surfxml_cluster_availability_file);
+ struct_cluster->V_cluster_state_file = xbt_strdup(A_surfxml_cluster_state_file);
+
+ surfxml_call_cb_functions(STag_surfxml_cluster_cb_list);
+}
+void ETag_surfxml_cluster(void){
+ surfxml_call_cb_functions(ETag_surfxml_cluster_cb_list);
+ if( !strcmp(A_surfxml_cluster_router_id,""))
+ xbt_free(struct_cluster->S_cluster_router_id);
+ xbt_free(struct_cluster->V_cluster_availability_file);
+ xbt_free(struct_cluster->V_cluster_state_file);
+ xbt_free(struct_cluster);
+}
+
+void STag_surfxml_peer(void){
+ struct_peer = xbt_new0(s_surf_parsing_peer_arg_t, 1);
+ struct_peer->V_peer_id = xbt_strdup(A_surfxml_peer_id);
+ struct_peer->V_peer_power = xbt_strdup(A_surfxml_peer_power);
+ struct_peer->V_peer_bw_in = xbt_strdup(A_surfxml_peer_bw_in);
+ struct_peer->V_peer_bw_out = xbt_strdup(A_surfxml_peer_bw_out);
+ struct_peer->V_peer_lat = xbt_strdup(A_surfxml_peer_lat);
+ struct_peer->V_peer_coord = xbt_strdup(A_surfxml_peer_coordinates);
+ struct_peer->V_peer_availability_trace = xbt_strdup(A_surfxml_peer_availability_file);
+ struct_peer->V_peer_state_trace = xbt_strdup(A_surfxml_peer_state_file);
+ surfxml_call_cb_functions(STag_surfxml_peer_cb_list);
+}
+void ETag_surfxml_peer(void){
+ surfxml_call_cb_functions(ETag_surfxml_peer_cb_list);
+ xbt_free(struct_peer->V_peer_id);
+ xbt_free(struct_peer->V_peer_power);
+ xbt_free(struct_peer->V_peer_bw_in);
+ xbt_free(struct_peer->V_peer_bw_out);
+ xbt_free(struct_peer->V_peer_lat);
+ xbt_free(struct_peer->V_peer_coord);
+ xbt_free(struct_peer->V_peer_availability_trace);
+ xbt_free(struct_peer->V_peer_state_trace);
+ xbt_free(struct_peer);
+}
+void STag_surfxml_link(void){
+ s_sg_platf_link_cbarg_t link;
+ memset(&link,0,sizeof(link));
+
+ xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
+ link.properties = current_property_set = xbt_dict_new();
+
+ link.id = A_surfxml_link_id;
+ link.bandwidth = surf_parse_get_double(A_surfxml_link_bandwidth);
+ link.bandwidth_trace = tmgr_trace_new(A_surfxml_link_bandwidth_file);
+ link.latency = surf_parse_get_double(A_surfxml_link_latency);
+ link.latency_trace = tmgr_trace_new(A_surfxml_link_latency_file);
+ /* FIXME: use a switch here */
+ xbt_assert((A_surfxml_link_state == A_surfxml_link_state_ON) ||
+ (A_surfxml_link_state == A_surfxml_link_state_OFF), "Invalid state");
+ if (A_surfxml_link_state == A_surfxml_link_state_ON)
+ link.state = SURF_RESOURCE_ON;
+ if (A_surfxml_link_state == A_surfxml_link_state_OFF)
+ link.state = SURF_RESOURCE_OFF;
+ link.state_trace = tmgr_trace_new(A_surfxml_link_state_file);
+
+ /* FIXME: use a switch here */
+ if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_SHARED)
+ link.policy = SURF_LINK_SHARED;
+ else
+ {
+ if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_FATPIPE)
+ link.policy = SURF_LINK_FATPIPE;
+ else if (A_surfxml_link_sharing_policy == A_surfxml_link_sharing_policy_FULLDUPLEX)
+ link.policy = SURF_LINK_FULLDUPLEX;
+ }
+
+ sg_platf_new_link(&link);
+}
+void ETag_surfxml_link(void){
+ current_property_set = NULL;
+}
+
+void STag_surfxml_route(void){
+ surfxml_call_cb_functions(STag_surfxml_route_cb_list);
+}
+void STag_surfxml_link_ctn(void){
+ surfxml_call_cb_functions(STag_surfxml_link_ctn_cb_list);
+}
+void STag_surfxml_process(void){
+ surfxml_call_cb_functions(STag_surfxml_process_cb_list);
+}
+void STag_surfxml_argument(void){
+ surfxml_call_cb_functions(STag_surfxml_argument_cb_list);
+}
+void STag_surfxml_prop(void){
+ surfxml_call_cb_functions(STag_surfxml_prop_cb_list);
+}
+void STag_surfxml_trace(void){
+ surfxml_call_cb_functions(STag_surfxml_trace_cb_list);
+}
+void STag_surfxml_trace_connect(void){
+ surfxml_call_cb_functions(STag_surfxml_trace_connect_cb_list);
+}
+void STag_surfxml_AS(void){
+ surfxml_call_cb_functions(STag_surfxml_AS_cb_list);
+}
+void STag_surfxml_ASroute(void){
+ surfxml_call_cb_functions(STag_surfxml_ASroute_cb_list);
+}
+void STag_surfxml_bypassRoute(void){
+ surfxml_call_cb_functions(STag_surfxml_bypassRoute_cb_list);
+}
+void STag_surfxml_config(void){
+ XBT_DEBUG("START configuration name = %s",A_surfxml_config_id);
+ xbt_assert(current_property_set == NULL, "Someone forgot to reset the property set to NULL in its closing tag (or XML malformed)");
+ current_property_set = xbt_dict_new();
+
+}
+void ETag_surfxml_config(void){
+ xbt_dict_cursor_t cursor = NULL;
+ char *key;
+ char *elem;
+ char *cfg;
+ xbt_dict_foreach(current_property_set, cursor, key, elem) {
+ cfg = bprintf("%s:%s",key,elem);
+ if(xbt_cfg_is_default_value(_surf_cfg_set, key))
+ xbt_cfg_set_parse(_surf_cfg_set, cfg);
+ else
+ XBT_INFO("The custom configuration '%s' is already defined by user!",key);
+ free(cfg);
+ }
+ XBT_DEBUG("End configuration name = %s",A_surfxml_config_id);
+ xbt_dict_free(¤t_property_set);
+}
+void STag_surfxml_random(void){
+ surfxml_call_cb_functions(STag_surfxml_random_cb_list);
+}
+
+#define parse_method(type,name) \
+void type##Tag_surfxml_##name(void) \
+{ surfxml_call_cb_functions(type##Tag_surfxml_##name##_cb_list); }
+parse_method(E, route);
+parse_method(E, link_ctn);
+parse_method(E, process);
+parse_method(E, argument);
+parse_method(E, prop);
+parse_method(E, trace);
+parse_method(E, trace_connect);
+parse_method(E, random);
+parse_method(E, AS);
+parse_method(E, ASroute);
+parse_method(E, bypassRoute);