/** @brief Displays debugging informations about a workstation */ void SD_workstation_dump(SD_workstation_t ws) { xbt_dict_t props; xbt_dict_cursor_t cursor=NULL; char *key,*data; SD_task_t task = NULL; XBT_INFO("Displaying workstation %s", SD_workstation_get_name(ws)); XBT_INFO(" - power: %.0f", SD_workstation_get_power(ws)); XBT_INFO(" - available power: %.2f", SD_workstation_get_available_power(ws)); switch (sg_host_sd(ws)->access_mode){ case SD_WORKSTATION_SHARED_ACCESS: XBT_INFO(" - access mode: Space shared"); break; case SD_WORKSTATION_SEQUENTIAL_ACCESS: XBT_INFO(" - access mode: Exclusive"); task = SD_workstation_get_current_task(ws); if(task) XBT_INFO(" current running task: %s", SD_task_get_name(task)); else XBT_INFO(" no task running"); break; default: break; } props = SD_workstation_get_properties(ws); if (!xbt_dict_is_empty(props)){ XBT_INFO(" - properties:"); xbt_dict_foreach(props,cursor,key,data) { XBT_INFO(" %s->%s",key,data); }
int main(int argc, char **argv) { char *platformFile = NULL; int totalHosts, totalLinks; unsigned int i; xbt_dict_t props = NULL; xbt_dict_cursor_t cursor = NULL; xbt_lib_cursor_t cursor_src = NULL; xbt_lib_cursor_t cursor_dst = NULL; char *src,*dst,*key,*data; char **value; xbt_ex_t e; const SD_workstation_t *hosts; const SD_link_t *links; SD_init(&argc, argv); platformFile = argv[1]; XBT_DEBUG("%s", platformFile); TRY { SD_create_environment(platformFile); } CATCH(e) { xbt_die("Error while loading %s: %s",platformFile,e.msg); } printf("<?xml version='1.0'?>\n"); printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n"); printf("<platform version=\"3\">\n"); printf("<AS id=\"AS0\" routing=\"Full\">\n"); // Hosts totalHosts = SD_workstation_get_number(); hosts = SD_workstation_get_list(); qsort((void *) hosts, totalHosts, sizeof(SD_workstation_t), name_compare_hosts); for (i = 0; i < totalHosts; i++) { printf(" <host id=\"%s\" power=\"%.0f\"", SD_workstation_get_name(hosts[i]), SD_workstation_get_power(hosts[i])); props = SD_workstation_get_properties(hosts[i]); if (props && xbt_dict_length(props) > 0) { printf(">\n"); xbt_dict_foreach(props, cursor, key, data) { printf(" <prop id=\"%s\" value=\"%s\"/>\n", key, data); } printf(" </host>\n"); } else {
int main(int argc, char **argv) { const SD_workstation_t *workstations; SD_workstation_t w1; SD_workstation_t w2; const char *name1; const char *name2; xbt_dict_t props; xbt_dict_cursor_t cursor = NULL; char *key, *data; char noexist[] = "NoProp"; const char *value; char exist[] = "Hdd"; /* initialisation of SD */ SD_init(&argc, argv); if (argc < 2) { XBT_INFO("Usage: %s platform_file", argv[0]); XBT_INFO("example: %s sd_platform.xml", argv[0]); exit(1); } SD_create_environment(argv[1]); /* init of platform elements */ workstations = SD_workstation_get_list(); w1 = workstations[0]; w2 = workstations[1]; SD_workstation_set_access_mode(w2, SD_WORKSTATION_SEQUENTIAL_ACCESS); name1 = SD_workstation_get_name(w1); name2 = SD_workstation_get_name(w2); /* The host properties can be retrived from all interfaces */ XBT_INFO("Property list for workstation %s", name1); /* Get the property list of the workstation 1 */ props = SD_workstation_get_properties(w1); /* Trying to set a new property */ xbt_dict_set(props, "NewProp", strdup("newValue"), NULL); /* Print the properties of the workstation 1 */ xbt_dict_foreach(props, cursor, key, data) { XBT_INFO("\tProperty: %s has value: %s", key, data); }
/** * \brief Returns the value of a given workstation property * * \param ws a workstation * \param name a property name * \return value of a property (or NULL if property not set) */ const char *SD_workstation_get_property_value(SD_workstation_t ws, const char *name) { return xbt_dict_get_or_null(SD_workstation_get_properties(ws), name); }
int main(int argc, char **argv) { char *platformFile = NULL; int totalHosts, totalLinks; int timings=0; int downgrade = 0; int version = 3; const char *link_ctn = link_ctn_v3; unsigned int i; xbt_dict_t props = NULL; xbt_dict_cursor_t cursor = NULL; xbt_lib_cursor_t cursor_src = NULL; xbt_lib_cursor_t cursor_dst = NULL; char *src,*dst,*key,*data; sg_routing_edge_t value1; sg_routing_edge_t value2; const SD_workstation_t *hosts; const SD_link_t *links; xbt_os_timer_t parse_time = xbt_os_timer_new(); setvbuf(stdout, NULL, _IOLBF, 0); SD_init(&argc, argv); if (parse_cmdline(&timings, &downgrade, &platformFile, argc, argv) || !platformFile) { xbt_die("Invalid command line arguments: expected [--timings|--downgrade] platformFile"); } XBT_DEBUG("%d,%d,%s", timings, downgrade, platformFile); if (downgrade) { version = 2; link_ctn = link_ctn_v2; } create_environment(parse_time, platformFile); if (timings) { XBT_INFO("Parsing time: %fs (%d hosts, %d links)", xbt_os_timer_elapsed(parse_time),SD_workstation_get_number(),SD_link_get_number()); } else { printf("<?xml version='1.0'?>\n"); printf("<!DOCTYPE platform SYSTEM \"http://simgrid.gforge.inria.fr/simgrid.dtd\">\n"); printf("<platform version=\"%d\">\n", version); if (!downgrade) printf("<AS id=\"AS0\" routing=\"Full\">\n"); // Hosts totalHosts = SD_workstation_get_number(); hosts = SD_workstation_get_list(); qsort((void *) hosts, totalHosts, sizeof(SD_workstation_t), name_compare_hosts); for (i = 0; i < totalHosts; i++) { printf(" <host id=\"%s\" power=\"%.0f\"", SD_workstation_get_name(hosts[i]), SD_workstation_get_power(hosts[i])); props = SD_workstation_get_properties(hosts[i]); if (props && !xbt_dict_is_empty(props)) { printf(">\n"); xbt_dict_foreach(props, cursor, key, data) { printf(" <prop id=\"%s\" value=\"%s\"/>\n", key, data); } printf(" </host>\n"); } else {