/** * Main function * Create the platform, list the available hosts and give them some work */ int main(int argc, char **argv) { unsigned long seed[] = {134, 233445, 865, 2634, 424242, 876543}; int connected; int max_tries = 10; //MSG initialization MSG_init(&argc, argv); //Set up the seed for the platform generation platf_random_seed(seed); XBT_INFO("creating nodes..."); platf_graph_uniform(50); do { max_tries--; XBT_INFO("creating links..."); platf_graph_clear_links(); platf_graph_interconnect_uniform(0.07); //Unrealistic, but simple XBT_INFO("done. Check connectedness..."); connected = platf_graph_is_connected(); XBT_INFO("Is it connected : %s", connected ? "yes" : (max_tries ? "no, retrying" : "no")); } while(!connected && max_tries); if(!connected && !max_tries) { xbt_die("Impossible to connect the graph, aborting."); } XBT_INFO("registering callbacks..."); platf_graph_promoter(promoter_1); platf_graph_labeler(labeler_1); XBT_INFO("protmoting..."); platf_do_promote(); XBT_INFO("labeling..."); platf_do_label(); XBT_INFO("Putting it in surf..."); platf_generate(); XBT_INFO("Let's get the available hosts and dispatch work:"); unsigned int i; msg_host_t host = NULL; msg_host_t host_master = NULL; xbt_dynar_t host_dynar = MSG_hosts_as_dynar(); char** hostname_list = xbt_malloc(sizeof(char*) * xbt_dynar_length(host_dynar)); xbt_dynar_foreach(host_dynar, i, host) { MSG_process_create("slave", slave, NULL, host); if(i==0) { //The first node will also be the master XBT_INFO("%s will be the master", MSG_host_get_name(host)); host_master = host; } hostname_list[i] = (char*) MSG_host_get_name(host); }
/** Main function */ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; unsigned long seed_platf_gen[] = {134, 233445, 865, 2634, 424242, 876543}; unsigned long seed_trace_gen[] = {8865244, 356772, 42, 77465, 2098754, 8725442}; int connected; int max_tries = 10; //MSG initialization MSG_init(&argc, argv); //Set up the seed for the platform generation platf_random_seed(seed_platf_gen); //Set up the RngStream for trace generation sg_platf_rng_stream_init(seed_trace_gen); XBT_INFO("creating nodes..."); platf_graph_uniform(10); do { max_tries--; XBT_INFO("creating links..."); platf_graph_clear_links(); platf_graph_interconnect_waxman(0.9, 0.4); XBT_INFO("done. Check connectedness..."); connected = platf_graph_is_connected(); XBT_INFO("Is it connected : %s", connected ? "yes" : (max_tries ? "no, retrying" : "no")); } while(!connected && max_tries); if(!connected && !max_tries) { xbt_die("Impossible to connect the graph, aborting."); } XBT_INFO("registering callbacks..."); platf_graph_promoter(promoter_1); platf_graph_labeler(labeler_1); XBT_INFO("promoting..."); platf_do_promote(); XBT_INFO("labeling..."); platf_do_label(); XBT_INFO("Putting it in surf..."); platf_generate(); XBT_INFO("Let's get the available hosts and dispatch work:"); unsigned int i; msg_host_t host = NULL; msg_host_t host_master = NULL; msg_process_t process = NULL; xbt_dynar_t host_dynar = MSG_hosts_as_dynar(); char** hostname_list = xbt_malloc(sizeof(char*) * xbt_dynar_length(host_dynar)); xbt_dynar_foreach(host_dynar, i, host) { process = MSG_process_create("slave", slave, NULL, host); MSG_process_auto_restart_set(process, TRUE); hostname_list[i] = (char*) MSG_host_get_name(host); }