void AsFloyd::getRouteAndLatency(RoutingEdgePtr src, RoutingEdgePtr dst, sg_platf_route_cbarg_t res, double *lat) { /* set utils vars */ size_t table_size = xbt_dynar_length(p_indexNetworkElm); this->srcDstCheck(src, dst); /* create a result route */ xbt_dynar_t route_stack = xbt_dynar_new(sizeof(sg_platf_route_cbarg_t), NULL); int pred; int cur = dst->getId(); do { pred = TO_FLOYD_PRED(src->getId(), cur); if (pred == -1) THROWF(arg_error, 0, "No route from '%s' to '%s'", src->getName(), dst->getName()); xbt_dynar_push_as(route_stack, sg_platf_route_cbarg_t, TO_FLOYD_LINK(pred, cur)); cur = pred; } while (cur != src->getId()); if (p_hierarchy == SURF_ROUTING_RECURSIVE) { res->gw_src = xbt_dynar_getlast_as(route_stack, sg_platf_route_cbarg_t)->gw_src; res->gw_dst = xbt_dynar_getfirst_as(route_stack, sg_platf_route_cbarg_t)->gw_dst; } sg_routing_edge_t prev_dst_gw = NULL; while (!xbt_dynar_is_empty(route_stack)) { sg_platf_route_cbarg_t e_route = xbt_dynar_pop_as(route_stack, sg_platf_route_cbarg_t); xbt_dynar_t links; void *link; unsigned int cpt; if (p_hierarchy == SURF_ROUTING_RECURSIVE && prev_dst_gw != NULL && strcmp(prev_dst_gw->getName(), e_route->gw_src->getName())) { routing_get_route_and_latency(prev_dst_gw, e_route->gw_src, &res->link_list, lat); } links = e_route->link_list; xbt_dynar_foreach(links, cpt, link) { xbt_dynar_push_as(res->link_list, sg_routing_link_t, link); if (lat) *lat += static_cast<NetworkLinkPtr>(link)->getLatency(); } prev_dst_gw = e_route->gw_dst; }
int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; MSG_init(&argc, argv); xbt_assert(argc > 1, "Usage: %s platform_file\n\tExample: %s msg_platform.xml\n", argv[0], argv[0]); MSG_create_environment(argv[1]); /** - Load the platform description */ MSG_function_register("dream_master", dream_master); /** - Create and deploy the @ref dream_master */ xbt_dynar_t hosts = MSG_hosts_as_dynar(); MSG_process_create("dream_master", dream_master, NULL, xbt_dynar_getfirst_as(hosts, msg_host_t)); xbt_dynar_free(&hosts); res = MSG_main(); /** - Run the simulation */ XBT_INFO("Simulation time %g", MSG_get_clock()); return res != MSG_OK; }
/** Test function */ msg_error_t test_all(const char *platform_file) { msg_error_t res = MSG_OK; xbt_dynar_t all_hosts; msg_host_t first_host; MSG_config("host/model", "ptask_L07"); MSG_create_environment(platform_file); all_hosts = MSG_hosts_as_dynar(); first_host = xbt_dynar_getfirst_as(all_hosts,msg_host_t); MSG_process_create("test", test, NULL, first_host); res = MSG_main(); xbt_dynar_free(&all_hosts); XBT_INFO("Simulation time %g", MSG_get_clock()); return res; }
int main(int argc, char *argv[]) { MSG_init(&argc, argv); MSG_config("host/model", "ptask_L07"); xbt_assert(argc <= 3, "1Usage: %s <platform file> [--energy]", argv[0]); xbt_assert(argc >= 2, "2Usage: %s <platform file> [--energy]", argv[0]); if(argc == 3 && argv[2][2] == 'e') sg_energy_plugin_init(); MSG_create_environment(argv[1]); /* Pick a process, no matter which, from the platform file */ xbt_dynar_t all_hosts = MSG_hosts_as_dynar(); msg_host_t first_host = xbt_dynar_getfirst_as(all_hosts,msg_host_t); xbt_dynar_free(&all_hosts); MSG_process_create("test", runner, NULL, first_host); msg_error_t res = MSG_main(); XBT_INFO("Simulation done."); return res != MSG_OK; }