Example #1
0
int main(int argc, char** argv)
{
  int status = 0;
  SIMIX_global_init(&argc, argv);

  XBT_INFO("Basic testing posix");
  status += test_parmap_basic(XBT_PARMAP_POSIX);
  XBT_INFO("Basic testing futex");
#ifdef HAVE_FUTEX_H
  status += test_parmap_basic(XBT_PARMAP_FUTEX);
#endif
  XBT_INFO("Basic testing busy wait");
  status += test_parmap_basic(XBT_PARMAP_BUSY_WAIT);

  XBT_INFO("Extended testing posix");
  status += test_parmap_extended(XBT_PARMAP_POSIX);
  XBT_INFO("Extended testing futex");
#ifdef HAVE_FUTEX_H
  status += test_parmap_extended(XBT_PARMAP_FUTEX);
#endif
  XBT_INFO("Extended testing busy wait");
  status += test_parmap_extended(XBT_PARMAP_BUSY_WAIT);

  return status == 0 ? EXIT_SUCCESS : EXIT_FAILURE;
}
Example #2
0
Engine::Engine(int* argc, char** argv) : pimpl(new kernel::EngineImpl())
{
  xbt_assert(Engine::instance_ == nullptr, "It is currently forbidden to create more than one instance of s4u::Engine");
  TRACE_global_init();
  SIMIX_global_init(argc, argv);

  Engine::instance_ = this;
}
Example #3
0
int main(int argc, char* argv[])
{
  SIMIX_global_init(&argc, argv);
  xbt_assert(argc == 2, "Usage: %s platform.xml\n", argv[0]);
  simgrid_load_platform(argv[1]);
  simcall_process_create("master", example::master, NULL, sg_host_by_name("Tremblay"), NULL);
  SIMIX_run();
  return 0;
}
Example #4
0
int main(int argc, char** argv)
{
  SIMIX_global_init(&argc, argv);

  simgrid::mc::Variable* var;
  simgrid::mc::Type* type;

  simgrid::mc::Process process(getpid(), -1);
  process.init();

  test_global_variable(process, process.binary_info.get(),
    "some_local_variable", &some_local_variable, sizeof(int));

  var = test_global_variable(process, process.binary_info.get(),
    "test_some_array", &test_some_array, sizeof(test_some_array));
  auto i = process.binary_info->types.find(var->type_id);
  xbt_assert(i != process.binary_info->types.end(), "Missing type");
  type = &i->second;
  xbt_assert(type->element_count == 6*5*4,
    "element_count mismatch in test_some_array : %i / %i",
    type->element_count, 6*5*4);

  var = test_global_variable(process, process.binary_info.get(),
    "test_some_struct", &test_some_struct, sizeof(test_some_struct));
  i = process.binary_info->types.find(var->type_id);
  xbt_assert(i != process.binary_info->types.end(), "Missing type");
  type = &i->second;

  assert(type);
  assert(find_member(*type, "first")->offset() == 0);
  assert(find_member(*type, "second")->offset()
      == ((const char*)&test_some_struct.second) - (const char*)&test_some_struct);

  unw_context_t context;
  unw_cursor_t cursor;
  unw_getcontext(&context);
  unw_init_local(&cursor, &context);

  test_local_variable(process.binary_info.get(), "main", "argc", &argc, &cursor);

  {
    int lexical_block_variable = 50;
    test_local_variable(process.binary_info.get(), "main",
      "lexical_block_variable", &lexical_block_variable, &cursor);
  }

  s_foo my_foo;
  test_type_by_name(process, my_foo);

  _exit(0);
}
Example #5
0
int main(int argc, char *argv[])
{
  int nthreads;
  unsigned modes = MODES_DEFAULT;

  SIMIX_global_init(&argc, argv);

  if (argc != 2 && argc != 3) {
    fprintf(stderr,
            "Usage: %s nthreads [modes]\n"
            "    nthreads - number of working threads\n"
            "    modes    - bitmask of modes to test\n",
            argv[0]);
    return EXIT_FAILURE;
  }
  nthreads = atoi(argv[1]);
  if (nthreads < 1) {
    fprintf(stderr, "ERROR: invalid thread count: %d\n", nthreads);
    return EXIT_FAILURE;
  }
  if (argc == 3)
    modes = strtol(argv[2], NULL, 0);

  printf("Parmap benchmark with %d workers (modes = %#x)...\n\n",
         nthreads, modes);

  fun_to_apply = fun_small_comp;

  printf("Benchmark for parmap create+apply+destroy (small comp):\n");
  bench_all_modes(bench_parmap_full, nthreads, modes);
  printf("\n");

  printf("Benchmark for parmap apply only (small comp):\n");
  bench_all_modes(bench_parmap_apply, nthreads, modes);
  printf("\n");

  fun_to_apply = fun_big_comp;

  printf("Benchmark for parmap create+apply+destroy (big comp):\n");
  bench_all_modes(bench_parmap_full, nthreads, modes);
  printf("\n");

  printf("Benchmark for parmap apply only (big comp):\n");
  bench_all_modes(bench_parmap_apply, nthreads, modes);
  printf("\n");

  return EXIT_SUCCESS;
}
Example #6
0
int main(int argc, char *argv[])
{
    SIMIX_global_init(&argc, argv);

    if (argc != 2) {
        printf("Usage: %s platform_and_deployment.xml\n", argv[0]);
        exit(EXIT_FAILURE);
    }

    SIMIX_function_register("master", master);
    SIMIX_create_environment(argv[1]);
    SIMIX_launch_application(argv[1]);
    SIMIX_run();

    return 0;
}
Example #7
0
/**
 * \ingroup msg_simulation
 * \brief Initialize MSG with less verifications
 * You should use the MSG_init() function instead. Failing to do so may turn into PEBKAC some day. You've been warned.
 */
void MSG_init_nocheck(int *argc, char **argv) {

  TRACE_global_init(argc, argv);

  xbt_getpid = MSG_process_self_PID;
  if (!msg_global) {

    msg_global = xbt_new0(s_MSG_Global_t, 1);

    xbt_cfg_register_boolean("msg/debug-multiple-use", "no", _sg_cfg_cb_msg_debug_multiple_use,
        "Print backtraces of both processes when there is a conflict of multiple use of a task");

    SIMIX_global_init(argc, argv);

    msg_global->sent_msg = 0;
    msg_global->task_copy_callback = nullptr;
    msg_global->process_data_cleanup = nullptr;

    SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
    SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);

    simgrid::surf::on_postparse.connect(MSG_post_create_environment);
    simgrid::s4u::Host::onCreation.connect([](simgrid::s4u::Host& host) {
      MSG_host_create_(&host);
    });
    MSG_HOST_LEVEL = simgrid::s4u::Host::extension_create([](void *p) {
      __MSG_host_priv_free((msg_host_priv_t) p);
    });

  }

  if(MC_is_active()){
    /* Ignore total amount of messages sent during the simulation for heap comparison */
    MC_ignore_heap(&(msg_global->sent_msg), sizeof(msg_global->sent_msg));
  }

  XBT_DEBUG("ADD MSG LEVELS");
  MSG_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, (void_f_pvoid_t) __MSG_storage_destroy);
  MSG_FILE_LEVEL = xbt_lib_add_level(file_lib, (void_f_pvoid_t) __MSG_file_destroy);
  if(xbt_cfg_get_boolean("clean-atexit"))
    atexit(MSG_exit);
}
Example #8
0
/**
 * \ingroup msg_simulation
 * \brief Initialize MSG with less verifications
 * You should use the MSG_init() function instead. Failing to do so may turn into PEBKAC some day. You've been warned.
 */
void MSG_init_nocheck(int *argc, char **argv) {

#ifdef HAVE_TRACING
  TRACE_global_init(argc, argv);
#endif

  xbt_getpid = MSG_process_self_PID;
  if (!msg_global) {

    msg_global = xbt_new0(s_MSG_Global_t, 1);

    xbt_cfg_register(&_sg_cfg_set, "msg/debug_multiple_use",
                     "Print backtraces of both processes when there is a conflict of multiple use of a task",
                     xbt_cfgelm_boolean, 1, 1, _sg_cfg_cb_msg_debug_multiple_use, NULL);
    xbt_cfg_setdefault_boolean(_sg_cfg_set, "msg/debug_multiple_use", "no");

    SIMIX_global_init(argc, argv);

#ifdef MSG_USE_DEPRECATED
    msg_global->max_channel = 0;
#endif
    msg_global->sent_msg = 0;
    msg_global->task_copy_callback = NULL;
    msg_global->process_data_cleanup = NULL;

    SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
    SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);

    sg_platf_postparse_add_cb(MSG_post_create_environment);
  }

  if(MC_is_active()){
    /* Ignore total amount of messages sent during the simulation for heap comparison */
    MC_ignore_heap(&(msg_global->sent_msg), sizeof(msg_global->sent_msg));
  }

  XBT_DEBUG("ADD MSG LEVELS");
  MSG_HOST_LEVEL = xbt_lib_add_level(host_lib, (void_f_pvoid_t) __MSG_host_priv_free);
  MSG_STORAGE_LEVEL = xbt_lib_add_level(storage_lib, (void_f_pvoid_t) __MSG_storage_destroy);
  MSG_FILE_LEVEL = xbt_lib_add_level(file_lib, (void_f_pvoid_t) __MSG_file_destroy);
  if(sg_cfg_get_boolean("clean_atexit")) atexit(MSG_exit);
}
Example #9
0
/** \ingroup msg_simulation
 * \brief Initialize some MSG internal data.
 */
void MSG_global_init(int *argc, char **argv)
{
#ifdef HAVE_TRACING
  TRACE_global_init(argc, argv);
#endif

  xbt_getpid = MSG_process_self_PID;
  if (!msg_global) {
    /* Connect our log channels: that must be done manually under windows */
    XBT_LOG_CONNECT(msg_gos, msg);
    XBT_LOG_CONNECT(msg_kernel, msg);
    XBT_LOG_CONNECT(msg_mailbox, msg);
    XBT_LOG_CONNECT(msg_process, msg);

    SIMIX_global_init(argc, argv);

    msg_global = xbt_new0(s_MSG_Global_t, 1);

    msg_global->max_channel = 0;
    msg_global->PID = 1;
    msg_global->sent_msg = 0;

    /* initialization of the action module */
    _MSG_action_init();

    SIMIX_function_register_process_create(MSG_process_create_from_SIMIX);
    SIMIX_function_register_process_cleanup(MSG_process_cleanup_from_SIMIX);
    SIMIX_function_register_process_kill(MSG_process_kill_from_SIMIX);
  }
#ifdef HAVE_TRACING
  TRACE_start();
#endif

  XBT_DEBUG("ADD MSG LEVELS");
  MSG_HOST_LEVEL = xbt_lib_add_level(host_lib,free);
}
Example #10
0
int smpi_main(int (*realmain) (int argc, char *argv[]), int argc, char *argv[])
{
  srand(SMPI_RAND_SEED);

  if (getenv("SMPI_PRETEND_CC") != NULL) {
    /* Hack to ensure that smpicc can pretend to be a simple compiler. Particularly handy to pass it to the
     * configuration tools */
    return 0;
  }
  smpi_init_logs();

  TRACE_global_init(&argc, argv);
  TRACE_add_start_function(TRACE_smpi_alloc);
  TRACE_add_end_function(TRACE_smpi_release);

  SIMIX_global_init(&argc, argv);
  MSG_init(&argc,argv);

  SMPI_switch_data_segment = smpi_switch_data_segment;

  smpi_init_options();

  // parse the platform file: get the host list
  SIMIX_create_environment(argv[1]);
  SIMIX_comm_set_copy_data_callback(&smpi_comm_copy_buffer_callback);
  SIMIX_function_register_default(realmain);
  SIMIX_launch_application(argv[2]);

  smpi_global_init();

  smpi_check_options();

  if(smpi_privatize_global_variables)
    smpi_initialize_global_memory_segments();

  /* Clean IO before the run */
  fflush(stdout);
  fflush(stderr);

  if (MC_is_active()) {
    MC_run();
  } else {
  
    SIMIX_run();

    xbt_os_walltimer_stop(global_timer);
    if (xbt_cfg_get_boolean("smpi/display-timing")){
      double global_time = xbt_os_timer_elapsed(global_timer);
      XBT_INFO("Simulated time: %g seconds. \n\n"
          "The simulation took %g seconds (after parsing and platform setup)\n"
          "%g seconds were actual computation of the application",
          SIMIX_get_clock(), global_time , smpi_total_benched_time);
          
      if (smpi_total_benched_time/global_time>=0.75)
      XBT_INFO("More than 75%% of the time was spent inside the application code.\n"
      "You may want to use sampling functions or trace replay to reduce this.");
    }
  }
  int count = smpi_process_count();
  int i, ret=0;
  for (i = 0; i < count; i++) {
    if(process_data[i]->return_value!=0){
      ret=process_data[i]->return_value;//return first non 0 value
      break;
    }
  }
  smpi_global_destroy();

  TRACE_end();

  return ret;
}