コード例 #1
0
ファイル: msg_host.c プロジェクト: dhascome/simgrid
/********************************* Host **************************************/
msg_host_t __MSG_host_create(smx_host_t workstation)
{
  const char *name = SIMIX_host_get_name(workstation);
  msg_host_priv_t host = xbt_new0(s_msg_host_priv_t, 1);
  s_msg_vm_t vm; // simply to compute the offset

  host->vms = xbt_swag_new(xbt_swag_offset(vm,host_vms_hookup));

#ifdef MSG_USE_DEPRECATED
  int i;
  char alias[MAX_ALIAS_NAME + 1] = { 0 };       /* buffer used to build the key of the mailbox */

  if (msg_global->max_channel > 0)
    host->mailboxes = xbt_new0(msg_mailbox_t, msg_global->max_channel);

  for (i = 0; i < msg_global->max_channel; i++) {
    sprintf(alias, "%s:%d", name, i);

    /* the key of the mailbox (in this case) is build from the name of the host and the channel number */
    host->mailboxes[i] = MSG_mailbox_new(alias);
    memset(alias, 0, MAX_ALIAS_NAME + 1);
  }
#endif

  xbt_lib_set(host_lib,name,MSG_HOST_LEVEL,host);
  
  return xbt_lib_get_elm_or_null(host_lib, name);
}
コード例 #2
0
ファイル: network_ns3.c プロジェクト: Shurakai/SimGrid
static void parse_ns3_add_link(sg_platf_link_cbarg_t link)
{
  XBT_DEBUG("NS3_ADD_LINK '%s'",link->id);

  if(!IPV4addr) IPV4addr = xbt_dynar_new(sizeof(char*),free);

  tmgr_trace_t bw_trace;
  tmgr_trace_t state_trace;
  tmgr_trace_t lat_trace;

  bw_trace = link->bandwidth_trace;
  lat_trace = link->latency_trace;
  state_trace = link->state_trace;

  if (bw_trace)
    XBT_INFO("The NS3 network model doesn't support bandwidth state traces");
  if (lat_trace)
    XBT_INFO("The NS3 network model doesn't support latency state traces");
  if (state_trace)
    XBT_INFO("The NS3 network model doesn't support link state traces");

  ns3_link_t link_ns3 = xbt_new0(s_ns3_link_t,1);;
  link_ns3->id = xbt_strdup((char*)(link->id));
  link_ns3->bdw = bprintf("%f",link->bandwidth);
  link_ns3->lat = bprintf("%f",link->latency);

  surf_ns3_link_t l = xbt_new0(s_surf_ns3_link_t,1);
  l->generic_resource.name = xbt_strdup(link->id);
  l->generic_resource.properties = current_property_set;
  l->data = link_ns3;
  l->created = 1;

  xbt_lib_set(link_lib,link->id,NS3_LINK_LEVEL,link_ns3);
  xbt_lib_set(link_lib,link->id,SURF_LINK_LEVEL,l);
}
コード例 #3
0
ファイル: msg_host.c プロジェクト: tempbottle/simgrid
/********************************* Host **************************************/
msg_host_t __MSG_host_create(sg_host_t host) // FIXME: don't return our parameter
{
  msg_host_priv_t priv = xbt_new0(s_msg_host_priv_t, 1);

#ifdef MSG_USE_DEPRECATED
  int i;
  char alias[MAX_ALIAS_NAME + 1] = { 0 };       /* buffer used to build the key of the mailbox */

  priv->mailboxes = (msg_global->max_channel > 0) ?
    xbt_new0(msg_mailbox_t, msg_global->max_channel) : NULL;

  for (i = 0; i < msg_global->max_channel; i++) {
    sprintf(alias, "%s:%d", name, i);

    /* the key of the mailbox (in this case) is build from the name of the host and the channel number */
    priv->mailboxes[i] = MSG_mailbox_new(alias);
    memset(alias, 0, MAX_ALIAS_NAME + 1);
  }
#endif


  priv->dp_objs = xbt_dict_new();
  priv->dp_enabled = 0;
  priv->dp_updated_by_deleted_tasks = 0;
  priv->is_migrating = 0;

  priv->affinity_mask_db = xbt_dict_new_homogeneous(NULL);

  sg_host_msg_set(host,priv);
  
  return host;
}
コード例 #4
0
void new_pajePushStateWithExtra (double timestamp, container_t container, type_t type, val_t value, void* extra)
{
  paje_event_t event = xbt_new0(s_paje_event_t, 1);
  event->event_type = PAJE_PushState;
  event->timestamp = timestamp;
  event->print = active_writer.print_PushState;
  event->free                             = &free_paje_event;
  event->data = xbt_new0(s_pushState_t, 1);
  (static_cast<pushState_t>(event->data))->type = type;
  (static_cast<pushState_t>(event->data))->container = container;
  (static_cast<pushState_t>(event->data))->value = value;
  (static_cast<pushState_t>(event->data))->extra = extra;

#if HAVE_SMPI
  if (xbt_cfg_get_boolean("smpi/trace-call-location")) {
    smpi_trace_call_location_t* loc = smpi_trace_get_call_location();
    (static_cast<pushState_t>(event->data))->filename   = loc->filename;
    (static_cast<pushState_t>(event->data))->linenumber = loc->linenumber;
  }
#endif

  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, static_cast<int>(event->event_type), event->timestamp);

  insert_into_buffer (event);
}
コード例 #5
0
ファイル: AsFull.cpp プロジェクト: fabienchaix/simgrid
void AsFull::seal() {
  int i;
  sg_platf_route_cbarg_t e_route;

  /* set utils vars */
  int table_size = static_cast<int>(vertices_.size());

  /* Create table if necessary */
  if (!routingTable_)
    routingTable_ = xbt_new0(sg_platf_route_cbarg_t, table_size * table_size);

  /* Add the loopback if needed */
  if (routing_platf->loopback_ && hierarchy_ == RoutingMode::base) {
    for (i = 0; i < table_size; i++) {
      e_route = TO_ROUTE_FULL(i, i);
      if (!e_route) {
        e_route = xbt_new0(s_sg_platf_route_cbarg_t, 1);
        e_route->gw_src = nullptr;
        e_route->gw_dst = nullptr;
        e_route->link_list = new std::vector<Link*>();
        e_route->link_list->push_back(routing_platf->loopback_);
        TO_ROUTE_FULL(i, i) = e_route;
      }
    }
  }
}
コード例 #6
0
ファイル: host.c プロジェクト: rosacris/simgrid
/********************************* Host **************************************/
m_host_t __MSG_host_create(smx_host_t workstation, void *data)
{
  const char *name;
  simdata_host_t simdata = xbt_new0(s_simdata_host_t, 1);
  m_host_t host = xbt_new0(s_m_host_t, 1);
  int i;

  char alias[MAX_ALIAS_NAME + 1] = { 0 };       /* buffer used to build the key of the mailbox */

  name = SIMIX_host_get_name(workstation);
  /* Host structure */
  host->name = xbt_strdup(name);
  host->simdata = simdata;
  host->data = data;

  simdata->smx_host = workstation;

  if (msg_global->max_channel > 0)
    simdata->mailboxes = xbt_new0(msg_mailbox_t, msg_global->max_channel);

  for (i = 0; i < msg_global->max_channel; i++) {
    sprintf(alias, "%s:%d", name, i);

    /* the key of the mailbox (in this case) is build from the name of the host and the channel number */
    simdata->mailboxes[i] = MSG_mailbox_new(alias);
    memset(alias, 0, MAX_ALIAS_NAME + 1);
  }

  SIMIX_req_host_set_data(workstation, host);
  xbt_lib_set(host_lib,name,MSG_HOST_LEVEL,host);

  return host;
}
コード例 #7
0
ファイル: surf_model.c プロジェクト: Shurakai/SimGrid
/** @brief initialize common datastructures to all models */
surf_model_t surf_model_init(void)
{
  s_surf_action_t action;
  surf_model_t model = xbt_new0(s_surf_model_t, 1);

  model->model_private = xbt_new0(s_surf_model_private_t, 1);

  model->states.ready_action_set =
      xbt_swag_new(xbt_swag_offset(action, state_hookup));
  model->states.running_action_set =
      xbt_swag_new(xbt_swag_offset(action, state_hookup));
  model->states.failed_action_set =
      xbt_swag_new(xbt_swag_offset(action, state_hookup));
  model->states.done_action_set =
      xbt_swag_new(xbt_swag_offset(action, state_hookup));

  model->action_unref = int_die_impossible_paction;
  model->action_cancel = void_die_impossible_paction;
  model->action_recycle = void_die_impossible_paction;

  model->action_state_get = surf_action_state_get;
  model->action_state_set = surf_action_state_set;
  model->action_get_start_time = surf_action_get_start_time;
  model->action_get_finish_time = surf_action_get_finish_time;
  model->action_data_set = surf_action_data_set;

  model->model_private->modified_set = NULL;
  model->model_private->action_heap = NULL;
  model->model_private->update_mechanism = UM_UNDEFINED;
  model->model_private->selective_update = 0;

  return model;
}
コード例 #8
0
ファイル: msg_host.c プロジェクト: Julio-Anjos/simgrid
/********************************* Host **************************************/
msg_host_t __MSG_host_create(smx_host_t workstation)
{
  const char *name = SIMIX_host_get_name(workstation);
  msg_host_priv_t priv = xbt_new0(s_msg_host_priv_t, 1);

#ifdef MSG_USE_DEPRECATED
  int i;
  char alias[MAX_ALIAS_NAME + 1] = { 0 };       /* buffer used to build the key of the mailbox */

  priv->mailboxes = (msg_global->max_channel > 0) ?
    xbt_new0(msg_mailbox_t, msg_global->max_channel) : NULL;

  for (i = 0; i < msg_global->max_channel; i++) {
    sprintf(alias, "%s:%d", name, i);

    /* the key of the mailbox (in this case) is build from the name of the host and the channel number */
    priv->mailboxes[i] = MSG_mailbox_new(alias);
    memset(alias, 0, MAX_ALIAS_NAME + 1);
  }
#endif


  priv->dp_objs = xbt_dict_new();
  priv->dp_enabled = 0;
  priv->dp_updated_by_deleted_tasks = 0;
  priv->is_migrating = 0;

  priv->affinity_mask_db = xbt_dict_new_homogeneous(NULL);

  xbt_lib_set(host_lib, name, MSG_HOST_LEVEL, priv);
  
  return xbt_lib_get_elm_or_null(host_lib, name);
}
コード例 #9
0
ファイル: actions.c プロジェクト: tempbottle/simgrid
static void action_reduce(const char *const *action)
{
  int i;
  char *reduce_identifier;
  char mailbox[80];
  double comm_size = parse_double(action[2]);
  double comp_size = parse_double(action[3]);
  msg_task_t comp_task = NULL;
  const char *process_name;
  double clock = MSG_get_clock();

  process_globals_t counters =
      (process_globals_t) MSG_process_get_data(MSG_process_self());

  xbt_assert(communicator_size, "Size of Communicator is not defined, "
             "can't use collective operations");

  process_name = MSG_process_get_name(MSG_process_self());

  reduce_identifier = bprintf("reduce_%d", counters->reduce_counter++);

  if (!strcmp(process_name, "p0")) {
    XBT_DEBUG("%s: %s is the Root", reduce_identifier, process_name);

    msg_comm_t *comms = xbt_new0(msg_comm_t, communicator_size - 1);
    msg_task_t *tasks = xbt_new0(msg_task_t, communicator_size - 1);
    for (i = 1; i < communicator_size; i++) {
      sprintf(mailbox, "%s_p%d_p0", reduce_identifier, i);
      comms[i - 1] = MSG_task_irecv(&(tasks[i - 1]), mailbox);
    }
    MSG_comm_waitall(comms, communicator_size - 1, -1);
    for (i = 1; i < communicator_size; i++) {
      MSG_comm_destroy(comms[i - 1]);
      MSG_task_destroy(tasks[i - 1]);
    }
    xbt_free(comms);
    xbt_free(tasks);

    comp_task = MSG_task_create("reduce_comp", comp_size, 0, NULL);
    XBT_DEBUG("%s: computing 'reduce_comp'", reduce_identifier);
    MSG_task_execute(comp_task);
    MSG_task_destroy(comp_task);
    XBT_DEBUG("%s: computed", reduce_identifier);

  } else {
    XBT_DEBUG("%s: %s sends", reduce_identifier, process_name);
    sprintf(mailbox, "%s_%s_p0", reduce_identifier, process_name);
    XBT_DEBUG("put on %s", mailbox);
    MSG_task_send(MSG_task_create(reduce_identifier, 0, comm_size, NULL),
                  mailbox);
  }

  log_action(action, MSG_get_clock() - clock);
  xbt_free(reduce_identifier);
}
コード例 #10
0
void new_pajeResetState (double timestamp, container_t container, type_t type)
{
  paje_event_t event = xbt_new0(s_paje_event_t, 1);
  event->event_type = PAJE_ResetState;
  event->timestamp = timestamp;
  event->print = active_writer.print_ResetState;
  event->free                              = &free_paje_event;
  event->data = xbt_new0(s_resetState_t, 1);
  (static_cast<resetState_t>(event->data))->type = type;
  (static_cast<resetState_t>(event->data))->container = container;

  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);

  insert_into_buffer (event);
}
コード例 #11
0
ファイル: surf_routing.c プロジェクト: dhascome/simgrid
/**
 * \brief Add a "host" to the network element list
 */
static void parse_S_host(sg_platf_host_cbarg_t host)
{
  sg_routing_edge_t info = NULL;
  if (current_routing->hierarchy == SURF_ROUTING_NULL)
    current_routing->hierarchy = SURF_ROUTING_BASE;
  xbt_assert(!xbt_lib_get_or_null(host_lib, host->id, ROUTING_HOST_LEVEL),
             "Reading a host, processing unit \"%s\" already exists", host->id);

  info = xbt_new0(s_routing_edge_t, 1);
  info->rc_component = current_routing;
  info->rc_type = SURF_NETWORK_ELEMENT_HOST;
  info->name = xbt_strdup(host->id);
  info->id = current_routing->parse_PU(current_routing, (void *) info);
  xbt_lib_set(host_lib, host->id, ROUTING_HOST_LEVEL, (void *) info);
  XBT_DEBUG("Having set name '%s' id '%d'",host->id,info->id);

  if(mount_list){
    xbt_lib_set(storage_lib, host->id, ROUTING_STORAGE_HOST_LEVEL, (void *) mount_list);
    mount_list = NULL;
  }

  if (host->coord && strcmp(host->coord, "")) {
    unsigned int cursor;
    char*str;

    if (!COORD_HOST_LEVEL)
      xbt_die ("To use host coordinates, please add --cfg=network/coordinates:yes to your command line");
    /* Pre-parse the host coordinates -- FIXME factorize with routers by overloading the routing->parse_PU function*/
    xbt_dynar_t ctn_str = xbt_str_split_str(host->coord, " ");
    xbt_dynar_t ctn = xbt_dynar_new(sizeof(double),NULL);
    xbt_dynar_foreach(ctn_str,cursor, str) {
      double val = atof(str);
      xbt_dynar_push(ctn,&val);
    }
コード例 #12
0
ファイル: instr_trace.cpp プロジェクト: fabienchaix/simgrid
void new_pajeDefineEventType(type_t type)
{
  paje_event_t event = xbt_new0(s_paje_event_t, 1);
  event->event_type = PAJE_DefineEventType;
  event->timestamp = 0;
  event->print = active_writer.print_DefineEventType;
  event->free = free_paje_event;
  event->data = xbt_new0(s_defineEventType_t, 1);
  ((defineEventType_t)(event->data))->type = type;

  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);

  //print it
  event->print (event);
  event->free (event);
}
コード例 #13
0
ファイル: smpi_replay.c プロジェクト: apargupta/simgrid
static void action_test(const char *const *action){
  CHECK_ACTION_PARAMS(action, 0, 0);
  double clock = smpi_process_simulated_elapsed();
  MPI_Request request;
  MPI_Status status;
  int flag = TRUE;

  request = xbt_dynar_pop_as(get_reqq_self(),MPI_Request);
  //if request is null here, this may mean that a previous test has succeeded 
  //Different times in traced application and replayed version may lead to this 
  //In this case, ignore the extra calls.
  if(request){
	  int rank = smpi_process_index();
	  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
	  extra->type=TRACING_TEST;
	  TRACE_smpi_testing_in(rank, extra);

	  flag = smpi_mpi_test(&request, &status);

	  XBT_DEBUG("MPI_Test result: %d", flag);
	  /* push back request in dynar to be caught by a subsequent wait. if the test
	   * did succeed, the request is now NULL.
	   */
	  xbt_dynar_push_as(get_reqq_self(),MPI_Request, request);

	  TRACE_smpi_testing_out(rank);
  }
  log_timed_action (action, clock);
}
コード例 #14
0
ファイル: instr_trace.cpp プロジェクト: fabienchaix/simgrid
void new_pajeNewEvent (double timestamp, container_t container, type_t type, val_t value)
{
  paje_event_t event = xbt_new0(s_paje_event_t, 1);
  event->event_type = PAJE_NewEvent;
  event->timestamp = timestamp;
  event->print = active_writer.print_NewEvent;
  event->free = free_paje_event;
  event->data = xbt_new0(s_newEvent_t, 1);
  ((newEvent_t)(event->data))->type = type;
  ((newEvent_t)(event->data))->container = container;
  ((newEvent_t)(event->data))->value = value;

  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);

  insert_into_buffer (event);
}
コード例 #15
0
static void model_rulebased_parse_route(AS_t rc, sg_platf_route_cbarg_t route)
{
  char *src = (char*)(route->src);
  char *dst = (char*)(route->dst);

  AS_rulebased_t routing = (AS_rulebased_t) rc;
  rule_route_t ruleroute = xbt_new0(s_rule_route_t, 1);
  const char *error;
  int erroffset;

  if(!strcmp(rc->model_desc->name,"Vivaldi")){
    if(!xbt_dynar_is_empty(route->link_list))
      xbt_die("You can't have link_ctn with Model Vivaldi.");
  }

  ruleroute->re_src = pcre_compile(src, 0, &error, &erroffset, NULL);
  xbt_assert(ruleroute->re_src,
      "PCRE compilation failed at offset %d (\"%s\"): %s\n",
      erroffset, src, error);
  ruleroute->re_dst = pcre_compile(dst, 0, &error, &erroffset, NULL);
  xbt_assert(ruleroute->re_src,
      "PCRE compilation failed at offset %d (\"%s\"): %s\n",
      erroffset, dst, error);

  ruleroute->re_str_link = route->link_list;
  route->link_list = NULL; // Don't free it twice in each container

  xbt_dynar_push(routing->list_route, &ruleroute);
}
コード例 #16
0
/* Business methods */
xbt_dynar_t AsFloyd::getOneLinkRoutes()
{
  xbt_dynar_t ret = xbt_dynar_new(sizeof(OnelinkPtr), xbt_free_f);
  sg_platf_route_cbarg_t route =   xbt_new0(s_sg_platf_route_cbarg_t, 1);
  route->link_list = xbt_dynar_new(sizeof(sg_routing_link_t), NULL);

  int src,dst;
  sg_routing_edge_t src_elm, dst_elm;
  int table_size = xbt_dynar_length(p_indexNetworkElm);
  for(src=0; src < table_size; src++) {
    for(dst=0; dst< table_size; dst++) {
      xbt_dynar_reset(route->link_list);
      src_elm = xbt_dynar_get_as(p_indexNetworkElm, src, RoutingEdgePtr);
      dst_elm = xbt_dynar_get_as(p_indexNetworkElm, dst, RoutingEdgePtr);
      this->getRouteAndLatency(src_elm, dst_elm, route, NULL);

      if (xbt_dynar_length(route->link_list) == 1) {
        void *link = *(void **) xbt_dynar_get_ptr(route->link_list, 0);
        OnelinkPtr onelink;
        if (p_hierarchy == SURF_ROUTING_BASE)
          onelink = new Onelink(link, src_elm, dst_elm);
        else if (p_hierarchy == SURF_ROUTING_RECURSIVE)
          onelink = new Onelink(link, route->gw_src, route->gw_dst);
        else
          onelink = new Onelink(link, NULL, NULL);
        xbt_dynar_push(ret, &onelink);
      }
    }
  }

  return ret;
}
コード例 #17
0
ファイル: smpi_replay.c プロジェクト: apargupta/simgrid
static void action_Isend(const char *const *action)
{
  CHECK_ACTION_PARAMS(action, 2, 1);
  int to = atoi(action[2]);
  double size=parse_double(action[3]);
  double clock = smpi_process_simulated_elapsed();
  MPI_Request request;

  if(action[4]) MPI_CURRENT_TYPE=decode_datatype(action[4]);
  else MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;

  int rank = smpi_process_index();
  int dst_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), to);
  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
  extra->type = TRACING_ISEND;
  extra->send_size = size;
  extra->src = rank;
  extra->dst = dst_traced;
  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL);
  TRACE_smpi_ptp_in(rank, rank, dst_traced, __FUNCTION__, extra);
  if (!TRACE_smpi_view_internals()) {
    TRACE_smpi_send(rank, rank, dst_traced, size*smpi_datatype_size(MPI_CURRENT_TYPE));
  }

  request = smpi_mpi_isend(NULL, size, MPI_CURRENT_TYPE, to, 0,MPI_COMM_WORLD);

  TRACE_smpi_ptp_out(rank, rank, dst_traced, __FUNCTION__);
  request->send = 1;

  xbt_dynar_push(get_reqq_self(),&request);

  log_timed_action (action, clock);
}
コード例 #18
0
ファイル: maxmin.cpp プロジェクト: luizabeltrame/simgrid
lmm_system_t lmm_system_new(int selective_update)
{
  lmm_system_t l = NULL;
  s_lmm_variable_t var;
  s_lmm_constraint_t cnst;

  l = xbt_new0(s_lmm_system_t, 1);

  l->modified = 0;
  l->selective_update_active = selective_update;
  l->visited_counter = 1;

  XBT_DEBUG("Setting selective_update_active flag to %d", l->selective_update_active);

  xbt_swag_init(&(l->variable_set), xbt_swag_offset(var, variable_set_hookup));
  xbt_swag_init(&(l->constraint_set), xbt_swag_offset(cnst, constraint_set_hookup));

  xbt_swag_init(&(l->active_constraint_set), xbt_swag_offset(cnst, active_constraint_set_hookup));

  xbt_swag_init(&(l->modified_constraint_set), xbt_swag_offset(cnst, modified_constraint_set_hookup));
  xbt_swag_init(&(l->saturated_variable_set), xbt_swag_offset(var, saturated_variable_set_hookup));
  xbt_swag_init(&(l->saturated_constraint_set), xbt_swag_offset(cnst, saturated_constraint_set_hookup));

  l->variable_mallocator = xbt_mallocator_new(65536,
                                              lmm_variable_mallocator_new_f,
                                              lmm_variable_mallocator_free_f,
                                              lmm_variable_mallocator_reset_f);

  return l;
}
コード例 #19
0
ファイル: instr_trace.cpp プロジェクト: fabienchaix/simgrid
void new_pajeCreateContainer (container_t container)
{
  paje_event_t event = xbt_new0(s_paje_event_t, 1);
  event->event_type = PAJE_CreateContainer;
  event->timestamp = SIMIX_get_clock();
  event->print = active_writer.print_CreateContainer;
  event->free = free_paje_event;
  event->data = xbt_new0(s_createContainer_t, 1);
  ((createContainer_t)(event->data))->container = container;

  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);

  //print it
  event->print (event);
  event->free (event);
}
コード例 #20
0
void new_pajeDefineEntityValue (val_t value)
{
  paje_event_t event = xbt_new0(s_paje_event_t, 1);
  event->event_type = PAJE_DefineEntityValue;
  event->timestamp = 0;
  event->print = active_writer.print_DefineEntityValue;
  event->free                                 = &free_paje_event;
  event->data = xbt_new0(s_defineEntityValue_t, 1);
  (static_cast<defineEntityValue_t>(event->data))->value = value;

  XBT_DEBUG("%s: event_type=%d", __FUNCTION__, (int)event->event_type);

  //print it
  event->print (event);
  event->free (event);
}
コード例 #21
0
void new_pajeDestroyContainer (container_t container)
{
  paje_event_t event = xbt_new0(s_paje_event_t, 1);
  event->event_type = PAJE_DestroyContainer;
  event->timestamp = SIMIX_get_clock();
  event->print = active_writer.print_DestroyContainer;
  event->free                                    = &free_paje_event;
  event->data = xbt_new0(s_destroyContainer_t, 1);
  (static_cast<destroyContainer_t>(event->data))->container = container;

  XBT_DEBUG("%s: event_type=%d, timestamp=%f", __FUNCTION__, (int)event->event_type, event->timestamp);

  //print it
  event->print (event);
  event->free (event);
}
コード例 #22
0
ファイル: smpi_replay.c プロジェクト: apargupta/simgrid
static void action_Irecv(const char *const *action)
{
  CHECK_ACTION_PARAMS(action, 2, 1);
  int from = atoi(action[2]);
  double size=parse_double(action[3]);
  double clock = smpi_process_simulated_elapsed();
  MPI_Request request;

  if(action[4]) MPI_CURRENT_TYPE=decode_datatype(action[4]);
  else MPI_CURRENT_TYPE= MPI_DEFAULT_TYPE;

  int rank = smpi_process_index();
  int src_traced = smpi_group_rank(smpi_comm_group(MPI_COMM_WORLD), from);
  instr_extra_data extra = xbt_new0(s_instr_extra_data_t,1);
  extra->type = TRACING_IRECV;
  extra->send_size = size;
  extra->src = src_traced;
  extra->dst = rank;
  extra->datatype1 = encode_datatype(MPI_CURRENT_TYPE, NULL);
  TRACE_smpi_ptp_in(rank, src_traced, rank, __FUNCTION__, extra);
  MPI_Status status;
  //unknow size from the receiver pov
  if(size==-1){
      smpi_mpi_probe(from, 0, MPI_COMM_WORLD, &status);
      size=status.count;
  }

  request = smpi_mpi_irecv(NULL, size, MPI_CURRENT_TYPE, from, 0, MPI_COMM_WORLD);

  TRACE_smpi_ptp_out(rank, src_traced, rank, __FUNCTION__);
  request->recv = 1;
  xbt_dynar_push(get_reqq_self(),&request);

  log_timed_action (action, clock);
}
コード例 #23
0
//syntax is  <maxsize>:<filename>
//If roll is 0, use split files, otherwise, use roll file
//For split, replace %  in the file by the current count
xbt_log_appender_t xbt_log_appender2_file_new(char *arg,int roll) {

  xbt_log_appender_t res = xbt_new0(s_xbt_log_appender_t, 1);
  if (_XBT_LOGV(smpi).initialized) // HACK to detect if we run in SMPI mode. Relies on MAIN__ source disposition
    res->do_append = smpi_append2_file;
  else
    res->do_append = append2_file;
  res->free_ = free_append2_;
  xbt_log_append2_file_t data = xbt_new0(struct xbt_log_append2_file_s, 1);
  xbt_assert(arg);
  char* buf=xbt_strdup(arg);
  char* sep=strchr(buf,':');
  xbt_assert(sep>0);
  data->filename=xbt_strdup(sep+1);
  *sep='\0';
  char *endptr;
  data->limit=strtol(buf,&endptr,10);
  xbt_assert(endptr[0]=='\0', "Invalid buffer size: %s", buf);
  xbt_free(buf);
  if(roll)
    data->count=-1;
  else
    data->count=0;
  open_append2_file(data);  
  res->data = data;
  return res;
}
コード例 #24
0
ファイル: rl_process.c プロジェクト: rosacris/simgrid
void gras_process_init()
{
  char **env_iter;
  _gras_procdata = xbt_new0(gras_procdata_t, 1);
  gras_procdata_init();

  /* initialize the host & process properties */
  _host_properties = xbt_dict_new();
  _process_properties = xbt_dict_new();
  env_iter = environ;
  while (*env_iter) {
    char *equal, *buf = xbt_strdup(*env_iter);
    equal = strchr(buf, '=');
    if (!equal) {
      XBT_WARN
          ("The environment contains an entry without '=' char: %s (ignore it)",
           *env_iter);
      continue;
    }
    *equal = '\0';
    xbt_dict_set(_process_properties, buf, xbt_strdup(equal + 1),
                 xbt_free_f);
    free(buf);
    env_iter++;
  }
}
コード例 #25
0
static smx_context_t
smx_ctx_cojava_factory_create_context(xbt_main_func_t code,
                                      int argc, char **argv,
                                      void_pfn_smxprocess_t cleanup_func,
                                      smx_process_t process)
{
	smx_ctx_cojava_t context = xbt_new0(s_smx_ctx_cojava_t, 1);
  /* If the user provided a function for the process then use it
     otherwise is the context for maestro */
  if (code) {
    if (argc == 0) {
      context->jprocess = (jobject) code;
    }
    else {
      context->jprocess = NULL;
    }
    context->super.cleanup_func = cleanup_func;

    context->super.argc = argc;
    context->super.argv = argv;
    context->super.code = code;

    smx_ctx_cojava_run(context);
  }
  else {
  	context->jcoroutine = NULL;
  	my_current_context = (smx_context_t)context;
  	maestro_context = (smx_context_t)context;
  }
  context->bound = 0;
  context->super.process = process;
  return (smx_context_t) context;
}
コード例 #26
0
ファイル: storage_n11.cpp プロジェクト: fabienchaix/simgrid
StorageAction *StorageN11::open(const char* mount, const char* path)
{
  XBT_DEBUG("\tOpen file '%s'",path);

  sg_size_t size, *psize;
  psize = (sg_size_t*) xbt_dict_get_or_null(content_, path);
  // if file does not exist create an empty file
  if(psize)
    size = *psize;
  else {
    psize = xbt_new(sg_size_t,1);
    size = 0;
    *psize = size;
    xbt_dict_set(content_, path, psize, nullptr);
    XBT_DEBUG("File '%s' was not found, file created.",path);
  }
  surf_file_t file = xbt_new0(s_surf_file_t,1);
  file->name = xbt_strdup(path);
  file->size = size;
  file->mount = xbt_strdup(mount);
  file->current_position = 0;

  StorageAction *action = new StorageN11Action(getModel(), 0, isOff(), this, OPEN);
  action->p_file = file;

  return action;
}
コード例 #27
0
msg_process_t MSG_process_create_with_environment(
  const char *name, std::function<void()> code, void *data,
  msg_host_t host, xbt_dict_t properties)
{
  xbt_assert(code != nullptr && host != nullptr, "Invalid parameters: host and code params must not be nullptr");
  simdata_process_t simdata = xbt_new0(s_simdata_process_t, 1);
  msg_process_t process;

  /* Simulator data for MSG */
  simdata->waiting_action = nullptr;
  simdata->waiting_task = nullptr;
  simdata->m_host = host;
  simdata->data = data;
  simdata->last_errno = MSG_OK;

  /* Let's create the process: SIMIX may decide to start it right now,
   * even before returning the flow control to us */
  process = simcall_process_create(
    name, std::move(code), simdata, host, -1,  properties, 0);

  if (!process) {
    /* Undo everything we have just changed */
    xbt_free(simdata);
    return nullptr;
  }
  else {
    simcall_process_on_exit(process,(int_f_pvoid_pvoid_t)TRACE_msg_process_kill,process);
  }
  return process;
}
コード例 #28
0
ファイル: smpi_replay.c プロジェクト: ricardojrdez/simgrid
static void action_init(const char *const *action)
{
  int i;
  XBT_DEBUG("Initialize the counters");
  smpi_replay_globals_t globals =  xbt_new(s_smpi_replay_globals_t, 1);
  globals->irecvs = xbt_dynar_new(sizeof(MPI_Request),NULL);

  if(action[2]) MPI_DEFAULT_TYPE= MPI_DOUBLE; // default MPE dataype 
  else MPI_DEFAULT_TYPE= MPI_BYTE; // default TAU datatype

  smpi_process_set_user_data((void*) globals);

  /* start a simulated timer */
  smpi_process_simulated_start();
  /*initialize the number of active processes */
  active_processes = smpi_process_count();

  if (!reqq) {
    reqq=xbt_new0(xbt_dynar_t,active_processes);

    for(i=0;i<active_processes;i++){
      reqq[i]=xbt_dynar_new(sizeof(MPI_Request),NULL);
    }
  }
}
コード例 #29
0
ファイル: masterworker.c プロジェクト: mpoquet/simgrid
/** Master expects 3+ arguments given in the XML deployment file: */
static int master(int argc, char* argv[])
{
  long number_of_tasks = xbt_str_parse_int(argv[1], "Invalid amount of tasks: %s");       /** - Number of tasks      */
  double comp_size     = xbt_str_parse_double(argv[2], "Invalid computational size: %s"); /** - Task compute cost    */
  double comm_size = xbt_str_parse_double(argv[3], "Invalid communication size: %s"); /** - Task communication size */

  /* Create the tasks in advance */
  msg_task_t* todo = xbt_new0(msg_task_t, number_of_tasks);

  for (int i = 0; i < number_of_tasks; i++) {
    char sprintf_buffer[64];
    sprintf(sprintf_buffer, "Task_%d", i);
    todo[i] = MSG_task_create(sprintf_buffer, comp_size, comm_size, NULL);
  }

  /* Get the info about the worker processes from my parameters */
  int worker_count    = argc - 4;
  msg_host_t* workers = xbt_new0(msg_host_t, worker_count);

  for (int i = 4; i < argc; i++) {
    workers[i - 4] = MSG_get_host_by_name(argv[i]);
    xbt_assert(workers[i - 4] != NULL, "Unknown host %s. Stopping Now! ", argv[i]);
  }
  XBT_INFO("Got %d workers and %ld tasks to process", worker_count, number_of_tasks);

  /* Dispatch the tasks */
  for (int i = 0; i < number_of_tasks; i++) {
    XBT_INFO("Sending '%s' to '%s'", todo[i]->name, MSG_host_get_name(workers[i % worker_count]));
    if (MSG_host_self() == workers[i % worker_count]) {
      XBT_INFO("Hey ! It's me ! :)");
    }

    MSG_task_send(todo[i], MSG_host_get_name(workers[i % worker_count]));
    XBT_INFO("Sent");
  }

  XBT_INFO("All tasks have been dispatched. Let's tell everybody the computation is over.");
  for (int i = 0; i < worker_count; i++) {
    msg_task_t finalize = MSG_task_create("finalize", 0, 0, FINALIZE);
    MSG_task_send(finalize, MSG_host_get_name(workers[i]));
  }

  XBT_INFO("Goodbye now!");
  free(workers);
  free(todo);
  return 0;
}
コード例 #30
0
ファイル: msg_gos.c プロジェクト: tempbottle/simgrid
/* Internal function used to factorize code between
 * MSG_task_isend_with_matching() and MSG_task_dsend().
 */
static XBT_INLINE
msg_comm_t MSG_task_isend_internal(msg_task_t task, const char *alias,
                                   int (*match_fun)(void*,void*, smx_synchro_t),
                                   void *match_data, void_f_pvoid_t cleanup,
                                   int detached)
{
  simdata_task_t t_simdata = NULL;
  msg_process_t process = MSG_process_self();
  msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);
  int call_end = TRACE_msg_task_put_start(task);

  /* Prepare the task to send */
  t_simdata = task->simdata;
  t_simdata->sender = process;
  t_simdata->source = ((simdata_process_t) SIMIX_process_self_get_data(process))->m_host;

  if (t_simdata->isused != 0) {
    if (msg_global->debug_multiple_use){
      XBT_ERROR("This task is already used in there:");
      xbt_backtrace_display(t_simdata->isused);
      XBT_ERROR("And you try to reuse it from here:");
      xbt_backtrace_display_current();
    } else {
      xbt_assert(t_simdata->isused == 0,
                 "This task is still being used somewhere else. You cannot send it now. Go fix your code! (use --cfg=msg/debug_multiple_use:on to get the backtrace of the other process)");
    }
  }

  if (msg_global->debug_multiple_use)
    MSG_BT(t_simdata->isused, "Using Backtrace");
  else
    t_simdata->isused = (void*)1;
  t_simdata->comm = NULL;
  msg_global->sent_msg++;

  /* Send it by calling SIMIX network layer */
  smx_synchro_t act = simcall_comm_isend(SIMIX_process_self(), mailbox, t_simdata->bytes_amount,
                                        t_simdata->rate, task, sizeof(void *),
                                        match_fun, cleanup, NULL, match_data,detached);
  t_simdata->comm = act; /* FIXME: is the field t_simdata->comm still useful? */

  msg_comm_t comm;
  if (detached) {
    comm = NULL;
  } else {
    comm = xbt_new0(s_msg_comm_t, 1);
    comm->task_sent = task;
    comm->task_received = NULL;
    comm->status = MSG_OK;
    comm->s_comm = act;
  }

  if (TRACE_is_enabled())
    simcall_set_category(act, task->category);
  if (call_end)
    TRACE_msg_task_put_end();

  return comm;
}