/** 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; }
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; }