/** * \brief Deploys your application. * \param L a Lua state * \return number of values returned to Lua * * - Argument 1 (string): name of the deployment file to load */ static int launch_application(lua_State* L) { const char* file = luaL_checkstring(L, 1); MSG_function_register_default(run_lua_code); MSG_launch_application(file); return 0; }
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; }
/** 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[]) { 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 */
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; }
/** * Register applicaiton for MSG */ static int msg_register_application(lua_State * L) { MSG_function_register_default(run_lua_code); //surf_parse = console_parse_application; MSG_launch_application(NULL); return 0; }
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; 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_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; }
MSG_error_t run(const char *platform_file,const char *application_file) { MSG_error_t res = MSG_OK; XBT_INFO("running simulation"); /* Simulation setting */ MSG_create_environment(platform_file); /* Application deployment */ MSG_function_register("service_cordel",service_cordel); MSG_function_register("service_chor",service_chor); MSG_function_register("service", service); MSG_function_register("broker",broker); MSG_function_register("service_controller",service_controller); MSG_function_register("broker_controller",broker_controller); MSG_function_register("service_chor_controller",service_chor_controller); MSG_function_register("service_cordel_controller",service_cordel_controller); MSG_launch_application(application_file); res = MSG_main(); return res; }/* end_of_test_all */
/** 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); }
/** 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 */
/** Test function */ MSG_error_t test_all(const char *platform_file, const char *application_file) { MSG_error_t res = MSG_OK; { /* Simulation setting */ MSG_set_channel_number(0); MSG_create_environment(platform_file); } { //declaring user categories with RGB colors TRACE_category_with_color ("compute", "1 0 0"); //red TRACE_category_with_color ("request", "0 1 0"); //green TRACE_category_with_color ("data", "0 0 1"); //blue TRACE_category_with_color ("finalize", "0 0 0");//black } { /* 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()); return res; }
/** * @param platform_file The path/name of the platform file. * @param deploy_file The path/name of the deploy file. * @param mra_config_file The path/name of the configuration file. * @param vc_file_name The volunteer computing configuration file. */ static msg_error_t run_mra_simulation (const char* platform_file, const char* deploy_file, const char* mra_config_file, const char* vc_file_name) { msg_error_t res_mra = MSG_OK; read_mra_config_file (mra_config_file); MSG_create_environment (platform_file); read_bandwidth (platform_file); init_mra_vc (vc_file_name); // for tracing purposes.. TRACE_category_with_color ("MRA_MAP", "1 0 0"); TRACE_category_with_color ("MRA_REDUCE", "0 0 1"); MSG_function_register ("master_mra", master_mra); MSG_function_register ("worker_mra", worker_mra); MSG_launch_application (deploy_file); init_mr_mra_config (mra_config_file); res_mra = MSG_main (); free_mra_global_mem (); return res_mra; }
/** * \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; }
/** 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(); }
JNIEXPORT void JNICALL Java_org_simgrid_msg_Msg_deployApplication(JNIEnv * env, jclass cls, jstring jdeploymentFile) { const char *deploymentFile = env->GetStringUTFChars(jdeploymentFile, 0); SIMIX_function_register_default(java_main); MSG_launch_application(deploymentFile); }
/** 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; }
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); 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[]) { /* Check the given arguments */ MSG_init(&argc, argv); /* Explicit initialization of the action module is required now*/ MSG_action_init(); // MSG_config("surf/precision","1e-9"); MSG_create_environment(argv[1]); /* Simulation setting */ msg_error_t res = MSG_OK; /* No need to register functions as in classical MSG programs: the actions get started anyway */ MSG_launch_application(argv[2]); char *wh=argv[4]; XBT_INFO("Your choose is %s",wh); xbt_replay_action_register("unlink", simsleep);//register the action xbt_replay_action_register("compute", simsleep);//register the action xbt_replay_action_register("access", simsleep); xbt_replay_action_register("stat", simsleep); xbt_replay_action_register("flush", simsleep); xbt_replay_action_register("readdir", simsleep); xbt_replay_action_register("getxattr", simsleep); xbt_replay_action_register("mkdir", simsleep); xbt_replay_action_register("symlink", simsleep); xbt_replay_action_register("readlink", simsleep); if(strcmp(wh,"action")==0) //decide which mode to run /* Action registration */ { xbt_replay_action_register("open", simopen); xbt_replay_action_register("release", simrelease); xbt_replay_action_register("read", simread); xbt_replay_action_register("creat", simcreat); xbt_replay_action_register("write", simwrite); } else if(strcmp(wh,"sleep")==0){ xbt_replay_action_register("open", simsleep); xbt_replay_action_register("release", simsleep); xbt_replay_action_register("read", simsleep); xbt_replay_action_register("creat", simsleep); xbt_replay_action_register("write", simsleep); } if(!opened_files) {opened_files = xbt_dict_new_homogeneous(NULL);} 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);} MSG_action_exit(); return !!MSG_OK; }
int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; MSG_init(&argc, argv); if (argc < 3) { XBT_CRITICAL("Usage: %s platform_file deployment_file\n", argv[0]); exit(1); } MSG_function_register("terrorist", terrorist); MSG_create_environment(argv[1]); MSG_launch_application(argv[2]); /* // Simplistic platform with only one host sg_platf_begin(); s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER; sg_platf_new_AS_begin(&AS); s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER; host.id = "host0"; sg_platf_new_host(&host); sg_platf_new_AS_end(); sg_platf_end(); // Add one process -- super heavy just to launch an application! SIMIX_init_application(); sg_platf_begin(); s_sg_platf_process_cbarg_t process = SG_PLATF_PROCESS_INITIALIZER; process.argc=1; process.argv = malloc(sizeof(char*)*2); process.argv[0] = "terrorist"; process.argv[1] = NULL; process.host = "host0"; process.function = "terrorist"; process.start_time = 0; sg_platf_new_process(&process); sg_platf_end(); */ // Launch the simulation res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); if (res == MSG_OK) return 0; else return 1; }
/** Test function */ msg_error_t test_all(const char *platform_file) { msg_error_t res = MSG_OK; MSG_create_environment(platform_file); MSG_function_register("master", master); MSG_function_register("slave", slave); surf_parse = bypass_deployment; MSG_launch_application(NULL); res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); return res; } /* end_of_test_all */
int main(int argc, char **argv){ MSG_init(&argc, argv); MSG_config("model-check/property","promela"); MSG_create_environment("snapshot_comparison_platform.xml"); MSG_function_register("test", test); MSG_launch_application("deploy_snapshot_comparison.xml"); MSG_main(); return 0; }
int main(int argc, char *argv[]) { MSG_init(&argc, argv); MC_automaton_new_propositional_symbol_pointer("cs", &cs); MSG_create_environment("../msg_platform.xml"); MSG_function_register("coordinator", coordinator); MSG_function_register("client", client); MSG_launch_application("deploy_bugged2_liveness.xml"); MSG_main(); return 0; }
int main(int argc, char *argv[]){ MSG_init(&argc, argv); MSG_create_environment(argv[1]); MSG_function_register("scheduler", scheduler); MSG_function_register("dispatcher", dispatcher); MSG_function_register("tier1", tier1); MSG_launch_application(argv[2]); msg_error_t res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); return res != MSG_OK; }
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]); /* - Load the platform description */ MSG_function_register("yielder", yielder); MSG_launch_application(argv[2]); /* - Deploy the sender and receiver processes */ msg_error_t res = MSG_main(); /* - Run the simulation */ return res != MSG_OK; }
int main(int argc, char *argv[]){ msg_error_t res; MSG_init(&argc, argv); xbt_assert(argc > 3, "Usage: %s description_file platform_file deployment_file\n" "\tExample: %s smpi_multiple_apps msg_platform.xml msg_deployment.xml\n", argv[0], argv[0]); /* Simulation setting */ MSG_create_environment(argv[2]); /* Application deployment: read the description file in order to identify instances to launch */ FILE* fp = fopen(argv[1], "r"); if (fp == NULL) xbt_die("Cannot open %s", argv[1]); char *line = NULL; size_t n = 0; int instance_size = 0; const char* instance_id = NULL; while (xbt_getline(&line, &n, fp) != -1 ){ xbt_dynar_t elems = xbt_str_split_quoted_in_place(line); if(xbt_dynar_length(elems)<3){ xbt_die ("Not enough elements in the line"); } const char** line_char= xbt_dynar_to_array(elems); instance_id = line_char[0]; instance_size = xbt_str_parse_int(line_char[2], "Invalid size: %s"); XBT_INFO("Initializing instance %s of size %d", instance_id, instance_size); SMPI_app_instance_register(instance_id, smpi_replay,instance_size); xbt_free(line_char); } fclose(fp); MSG_launch_application(argv[3]); SMPI_init(); res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); SMPI_finalize(); return res != MSG_OK; }
int main(int argc, char *argv[]) { MSG_init(&argc, argv); MSG_config("model-check/property","promela_bugged2_liveness"); MC_automaton_new_propositional_symbol("cs", &predCS); MSG_create_environment("../msg_platform.xml"); MSG_function_register("coordinator", coordinator); MSG_function_register("client", client); MSG_launch_application("deploy_bugged2_liveness.xml"); MSG_main(); return 0; }
int main(int argc, char *argv[]) { msg_error_t res = MSG_OK; 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_function_register("terrorist", terrorist); MSG_create_environment(argv[1]); MSG_launch_application(argv[2]); // Launch the simulation res = MSG_main(); XBT_INFO("Simulation time %g", MSG_get_clock()); return res != MSG_OK; }