int main(int argc, char *argv[]) { MSG_init(&argc, argv); xbt_assert(argc > 2, "Usage: %s platform_file deployment_file\n" "\tExample: %s msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); MSG_create_environment(argv[1]); //declaring user variables TRACE_host_variable_declare("HDD_capacity"); TRACE_host_variable_declare("HDD_utilization"); //register functions and launch deployment MSG_function_register("master", trace_fun); MSG_function_register("worker", trace_fun); MSG_launch_application(argv[2]); MSG_main(); //get user declared variables unsigned int cursor; char *variable; xbt_dynar_t host_variables = TRACE_get_host_variables (); if (host_variables){ XBT_INFO ("Declared host variables:"); xbt_dynar_foreach (host_variables, cursor, variable){ XBT_INFO ("%s", variable); } xbt_dynar_free (&host_variables); }
int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; MSG_init(&argc, argv); /* Explicit initialization of the action module is required now*/ MSG_action_init(); xbt_assert(argc > 3,"Usage: %s platform_file deployment_file [action_files]\n" "\texample: %s platform.xml deployment.xml actions # if all actions are in the same file\n" "\texample: %s platform.xml deployment.xml # if actions are in separate files, specified in deployment\n", argv[0], argv[0], argv[0]); MSG_create_environment(argv[1]); MSG_launch_application(argv[2]); /* Action registration */ xbt_replay_action_register("open", action_open); xbt_replay_action_register("read", action_read); xbt_replay_action_register("close", action_close); if (!opened_files) opened_files = xbt_dict_new_homogeneous(NULL); /* Actually do the simulation using MSG_action_trace_run */ res = MSG_action_trace_run(argv[3]); // it's ok to pass a NULL argument here XBT_INFO("Simulation time %g", MSG_get_clock()); if (opened_files) xbt_dict_free(&opened_files); /* Explicit finalization of the action module is required now*/ MSG_action_exit(); return res!=MSG_OK; }
/** Main function */ int main(int argc, char *argv[]) { MSG_init(&argc, argv); if (argc < 3) { printf("Usage: %s platform_file deployment_file\n", argv[0]); exit(1); } char *platform_file = argv[1]; char *deployment_file = argv[2]; MSG_create_environment(platform_file); //declaring user variables TRACE_host_variable_declare("HDD_capacity"); TRACE_host_variable_declare("HDD_utilization"); //register functions and launch deployment MSG_function_register("master", master); MSG_function_register("slave", master); MSG_launch_application(deployment_file); MSG_main(); //get user declared variables unsigned int cursor; char *variable; xbt_dynar_t host_variables = TRACE_get_host_variables (); if (host_variables){ XBT_INFO ("Declared host variables:"); xbt_dynar_foreach (host_variables, cursor, variable){ XBT_INFO ("%s", variable); } xbt_dynar_free (&host_variables); }
int main(int argc, char **argv) { int i; msg_error_t res = MSG_OK; MSG_init(&argc, argv); surf_parse = surf_parse_bypass_platform; MSG_create_environment(NULL); MSG_function_register("host", host); xbt_dynar_t hosts = MSG_hosts_as_dynar(); nb_hosts = xbt_dynar_length(hosts); XBT_INFO("Number of host '%d'",nb_hosts); for(i = 0 ; i<nb_hosts; i++) { char* name_host = bprintf("%d",i); MSG_process_create( name_host, host, NULL, xbt_dynar_get_as(hosts,i,msg_host_t) ); free(name_host); } xbt_dynar_free(&hosts); res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); if (res == MSG_OK) return 0; else return 1; }
/** * Bittorrent example launcher */ int main(int argc, char *argv[]) { xbt_dynar_t host_list; msg_host_t host; unsigned i; MSG_init(&argc, argv); /* Check the arguments */ if (argc < 3) { printf("Usage: %s platform_file deployment_file \n", argv[0]); return -1; } const char *platform_file = argv[1]; const char *deployment_file = argv[2]; MSG_create_environment(platform_file); host_list = MSG_hosts_as_dynar(); xbt_dynar_foreach(host_list, i, host) { char descr[512]; RngStream stream; snprintf(descr, sizeof descr, "RngSream<%s>", MSG_host_get_name(host)); stream = RngStream_CreateStream(descr); MSG_host_set_data(host, stream); }
int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; #ifdef _MSC_VER unsigned int prev_exponent_format = _set_output_format(_TWO_DIGIT_EXPONENT); #endif MSG_init(&argc, argv); if (argc < 3) { printf("Usage: %s platform_file deployment_file\n", argv[0]); printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); exit(1); } res = test_all(argv[1], argv[2]); #ifdef _MSC_VER _set_output_format(prev_exponent_format); #endif if (res == MSG_OK) return 0; else return 1; }
int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; sg_energy_plugin_init(); MSG_init(&argc, argv); if (argc != 3) { XBT_CRITICAL("Usage: %s platform_file deployment_file\n", argv[0]); XBT_CRITICAL ("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); exit(1); } MSG_create_environment(argv[1]); /* Application deployment */ MSG_function_register("dvfs_test", dvfs); MSG_launch_application(argv[2]); res = MSG_main(); XBT_INFO("Total simulation time: %e", MSG_get_clock()); if (res == MSG_OK) return 0; else return 1; }
int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; MSG_init(&argc, argv); MSG_create_environment(argv[1]); /* Trace categories */ TRACE_category_with_color("host0", "0 0 1"); TRACE_category_with_color("host1", "0 1 0"); TRACE_category_with_color("host2", "0 1 1"); TRACE_category_with_color("host3", "1 0 0"); TRACE_category_with_color("host4", "1 0 1"); TRACE_category_with_color("host5", "0 0 0"); TRACE_category_with_color("host6", "1 1 0"); TRACE_category_with_color("host7", "1 1 1"); TRACE_category_with_color("host8", "0 1 0"); /* Application deployment */ MSG_function_register("broadcaster", broadcaster); MSG_function_register("peer", peer); MSG_launch_application(argv[2]); res = MSG_main(); XBT_INFO("Total simulation time: %e", MSG_get_clock()); return res != MSG_OK; }
int MRSG_main (const char* plat, const char* depl, const char* conf) { char* argv[] = { "mrsg", "--cfg=tracing:1", "--cfg=tracing/buffer:1", "--cfg=tracing/filename:tracefile.trace", "--cfg=tracing/categorized:1", "--cfg=tracing/uncategorized:1", "--cfg=viva/categorized:cat.plist", "--cfg=viva/uncategorized:uncat.plist" }; int argc = sizeof(argv)/sizeof(argv[0]); msg_error_t res = MSG_OK; config.initialized = 0; check_config (); MSG_init (&argc, argv); res = run_simulation (plat, depl, conf); if (res == MSG_OK) return 0; else return 1; }
/** Main function */ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; /* Argument checking */ MSG_init(&argc, argv); if (argc < 3) { XBT_CRITICAL("Usage: %s platform_file deployment_file\n", argv[0]); XBT_CRITICAL("example: %s msg_platform.xml msg_deployment_suspend.xml\n", argv[0]); exit(1); } /* Simulation setting */ MSG_create_environment(argv[1]); /* Application deployment */ MSG_function_register("emigrant", emigrant); MSG_function_register("policeman", policeman); MSG_launch_application(argv[2]); /* Run the simulation */ mutex = xbt_mutex_init(); cond = xbt_cond_init(); res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); xbt_cond_destroy(cond); xbt_mutex_destroy(mutex); if (res == MSG_OK) return 0; else return 1; } /* end_of_main */
/** Main function */ int main(int argc, char *argv[]) { root_id = std::this_thread::get_id(); SIMIX_set_maestro(maestro, NULL); MSG_init(&argc, argv); if (argc != 2) { XBT_CRITICAL("Usage: %s platform_file\n", argv[0]); xbt_die("example: %s msg_platform.xml\n",argv[0]); } MSG_create_environment(argv[1]); /* Become one of the simulated process. * * This must be done after the creation of the platform because we are depending attaching to a host.*/ MSG_process_attach("sender", NULL, MSG_host_by_name("Tremblay"), NULL); ensure_root_tid(); // Execute the sender code: const char* subargv[3] = { "sender", "Jupiter", NULL }; sender(2, (char**) subargv); MSG_process_detach(); // Become root thread again XBT_INFO("Detached"); ensure_root_tid(); return 0; }
int MRA_main (const char* plat, const char* depl, const char* conf, const char* trace_vc) { int argc = 8; char* argv[] = { "mra", "--cfg=tracing:1", "--cfg=tracing/buffer:1", "--cfg=tracing/filename:tracefile.trace", "--cfg=tracing/categorized:1", "--cfg=tracing/uncategorized:1", "--cfg=viva/categorized:cat.plist", "--cfg=viva/uncategorized:uncat.plist" }; msg_error_t res_mra = MSG_OK; config_mra.initialized = 0; check_config_mra (); MSG_init (&argc, argv); res_mra = run_mra_simulation (plat, depl, conf, trace_vc); if (res_mra == MSG_OK) return 0; else return 1; }
/** Main function */ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; /* Check the given arguments */ MSG_init(&argc, argv); /* Explicit initialization of the action module is required now*/ MSG_action_init(); if (argc < 3) { printf("Usage: %s platform_file deployment_file [action_files]\n", argv[0]); printf ("example: %s msg_platform.xml msg_deployment.xml actions # if all actions are in the same file\n", argv[0]); printf ("example: %s msg_platform.xml msg_deployment.xml # if actions are in separate files, specified in deployment\n", argv[0]); exit(1); } printf("WARNING: THIS BINARY IS KINDA DEPRECATED\n" "This example is still relevant if you want to learn about MSG-based trace replay, " "but if you want to simulate MPI-like traces, you should use the newer version " "that is in the examples/smpi/replay directory instead.\n"); /* Simulation setting */ MSG_create_environment(argv[1]); /* No need to register functions as in classical MSG programs: the actions get started anyway */ MSG_launch_application(argv[2]); /* Action registration */ xbt_replay_action_register("init", action_init); xbt_replay_action_register("finalize", action_finalize); xbt_replay_action_register("comm_size", action_comm_size); xbt_replay_action_register("send", action_send); xbt_replay_action_register("Isend", action_Isend); xbt_replay_action_register("recv", action_recv); xbt_replay_action_register("Irecv", action_Irecv); xbt_replay_action_register("wait", action_wait); xbt_replay_action_register("barrier", action_barrier); xbt_replay_action_register("bcast", action_bcast); xbt_replay_action_register("reduce", action_reduce); xbt_replay_action_register("allReduce", action_allReduce); xbt_replay_action_register("sleep", action_sleep); xbt_replay_action_register("compute", action_compute); /* Actually do the simulation using MSG_action_trace_run */ res = MSG_action_trace_run(argv[3]); // it's ok to pass a NULL argument here XBT_INFO("Simulation time %g", MSG_get_clock()); /* Explicit finalization of the action module is required now*/ MSG_action_exit(); if (res == MSG_OK) return 0; else return 1; } /* end_of_main */
/** * \brief Main function. */ int main(int argc, char *argv[]) { #ifdef BENCH_THIS_CODE xbt_os_cputimer_t timer = xbt_os_timer_new(); #endif MSG_init(&argc, argv); char **options = &argv[1]; const char* platform_file = options[0]; const char* application_file = options[1]; MSG_create_environment(platform_file); MSG_function_register("node", node); MSG_launch_application(application_file); #ifdef BENCH_THIS_CODE xbt_os_cputimer_start(timer); #endif msg_error_t res = MSG_main(); #ifdef BENCH_THIS_CODE xbt_os_cputimer_stop(timer); #endif XBT_CRITICAL("Simulated time: %g", MSG_get_clock()); if (res == MSG_OK) return 0; else return 1; }
int main(int argc, char **argv) { int i,res; MSG_init(&argc, argv); MSG_create_environment(argv[1]); xbt_dynar_t hosts = MSG_hosts_as_dynar(); MSG_function_register("host", host); unsigned long nb_hosts = xbt_dynar_length(hosts); XBT_INFO("Number of host '%lu'",nb_hosts); for(i = 0 ; i<nb_hosts; i++) { char* name_host = bprintf("%d",i); MSG_process_create( name_host, host, NULL, xbt_dynar_get_as(hosts,i,msg_host_t) ); free(name_host); } xbt_dynar_free(&hosts); res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); if (res == MSG_OK) return 0; else return 1; }
int main(int argc, char *argv[]) { MSG_init(&argc, argv); if (argc != 3) { printf("Usage: %s platform_file deployment_file\n", argv[0]); printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); exit(1); } const char *platform_file = argv[1]; const char *application_file = argv[2]; MSG_create_environment(platform_file); MSG_function_register("receiver", receiver); MSG_function_register("sender", sender); MSG_launch_application(application_file); #ifndef DISABLE_THE_MUTEX mutex = xbt_mutex_init(); #endif msg_error_t res = MSG_main(); #ifndef DISABLE_THE_MUTEX xbt_mutex_destroy(mutex); mutex = NULL; #endif XBT_INFO("Simulation time %g", MSG_get_clock()); if (res == MSG_OK) return 0; else return 1; }
/** Main function */ int main(int argc, char *argv[]) { msg_error_t res; const char *platform_file; const char *application_file; MSG_init(&argc, argv); if (argc != 3) { printf("Usage: %s platform_file deployment_file\n", argv[0]); printf("example: %s msg_platform.xml msg_deployment.xml\n", argv[0]); exit(1); } platform_file = argv[1]; application_file = argv[2]; { /* Simulation setting */ MSG_create_environment(platform_file); } { /* Application deployment */ MSG_function_register("master", master); MSG_function_register("slave", slave); MSG_launch_application(application_file); } res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); if (res == MSG_OK) return 0; else return 1; } /* end_of_main */
/** Main function */ int main(int argc, char *argv[]) { MSG_init(&argc, argv); MSG_function_register("app", &app); MSG_create_environment(argv[1]); MSG_process_create("app", app, NULL, MSG_get_host_by_name("Tremblay")); return MSG_main(); }
/** Main function */ int main(int argc, char *argv[]) { MSG_init(&argc, argv); MSG_function_register("app", &app); MSG_create_environment(argv[1]); MSG_launch_application(argv[2]); return MSG_main(); }
/** This function starts and ends simulation workflow. `main` accepts following arguments: @--cfg=tracing:yes enables tracing functionality of simgrid @--cfg=tracing/platform:yes enables platform tracing functionality of simgrid @--cfg=tracing/filename:<path to trace file> defines path to file simgrid writes to @--cfg=maxmin/concurrency_limit:100000 maximum number of simultaneously running processes in simulation @--cfg=storage/max_file_descriptors:220000" maximum number of simultaneously open (and not closed) file descriptors */ int main(int argc, char *argv[]){ YAML::Node config = YAML::LoadFile("config.yml"); const std::string model = config["model"].as<std::string>(); const std::string platform = config["platform"].as<std::string>(); const std::string deployment = config["deployment"].as<std::string>(); path_to_output = config["out.txt"].as<std::string>(); jobs_file = config["jobs"].as<std::string>(); input_files_file = config["input"].as<std::string>(); auto t1 = std::chrono::high_resolution_clock::now(); MSG_init(&argc, argv); MSG_create_environment(platform.c_str()); declare_trace_variables(); sem_requester = MSG_sem_init(1); MSG_function_register("evil", evil); MSG_function_register("scheduler", scheduler); MSG_function_register("tier1", tier1); MSG_function_register("killer", killer); MSG_function_register("tracer", tracer); MSG_function_register("initialize", initialize_file_labels); MSG_function_register("delete_unpop_file", delete_unpopular_file); MSG_launch_application(deployment.c_str()); current_model = (char*) model.c_str(); msg_error_t res = MSG_main(); XBT_INFO("Simulation time %f", MSG_get_clock()); fclose(FP); MSG_sem_destroy(sem_requester); MSG_sem_destroy(sem_link); // Clear info of name node /*std::map<string, FileData*>::iterator file_itr = name_node->begin(); while (file_itr != name_node->end()){ delete (*file_itr).second; name_node->erase(file_itr); file_itr++; }*/ // delete global_queue and name_node delete GLOBAL_QUEUE; //delete name_node; auto t2 = std::chrono::high_resolution_clock::now(); XBT_INFO("Real time of simulation: %ld seconds", std::chrono::duration_cast<std::chrono::seconds>(t2-t1).count()); return res != MSG_OK; }
/** * 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); }
int main (int argc, char* argv[]) { /* MRA_user_init must be called before setting the user functions. */ MRA_user_init (); /* MRSG_user_init must be called before setting the user functions. */ MRSG_user_init (); /* Set the task cost MRA function. */ MRA_set_task_mra_cost_f (mra_task_cost_function); /* Set the task cost MRSG function. */ MRSG_set_task_cost_f (mrsg_task_cost_function); /* Set the MRA_map output function. */ MRA_set_map_mra_output_f (mra_map_output_function); /* Set the MRSG_map output function. */ MRSG_set_map_output_f (mrsg_map_output_function); /* Run the MRSG simulation. */ //BIGHYBRID_main ("plat350-350.xml","d-plat350-350.xml","bighyb-plat350-350.conf","parser-boinc-080.txt"); /* Check the args given in the command line: < 5 : invalid (something is missing) = 5 : no simgrid arg > 5 : simgrid arg */ if(argc < 5) { printf("usage : %s plat.xml depoly.xml plat.conf machines-trace.txt",argv[0]); exit(0); }else if (argc == 5){ int sg_argc = argc -4; MSG_init (&sg_argc, argv); printf("\n%s %s %s %s",argv[argc-4],argv[argc-3],argv[argc-2],argv[argc-1]); BIGHYBRID_main (argv[argc-4],argv[argc-3],argv[argc-2],argv[argc-1]); }else{ int sg_argc = argc -4; // printf("WITH SIMGRID %s\n%s %s %s %s\n",argv[1],argv[sg_argc],argv[sg_argc+1], argv[sg_argc+2],argv[sg_argc+3]); MSG_init (&sg_argc, argv); // BIGHYBRID_main (argv[sg_argc+1],argv[sg_argc+2], argv[sg_argc+3],argv[sg_argc+4]); BIGHYBRID_main (argv[sg_argc],argv[sg_argc+1], argv[sg_argc+2],argv[sg_argc+3]); } return 0; }
int main(int argc, char *argv[]) { MSG_init(&argc, argv); xbt_assert(argc==2); MSG_create_environment(argv[1]); MSG_process_create("test", server, NULL, MSG_host_by_name("Tremblay")); MSG_main(); return 0; }
int main(int argc, char *argv[]) { MSG_init(&argc, argv); MSG_create_environment("../msg_platform.xml"); MSG_function_register("coordinator", coordinator); MSG_function_register("client", client); MSG_launch_application("deploy_mutex.xml"); MSG_main(); return 0; }
int main(int argc, char *argv[]) { 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]); MSG_process_create("simple_func", process_function, NULL, MSG_get_host_by_name("Tremblay")); MSG_process_create("simple_func", process_function, NULL, MSG_get_host_by_name("Fafard")); MSG_main(); return 0; }
int main(int argc, char *argv[]) { MSG_init(&argc, argv); if (argc < 2) { printf("Usage: %s platform_file\n", argv[0]); exit(1); } MSG_create_environment(argv[1]); MSG_main(); return 0; }
/** Main function */ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; MSG_init(&argc, argv); res = test_all(argv[1]); if (res == MSG_OK) return 0; else return 1; } /* end_of_main */
/** Main function */ int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; long i; MSG_init(&argc, argv); if (argc < 4) { printf("Usage: %s platform_file number_of_jobs number_of_slaves\n", argv[0]); printf("example: %s msg_platform.xml 10 5\n", argv[0]); exit(1); } MSG_function_register("master", master); MSG_function_register("slave", slave); MSG_create_environment(argv[1]); number_of_jobs = atol(argv[2]); number_of_slaves = atol(argv[3]); xbt_dynar_t host_dynar = MSG_hosts_as_dynar(); long number_max = xbt_dynar_length(host_dynar); XBT_INFO("Got %ld slaves, %ld tasks to process, and %ld hosts", number_of_slaves, number_of_jobs,number_max); msg_host_t *host_table = xbt_dynar_to_array(host_dynar); //xbt_dynar_free(&host_dynar); MSG_process_create( "master", master, NULL, host_table[my_random(number_max)] ); for(i = 0 ; i<number_of_slaves; i++) { char* name_host = bprintf("slave-%ld",i); MSG_process_create( name_host, slave, NULL, host_table[my_random(number_max)] ); free(name_host); } xbt_free(host_table); res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); if (res == MSG_OK) return 0; else return 1; } /* end_of_main */
int main(int argc, char *argv[]) { MSG_init(&argc, argv); MSG_create_environment("platform.xml"); MSG_function_register("server", server); MSG_function_register("client", client); MSG_launch_application("deploy_bugged1.xml"); MSG_main(); return 0; }
int main(int argc, char *argv[]){ MSG_init(&argc, argv); xbt_assert(argc == 2); MSG_create_environment(argv[1]); launch_master(MSG_host_by_name("Fafard")); int res = MSG_main(); XBT_INFO("Bye (simulation time %g)", MSG_get_clock()); return !(res == MSG_OK); }