Ejemplo n.º 1
0
/** @brief shows an exception content and the associated stack if available */
void xbt_ex_display(xbt_ex_t * e)
{
  char *thrower = NULL;
  if (e->pid != xbt_getpid())
    thrower = bprintf(" on process %d",e->pid);

  fprintf(stderr,
          "** SimGrid: UNCAUGHT EXCEPTION received on %s(%d): category: %s; value: %d\n"
          "** %s\n"
          "** Thrown by %s()%s\n",
          xbt_binary_name, xbt_getpid(),
          xbt_ex_catname(e->category), e->value, e->msg,
          e->procname, thrower ? thrower : " in this process");
  XBT_CRITICAL("%s", e->msg);
  xbt_free(thrower);

  if (xbt_initialized==0 || smx_cleaned) {
    fprintf(stderr, "Ouch. SimGrid is not initialized yet, or already closing. No backtrace available.\n");
    return; /* Not started yet or already closing. Trying to generate a backtrace would probably fail */
  }

  if (!e->bt_strings)
    xbt_ex_setup_backtrace(e);

#ifdef HAVE_BACKTRACE
  if (e->used && e->bt_strings) {
    /* We have everything to build neat backtraces */
    int i;
    int cutpath = 0;
    TRY { // We don't want to have an exception while checking how to deal with the one we already have, do we?
      cutpath = sg_cfg_get_boolean("exception/cutpath");
    } CATCH_ANONYMOUS { }

    fprintf(stderr, "\n");
    for (i = 0; i < e->used; i++) {
        
      if (cutpath) {
        char* p = e->bt_strings[i];
        xbt_str_rtrim(p, ":0123456789");
        char* filename = strrchr(p, '/')+1;
        char* end_of_message  = strrchr(p, ' ');

        int length = strlen(p)-strlen(end_of_message);
        char* dest = malloc(length);

        memcpy(dest, &p[0], length);
        dest[length] = 0;

        fprintf(stderr, "%s %s\n", dest, filename);

        free(dest);
      }
      else {
        fprintf(stderr, "%s\n", e->bt_strings[i]);
      }
    }

  } else
Ejemplo n.º 2
0
/** @brief shows an exception content and the associated stack if available */
void xbt_ex_display(xbt_ex_t * e)
{
  char *thrower = NULL;
  if (e->pid != xbt_getpid())
    thrower = bprintf(" on process %d",e->pid);

  fprintf(stderr,
          "** SimGrid: UNCAUGHT EXCEPTION received on %s(%d): category: %s; value: %d\n"
          "** %s\n"
          "** Thrown by %s()%s\n",
          xbt_binary_name, xbt_getpid(),
          xbt_ex_catname(e->category), e->value, e->msg,
          e->procname, thrower ? thrower : " in this process");
  XBT_CRITICAL("%s", e->msg);
  xbt_free(thrower);

  if (!e->bt_strings)
    xbt_ex_setup_backtrace(e);

#ifdef HAVE_BACKTRACE
  if (e->used && e->bt_strings) {
    /* We have everything to build neat backtraces */
    int i;

    fprintf(stderr, "\n");
    for (i = 0; i < e->used; i++) {
      if (sg_cfg_get_boolean("exception/cutpath")) {
        char* p = e->bt_strings[i];
        xbt_str_rtrim(p, ":0123456789");
        char* filename = strrchr(p, '/')+1;
        char* end_of_message  = strrchr(p, ' ');

        int length = strlen(p)-strlen(end_of_message);
        char* dest = malloc(length);

        memcpy(dest, &p[0], length);
        dest[length] = 0;

        fprintf(stderr, "%s %s\n", dest, filename);

        free(dest);
      }
      else {
        fprintf(stderr, "%s\n", e->bt_strings[i]);
      }
    }

  } else
#endif
  {
    fprintf(stderr,
            "\n"
            "**   In %s() at %s:%d\n"
            "**   (no backtrace available)\n",
            e->func, e->file, e->line);
  }
}
Ejemplo n.º 3
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);
}
Ejemplo n.º 4
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 (sg_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.");
    }
  }

  smpi_global_destroy();

  TRACE_end();

  return 0;
}
Ejemplo n.º 5
0
static void smpi_init_options(){
  int gather_id = find_coll_description(mpi_coll_gather_description,
                                          sg_cfg_get_string("smpi/gather"),"gather");
    mpi_coll_gather_fun = (int (*)(void *, int, MPI_Datatype,
                                   void *, int, MPI_Datatype, int, MPI_Comm))
        mpi_coll_gather_description[gather_id].coll;

    int allgather_id = find_coll_description(mpi_coll_allgather_description,
                                             sg_cfg_get_string("smpi/allgather"),"allgather");
    mpi_coll_allgather_fun = (int (*)(void *, int, MPI_Datatype,
                                      void *, int, MPI_Datatype, MPI_Comm))
        mpi_coll_allgather_description[allgather_id].coll;

    int allgatherv_id = find_coll_description(mpi_coll_allgatherv_description,
                                              sg_cfg_get_string("smpi/allgatherv"),"allgatherv");
    mpi_coll_allgatherv_fun = (int (*)(void *, int, MPI_Datatype, void *, int *,
                                       int *, MPI_Datatype, MPI_Comm))
        mpi_coll_allgatherv_description[allgatherv_id].coll;

    int allreduce_id = find_coll_description(mpi_coll_allreduce_description,
                                             sg_cfg_get_string("smpi/allreduce"),"allreduce");
    mpi_coll_allreduce_fun = (int (*)(void *sbuf, void *rbuf, int rcount,
                                      MPI_Datatype dtype, MPI_Op op,
                                      MPI_Comm comm))
        mpi_coll_allreduce_description[allreduce_id].coll;

    int alltoall_id = find_coll_description(mpi_coll_alltoall_description,
                                            sg_cfg_get_string("smpi/alltoall"),"alltoall");
    mpi_coll_alltoall_fun = (int (*)(void *, int, MPI_Datatype,
                                     void *, int, MPI_Datatype, MPI_Comm))
        mpi_coll_alltoall_description[alltoall_id].coll;

    int alltoallv_id = find_coll_description(mpi_coll_alltoallv_description,
                                             sg_cfg_get_string("smpi/alltoallv"),"alltoallv");
    mpi_coll_alltoallv_fun = (int (*)(void *, int *, int *, MPI_Datatype,
                                      void *, int *, int *, MPI_Datatype,
                                      MPI_Comm))
        mpi_coll_alltoallv_description[alltoallv_id].coll;

    int bcast_id = find_coll_description(mpi_coll_bcast_description,
                                         sg_cfg_get_string("smpi/bcast"),"bcast");
    mpi_coll_bcast_fun = (int (*)(void *buf, int count, MPI_Datatype datatype,
                                  int root, MPI_Comm com))
        mpi_coll_bcast_description[bcast_id].coll;

    int reduce_id = find_coll_description(mpi_coll_reduce_description,
                                          sg_cfg_get_string("smpi/reduce"),"reduce");
    mpi_coll_reduce_fun = (int (*)(void *buf, void *rbuf, int count,
                                   MPI_Datatype datatype, MPI_Op op,
                                   int root, MPI_Comm comm))
        mpi_coll_reduce_description[reduce_id].coll;

    int reduce_scatter_id =
        find_coll_description(mpi_coll_reduce_scatter_description,
                              sg_cfg_get_string("smpi/reduce_scatter"),"reduce_scatter");
    mpi_coll_reduce_scatter_fun = (int (*)(void *sbuf, void *rbuf, int *rcounts,
                                           MPI_Datatype dtype, MPI_Op op,
                                           MPI_Comm comm))
        mpi_coll_reduce_scatter_description[reduce_scatter_id].coll;

    int scatter_id = find_coll_description(mpi_coll_scatter_description,
                                           sg_cfg_get_string("smpi/scatter"),"scatter");
    mpi_coll_scatter_fun = (int (*)(void *sendbuf, int sendcount,
                                    MPI_Datatype sendtype, void *recvbuf,
                                    int recvcount, MPI_Datatype recvtype,
                                    int root, MPI_Comm comm))
        mpi_coll_scatter_description[scatter_id].coll;

    int barrier_id = find_coll_description(mpi_coll_barrier_description,
                                           sg_cfg_get_string("smpi/barrier"),"barrier");
    mpi_coll_barrier_fun = (int (*)(MPI_Comm comm))
        mpi_coll_barrier_description[barrier_id].coll;

    smpi_cpu_threshold = sg_cfg_get_double("smpi/cpu_threshold");
    smpi_running_power = sg_cfg_get_double("smpi/running_power");
    smpi_privatize_global_variables = sg_cfg_get_boolean("smpi/privatize_global_variables");
    if (smpi_cpu_threshold < 0)
      smpi_cpu_threshold = DBL_MAX;

}