当前位置: 首页>>代码示例>>C++>>正文


C++ MSG_create_environment函数代码示例

本文整理汇总了C++中MSG_create_environment函数的典型用法代码示例。如果您正苦于以下问题:C++ MSG_create_environment函数的具体用法?C++ MSG_create_environment怎么用?C++ MSG_create_environment使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了MSG_create_environment函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: test_all

/** 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;
}
开发者ID:rosacris,项目名称:simgrid,代码行数:27,代码来源:categories.c

示例2: main

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;

}
开发者ID:Julio-Anjos,项目名称:simgrid,代码行数:25,代码来源:file.c

示例3: main

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;

}
开发者ID:tempbottle,项目名称:simgrid,代码行数:32,代码来源:token_bypass.c

示例4: main

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;
}
开发者ID:apargupta,项目名称:simgrid,代码行数:29,代码来源:mutex_handling.c

示例5: main

/** 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);
  }
开发者ID:FlorianPO,项目名称:simgrid,代码行数:35,代码来源:user_variables.c

示例6: main

/**
 * 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);
  }
开发者ID:dhascome,项目名称:simgrid,代码行数:30,代码来源:bittorrent.c

示例7: main

/** 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 */
开发者ID:apargupta,项目名称:simgrid,代码行数:34,代码来源:process_join.c

示例8: main

/** 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 */
开发者ID:ricardojrdez,项目名称:simgrid,代码行数:35,代码来源:migration.c

示例9: 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;
}
开发者ID:apargupta,项目名称:simgrid,代码行数:34,代码来源:msg_pmm.c

示例10: main

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;
}
开发者ID:R7R8,项目名称:simgrid,代码行数:31,代码来源:chainsend.c

示例11: 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;
}
开发者ID:fabienchaix,项目名称:simgrid,代码行数:31,代码来源:maestro-set.cpp

示例12: create_environment

/**
 * \brief Creates the platform.
 * \param L a Lua state
 * \return number of values returned to Lua
 *
 * - Argument 1 (string): name of the platform file to load
 */
static int create_environment(lua_State* L) {

  const char* file = luaL_checkstring(L, 1);
  XBT_DEBUG("Loading environment file %s", file);
  MSG_create_environment(file);
  return 0;
}
开发者ID:dhascome,项目名称:simgrid,代码行数:14,代码来源:simgrid_lua.c

示例13: main

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;
}
开发者ID:Julio-Anjos,项目名称:simgrid,代码行数:31,代码来源:e3.c

示例14: 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 */
开发者ID:tempbottle,项目名称:simgrid,代码行数:61,代码来源:actions.c

示例15: main

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);
  }
开发者ID:dindon-sournois,项目名称:simgrid,代码行数:30,代码来源:trace-host-user-variables.c


注:本文中的MSG_create_environment函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。