Beispiel #1
0
Storage *StorageN11Model::createStorage(const char* id, const char* type_id,
    const char* content_name, const char* content_type, xbt_dict_t properties, const char* attach)
{

  xbt_assert(!surf_storage_resource_priv(surf_storage_resource_by_name(id)),
      "Storage '%s' declared several times in the platform file", id);

  storage_type_t storage_type = (storage_type_t) xbt_lib_get_or_null(storage_type_lib, type_id,ROUTING_STORAGE_TYPE_LEVEL);

  double Bread  = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bread"),
      "property Bread, storage",type_id);
  double Bwrite = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bwrite"),
      "property Bwrite, storage",type_id);
  double Bconnection   = surf_parse_get_bandwidth((char*)xbt_dict_get(storage_type->model_properties, "Bconnection"),
      "property Bconnection, storage",type_id);

  Storage *storage = new StorageN11(this, id, properties, maxminSystem_,
      Bread, Bwrite, Bconnection, type_id, (char *)content_name,
      content_type, storage_type->size, (char *) attach);
  storageCreatedCallbacks(storage);
  xbt_lib_set(storage_lib, id, SURF_STORAGE_LEVEL, storage);

  XBT_DEBUG("SURF storage create resource\n\t\tid '%s'\n\t\ttype '%s'\n\t\tproperties '%p'\n\t\tBread '%f'\n",
      id, type_id, properties, Bread);

  p_storageList.push_back(storage);

  return storage;
}
Beispiel #2
0
void smpi_sample_3(int global, const char *file, int line)
{
  char *loc = sample_location(global, file, line);
  local_data_t *data;

  xbt_assert(samples, "Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
  data = xbt_dict_get(samples, loc);
  XBT_DEBUG("sample3 %s",loc);

  if (data->benching==0) {
    THROW_IMPOSSIBLE;
  }

  // ok, benchmarking this loop is over
  xbt_os_timer_stop(smpi_process_timer());

  // update the stats
  double sample, n;
  data->count++;
  sample = xbt_os_timer_elapsed(smpi_process_timer());
  data->sum += sample;
  data->sum_pow2 += sample * sample;
  n = (double)data->count;
  data->mean = data->sum / n;
  data->relstderr = sqrt((data->sum_pow2 / n - data->mean * data->mean) / n) / data->mean;
  if (!sample_enough_benchs(data)) {
    data->mean = sample; // Still in benching process; We want sample_2 to simulate the exact time of this loop occurrence before leaving, not the mean over the history
  }
  XBT_DEBUG("Average mean after %d steps is %f, relative standard error is %f (sample was %f)", data->count,
      data->mean, data->relstderr, sample);

  // That's enough for now, prevent sample_2 to run the same code over and over
  data->benching = 0;
}
Beispiel #3
0
int smpi_sample_2(int global, const char *file, int line)
{
  char *loc = sample_location(global, file, line);
  local_data_t *data;

  xbt_assert(samples, "Y U NO use SMPI_SAMPLE_* macros? Stop messing directly with smpi_sample_* functions!");
  data = xbt_dict_get(samples, loc);
  XBT_DEBUG("sample2 %s",loc);
  free(loc);

  if (data->benching==1) {
    // we need to run a new bench
    XBT_DEBUG("benchmarking: count:%d iter:%d stderr:%f thres:%f; mean:%f",
        data->count, data->iters, data->relstderr, data->threshold, data->mean);
    smpi_bench_begin();
    return 1;
  } else {
    // Enough data, no more bench (either we got enough data from previous visits to this benched nest, or we just ran one bench and need to bail out now that our job is done).
    // Just sleep instead
    XBT_DEBUG("No benchmark (either no need, or just ran one): count >= iter (%d >= %d) or stderr<thres (%f<=%f). apply the %fs delay instead",
        data->count, data->iters, data->relstderr, data->threshold, data->mean);
    smpi_execute(data->mean);

    smpi_bench_begin(); // prepare to capture future, unrelated computations
    return 0;
  }
}
static xbt_dynar_t get_reqq_self()
{
   char * key = bprintf("%d", smpi_process_index());
   xbt_dynar_t dynar_mpi_request = static_cast<xbt_dynar_t>(xbt_dict_get(reqq, key));
   xbt_free(key);
 
   return dynar_mpi_request;
}
Beispiel #5
0
static xbt_dynar_t get_reqq_self(){
   char * key;
   
   int size = asprintf(&key, "%d", smpi_process_index());
   if(size==-1)
     xbt_die("could not allocate memory for asprintf");
   xbt_dynar_t dynar_mpi_request = (xbt_dynar_t) xbt_dict_get(reqq, key);
   free(key);
 
   return dynar_mpi_request;
}
Beispiel #6
0
void* smpi_shared_get_call(const char* func, const char* input) {
   char* loc = bprintf("%s:%s", func, input);
   void* data;

   if(!calls) {
      calls = xbt_dict_new_homogeneous(NULL);
   }
   data = xbt_dict_get(calls, loc);
   free(loc);
   return data;
}
Beispiel #7
0
static void recursiveGraphExtraction (simgrid::surf::As *rc, container_t container, xbt_dict_t filter)
{
  if (!TRACE_platform_topology()){
    XBT_DEBUG("Graph extraction disabled by user.");
    return;
  }
  XBT_DEBUG ("Graph extraction for routing_component = %s", rc->name_);
  if (!xbt_dict_is_empty(rc->children_)){
    xbt_dict_cursor_t cursor = NULL;
    AS_t rc_son;
    char *child_name;
    //bottom-up recursion
    xbt_dict_foreach(surf_AS_get_children(rc), cursor, child_name, rc_son) {
      container_t child_container = (container_t) xbt_dict_get (
        container->children, surf_AS_get_name(rc_son));
      recursiveGraphExtraction (rc_son, child_container, filter);
    }
Beispiel #8
0
int smpi_shared_known_call(const char* func, const char* input) {
   char* loc = bprintf("%s:%s", func, input);
   xbt_ex_t ex;
   int known;

   if(!calls) {
      calls = xbt_dict_new_homogeneous(NULL);
   }
   TRY {
      xbt_dict_get(calls, loc); /* Succeed or throw */
      known = 1;
   }
   CATCH(ex) {
      if(ex.category == not_found_error) {
         known = 0;
         xbt_ex_free(ex);
      } else {
         RETHROW;
      }
   }
   free(loc);
   return known;
}
Beispiel #9
0
/**
 * \ingroup XBT_replay
 * \brief function used internally to actually run the replay

 * \param argc argc .
 * \param argv argv
 */
int xbt_replay_action_runner(int argc, char *argv[])
{
  int i;
  xbt_ex_t e;
  if (xbt_action_fp) {              // A unique trace file
    char **evt;
    while ((evt = action_get_action(argv[0]))) {
      char* lowername = str_tolower (evt[1]);
      action_fun function =
        (action_fun)xbt_dict_get(xbt_action_funs, lowername);
      xbt_free(lowername);
      TRY{
        function((const char **)evt);
      }
      CATCH(e) {
        free(evt);
        xbt_die("Replay error :\n %s"
                  , e.msg);
      }
      for (i=0;evt[i]!= NULL;i++)
        free(evt[i]);
      free(evt);
    }
  } else {                      // Should have got my trace file in argument
Beispiel #10
0
void print_TIPushState(paje_event_t event)
{
  int i;

  //char* function=nullptr;
  if (((pushState_t) event->data)->extra == nullptr)
    return;
  instr_extra_data extra = (instr_extra_data) (((pushState_t) event->data)->extra);

  char *process_id = nullptr;
  //FIXME: dirty extract "rank-" from the name, as we want the bare process id here
  if (strstr(((pushState_t) event->data)->container->name, "rank-") == nullptr)
    process_id = xbt_strdup(((pushState_t) event->data)->container->name);
  else
    process_id = xbt_strdup(((pushState_t) event->data)->container->name + 5);

  FILE* trace_file =  (FILE* )xbt_dict_get(tracing_files, ((pushState_t) event->data)->container->name);

  switch (extra->type) {
  case TRACING_INIT:
    fprintf(trace_file, "%s init\n", process_id);
    break;
  case TRACING_FINALIZE:
    fprintf(trace_file, "%s finalize\n", process_id);
    break;
  case TRACING_SEND:
    fprintf(trace_file, "%s send %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
    break;
  case TRACING_ISEND:
    fprintf(trace_file, "%s isend %d %d %s\n", process_id, extra->dst, extra->send_size, extra->datatype1);
    break;
  case TRACING_RECV:
    fprintf(trace_file, "%s recv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
    break;
  case TRACING_IRECV:
    fprintf(trace_file, "%s irecv %d %d %s\n", process_id, extra->src, extra->send_size, extra->datatype1);
    break;
  case TRACING_TEST:
    fprintf(trace_file, "%s test\n", process_id);
    break;
  case TRACING_WAIT:
    fprintf(trace_file, "%s wait\n", process_id);
    break;
  case TRACING_WAITALL:
    fprintf(trace_file, "%s waitall\n", process_id);
    break;
  case TRACING_BARRIER:
    fprintf(trace_file, "%s barrier\n", process_id);
    break;
  case TRACING_BCAST:          // rank bcast size (root) (datatype)
    fprintf(trace_file, "%s bcast %d ", process_id, extra->send_size);
    if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
      fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
    fprintf(trace_file, "\n");
    break;
  case TRACING_REDUCE:         // rank reduce comm_size comp_size (root) (datatype)
    fprintf(trace_file, "%s reduce %d %f ", process_id, extra->send_size, extra->comp_size);
    if (extra->root != 0 || (extra->datatype1 && strcmp(extra->datatype1, "")))
      fprintf(trace_file, "%d %s", extra->root, extra->datatype1);
    fprintf(trace_file, "\n");
    break;
  case TRACING_ALLREDUCE:      // rank allreduce comm_size comp_size (datatype)
    fprintf(trace_file, "%s allreduce %d %f %s\n", process_id, extra->send_size, extra->comp_size, extra->datatype1);
    break;
  case TRACING_ALLTOALL:       // rank alltoall send_size recv_size (sendtype) (recvtype)
    fprintf(trace_file, "%s alltoall %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->datatype1,
            extra->datatype2);
    break;
  case TRACING_ALLTOALLV:      // rank alltoallv send_size [sendcounts] recv_size [recvcounts] (sendtype) (recvtype)
    fprintf(trace_file, "%s alltoallv %d ", process_id, extra->send_size);
    for (i = 0; i < extra->num_processes; i++)
      fprintf(trace_file, "%d ", extra->sendcounts[i]);
    fprintf(trace_file, "%d ", extra->recv_size);
    for (i = 0; i < extra->num_processes; i++)
      fprintf(trace_file, "%d ", extra->recvcounts[i]);
    fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
    break;
  case TRACING_GATHER:         // rank gather send_size recv_size root (sendtype) (recvtype)
    fprintf(trace_file, "%s gather %d %d %d %s %s\n", process_id, extra->send_size, extra->recv_size, extra->root,
            extra->datatype1, extra->datatype2);
    break;
  case TRACING_ALLGATHERV:     // rank allgatherv send_size [recvcounts] (sendtype) (recvtype)
    fprintf(trace_file, "%s allgatherv %d ", process_id, extra->send_size);
    for (i = 0; i < extra->num_processes; i++)
      fprintf(trace_file, "%d ", extra->recvcounts[i]);
    fprintf(trace_file, "%s %s \n", extra->datatype1, extra->datatype2);
    break;
  case TRACING_REDUCE_SCATTER: // rank reducescatter [recvcounts] comp_size (sendtype)
    fprintf(trace_file, "%s reducescatter ", process_id);
    for (i = 0; i < extra->num_processes; i++)
      fprintf(trace_file, "%d ", extra->recvcounts[i]);
    fprintf(trace_file, "%f %s\n", extra->comp_size, extra->datatype1);
    break;
  case TRACING_COMPUTING:
    fprintf(trace_file, "%s compute %f\n", process_id, extra->comp_size);
    break;
  case TRACING_SLEEPING:
    fprintf(trace_file, "%s sleep %f\n", process_id, extra->sleep_duration);
    break;
  case TRACING_GATHERV: // rank gatherv send_size [recvcounts] root (sendtype) (recvtype)
    fprintf(trace_file, "%s gatherv %d ", process_id, extra->send_size);
    for (i = 0; i < extra->num_processes; i++)
      fprintf(trace_file, "%d ", extra->recvcounts[i]);
    fprintf(trace_file, "%d %s %s\n", extra->root, extra->datatype1, extra->datatype2);
    break;
  case TRACING_WAITANY:
  case TRACING_SENDRECV:
  case TRACING_SCATTER:
  case TRACING_SCATTERV:
  case TRACING_ALLGATHER:
  case TRACING_SCAN:
  case TRACING_EXSCAN:
  case TRACING_COMM_SIZE:
  case TRACING_COMM_SPLIT:
  case TRACING_COMM_DUP:
  case TRACING_SSEND:
  case TRACING_ISSEND:
  default:
    XBT_WARN ("Call from %s impossible to translate into replay command : Not implemented (yet)",
         ((pushState_t) event->data)->value->name);
    break;
  }

  if (extra->recvcounts != nullptr)
    xbt_free(extra->recvcounts);
  if (extra->sendcounts != nullptr)
    xbt_free(extra->sendcounts);
  xbt_free(process_id);
  xbt_free(extra);
}
Beispiel #11
0
static MPI_Request find_request(int req) {
  char key[KEY_SIZE];
   
  return (MPI_Request)xbt_dict_get(request_lookup, get_key(key, req));
}
Beispiel #12
0
/* Master Process */
int master(int argc, char *argv[])
{
    char * key;
    struct HdmsgHost *hdmsg_host;
    xbt_dict_cursor_t cursor = NULL;
    
    int i = 0;
    
    long remaining_inits = 0;
    long remaining_mappers = 0;
    long remaining_shufflers = 0;
    long remaining_reducers = 0;
    long expected_messages = 0;
    
    msg_comm_t res_irecv;
    msg_task_t task_com;
    msg_task_t *tasks = xbt_new(msg_task_t, number_of_workers);
    xbt_dynar_t comms = xbt_dynar_new(sizeof(msg_comm_t), NULL);
    
    XBT_INFO("INITIALIZATION BEGIN");
    
    // Initialize processes (mappers, shufflers, and reducers) on each host
    xbt_dict_foreach(hosts, cursor, key, hdmsg_host)
    {
        if (hdmsg_host->is_worker)
        {
            MSG_process_create("Init", initializeProcs, NULL, hdmsg_host->host);
            
            tasks[remaining_inits] = NULL;
            res_irecv = MSG_task_irecv(&tasks[remaining_inits], "master");
            xbt_dynar_push_as(comms, msg_comm_t, res_irecv);
            remaining_inits++;
        }
    }
    
    while (!xbt_dynar_is_empty(comms))
    {
        xbt_dynar_remove_at(comms, MSG_comm_waitany(comms), &res_irecv);
        task_com = MSG_comm_get_task(res_irecv);
        
        if (!strcmp(MSG_task_get_name(task_com), "init_exit"))
        {
            msg_host_t h = MSG_task_get_source(task_com);
            MSG_task_destroy(task_com);
            
            const char *host_name = MSG_host_get_name(h);
            struct HdmsgHost *hdmsg_host = xbt_dict_get(hosts, host_name);
            
            remaining_mappers += get_mapper_count(hdmsg_host);
            remaining_shufflers += get_shuffler_count(hdmsg_host);
            remaining_reducers += get_reducer_count(hdmsg_host);
            
            remaining_inits--;
            
            if (remaining_inits == 0)
            {
                XBT_INFO("INITIALIZATION COMPLETE");
                
                // Add an extra message to account for the message sent when the shuffle phase begins
                expected_messages = 1 + remaining_mappers + remaining_shufflers + remaining_reducers;
                
                free(tasks);
                tasks = xbt_new(msg_task_t, expected_messages);
                
                for (i = 0; i < expected_messages; i++)
                {
                    tasks[i] = NULL;
                    res_irecv = MSG_task_irecv(&tasks[i], "master");
                    xbt_dynar_push_as(comms, msg_comm_t, res_irecv);
                }
                
                XBT_INFO("MAP PHASE BEGIN");
                
                // Activate Mappers
                xbt_dict_foreach(hosts, cursor, key, hdmsg_host)
                {
                    activate_mappers(hdmsg_host);
                }
            }