Example #1
0
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;
}
Example #2
0
/** @ingroup plugin_loadbalancer
 * @brief Initializes the load balancer plugin
 * @details The load balancer plugin supports several AMPI load balancers that move ranks
 * around, based on their host's load.
 */
void sg_load_balancer_plugin_init()
{
  static bool done = false;
  if (!done) {
    done = true;
    simgrid::kernel::activity::ExecImpl::on_completion.connect([](simgrid::kernel::activity::ExecImpl const& activity) {
      simgrid::smpi::plugin::lb.record_actor_computation(activity.simcalls_.front()->issuer->iface(),
                                                         activity.surf_action_->get_cost());
    });

    xbt_replay_action_register(
        "migrate", [](simgrid::xbt::ReplayAction& action) { simgrid::smpi::plugin::MigrateAction().execute(action); });
    xbt_replay_action_register("iteration_in", simgrid::smpi::plugin::action_iteration_in);
    xbt_replay_action_register("iteration_out", simgrid::smpi::plugin::action_iteration_out);
  }
}
Example #3
0
int main(int argc, char* argv[])
{
  simgrid::s4u::Engine e(&argc, argv);

  xbt_assert(argc > 2, "Usage: %s platform_file deployment_file [action_files]\n"
                       "\t# if all actions are in the same file\n"
                       "\tExample: %s msg_platform.xml msg_deployment.xml actions\n"
                       "\t# if actions are in separate files, specified in deployment\n"
                       "\tExample: %s msg_platform.xml msg_deployment.xml ",
             argv[0], argv[0], argv[0]);

  e.load_platform(argv[1]);
  e.register_actor<Replayer>("p0");
  e.register_actor<Replayer>("p1");
  e.load_deployment(argv[2]);

  /*   Action registration */
  xbt_replay_action_register("compute", Replayer::compute);
  xbt_replay_action_register("send", Replayer::send);
  xbt_replay_action_register("recv", Replayer::recv);

  if (argv[3]) {
    simgrid::xbt::action_fs = new std::ifstream(argv[3], std::ifstream::in);
  }

  e.run();

  if (argv[3]) {
    delete simgrid::xbt::action_fs;
    simgrid::xbt::action_fs = nullptr;
  }

  XBT_INFO("Simulation time %g", e.get_clock());

  return 0;
}
Example #4
0
/** 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 */
Example #5
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;
}
Example #6
0
void smpi_replay_init(int *argc, char***argv){
  PMPI_Init(argc, argv);
  if (!smpi_process_index()){
    _xbt_replay_action_init();
    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("compute",  action_compute);
  }

  xbt_replay_action_runner(*argc, *argv);
}