Ejemplo n.º 1
0
//dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
void TRACE_paje_dump_buffer (int force)
{
  if (!TRACE_is_enabled())
    return;
  XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
  if (force){
    for (auto event :buffer){
      event->print (event);
      event->free (event);
    }
    buffer.clear();
  }else{
    std::vector<paje_event_t>::iterator i = buffer.begin();
    for (auto event :buffer){
      double head_timestamp = event->timestamp;
      if (head_timestamp > TRACE_last_timestamp_to_dump)
        break;
      event->print (event);
      event->free (event);
      ++i;
    }
    buffer.erase(buffer.begin(), i);
  }
  XBT_DEBUG("%s: ends", __FUNCTION__);
}
Ejemplo n.º 2
0
//dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
void TRACE_paje_dump_buffer(bool force)
{
  if (not TRACE_is_enabled())
    return;
  XBT_DEBUG("%s: dump until %f. starts", __func__, TRACE_last_timestamp_to_dump);
  if (force){
    for (auto const& event : buffer) {
      event->print();
      delete event;
    }
    buffer.clear();
  } else {
    std::vector<simgrid::instr::PajeEvent*>::iterator i = buffer.begin();
    for (auto const& event : buffer) {
      double head_timestamp = event->timestamp_;
      if (head_timestamp > TRACE_last_timestamp_to_dump)
        break;
      event->print();
      delete event;
      ++i;
    }
    buffer.erase(buffer.begin(), i);
  }
  XBT_DEBUG("%s: ends", __func__);
}
Ejemplo n.º 3
0
int TRACE_start()
{
  TRACE_getopts();

  // tracing system must be:
  //    - enabled (with --cfg=tracing:1)
  //    - already configured (TRACE_global_init already called)
  if (!(TRACE_is_enabled() && TRACE_is_configured())){
    return 0;
  }

  XBT_DEBUG("Tracing starts");

  /* open the trace file */
  TRACE_paje_start();

  /* activate trace */
  if (trace_active == 1){
    THROWF (tracing_error, 0, "Tracing is already active");
  }
  trace_active = 1;
  XBT_DEBUG ("Tracing is on");

  /* other trace initialization */
  created_categories = xbt_dict_new_homogeneous(xbt_free);
  declared_marks = xbt_dict_new_homogeneous (xbt_free);
  user_host_variables = xbt_dict_new_homogeneous (xbt_free);
  user_link_variables = xbt_dict_new_homogeneous (xbt_free);
  TRACE_surf_alloc();
  TRACE_smpi_alloc();
  return 0;
}
Ejemplo n.º 4
0
/* 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;
}
Ejemplo n.º 5
0
/*********
 * Model *
 *********/
void CpuModel::updateActionsStateLazy(double now, double /*delta*/)
{
  CpuAction *action;
  while ((xbt_heap_size(getActionHeap()) > 0)
         && (double_equals(xbt_heap_maxkey(getActionHeap()), now, sg_surf_precision))) {
    action = static_cast<CpuAction*>(xbt_heap_pop(getActionHeap()));
    XBT_CDEBUG(surf_kernel, "Something happened to action %p", action);
    if (TRACE_is_enabled()) {
      Cpu *cpu = static_cast<Cpu*>(lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)));
      TRACE_surf_host_set_utilization(cpu->getName(), action->getCategory(),
                                      lmm_variable_getvalue(action->getVariable()),
                                      action->getLastUpdate(),
                                      now - action->getLastUpdate());
    }

    action->finish();
    XBT_CDEBUG(surf_kernel, "Action %p finished", action);

    /* set the remains to 0 due to precision problems when updating the remaining amount */
    action->setRemains(0);
    action->setState(SURF_ACTION_DONE);
    action->heapRemove(getActionHeap()); //FIXME: strange call since action was already popped
  }
  if (TRACE_is_enabled()) {
    //defining the last timestamp that we can safely dump to trace file
    //without losing the event ascending order (considering all CPU's)
    double smaller = -1;
    ActionList *actionSet = getRunningActionSet();
    for(ActionList::iterator it(actionSet->begin()), itend(actionSet->end())
       ; it != itend ; ++it) {
      action = static_cast<CpuAction*>(&*it);
        if (smaller < 0) {
          smaller = action->getLastUpdate();
          continue;
        }
        if (action->getLastUpdate() < smaller) {
          smaller = action->getLastUpdate();
        }
    }
    if (smaller > 0) {
      TRACE_last_timestamp_to_dump = smaller;
    }
  }
  return;
}
Ejemplo n.º 6
0
// This function can be called from extern file, to initialize logs, options, and processes of smpi
// without the need of smpirun
void SMPI_init(){
  smpi_init_logs();
  smpi_init_options();
  smpi_global_init();
  smpi_check_options();
  if (TRACE_is_enabled() && TRACE_is_configured())
    TRACE_smpi_alloc();
  if(smpi_privatize_global_variables)
    smpi_initialize_global_memory_segments();
}
Ejemplo n.º 7
0
static xbt_dynar_t instr_dict_to_dynar (xbt_dict_t filter)
{
  if (!TRACE_is_enabled()) return NULL;
  if (!TRACE_needs_platform()) return NULL;

  xbt_dynar_t ret = xbt_dynar_new (sizeof(char*), &xbt_free_ref);
  xbt_dict_cursor_t cursor = NULL;
  char *name, *value;
  xbt_dict_foreach(filter, cursor, name, value) {
    xbt_dynar_push_as (ret, char*, xbt_strdup(name));
  }
Ejemplo n.º 8
0
void instr_pause_tracing (void)
{
  previous_trace_state = trace_enabled;
  if (!TRACE_is_enabled()){
    XBT_DEBUG ("Tracing is already paused, therefore do nothing.");
  }else{
    XBT_DEBUG ("Tracing is being paused.");
  }
  trace_enabled = 0;
  XBT_DEBUG ("Tracing is paused.");
}
Ejemplo n.º 9
0
void TRACE_surf_action(surf_action_t surf_action, const char *category)
{
  if (!TRACE_is_enabled())
    return;
  if (!TRACE_categorized ())
    return;
  if (!category)
    return;

  surf_action_set_category(surf_action, category);
}
Ejemplo n.º 10
0
void TRACE_surf_action(surf_action_t surf_action, const char *category)
{
  if (!TRACE_is_enabled())
    return;
  if (!TRACE_categorized ())
    return;
  if (!category)
    return;

  surf_action->category = xbt_strdup(category);
}
Ejemplo n.º 11
0
void NetworkCm02Model::updateActionsStateLazy(double now, double /*delta*/)
{
  NetworkCm02ActionPtr action;
  while ((xbt_heap_size(p_actionHeap) > 0)
         && (double_equals(xbt_heap_maxkey(p_actionHeap), now, sg_surf_precision))) {
    action = (NetworkCm02ActionPtr) xbt_heap_pop(p_actionHeap);
    XBT_DEBUG("Something happened to action %p", action);
#ifdef HAVE_TRACING
    if (TRACE_is_enabled()) {
      int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->getVariable());
      int i;
      for (i = 0; i < n; i++){
        lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem,
                                                            action->getVariable(),
                                                            i);
        NetworkCm02LinkPtr link = static_cast<NetworkCm02LinkPtr>(lmm_constraint_id(constraint));
        TRACE_surf_link_set_utilization(link->getName(),
                                        action->getCategory(),
                                        (lmm_variable_getvalue(action->getVariable())*
                                            lmm_get_cnst_weight_from_var(p_maxminSystem,
                                                action->getVariable(),
                                                i)),
                                        action->getLastUpdate(),
                                        now - action->getLastUpdate());
      }
    }
#endif

    // if I am wearing a latency hat
    if (action->getHat() == LATENCY) {
      XBT_DEBUG("Latency paid for action %p. Activating", action);
      lmm_update_variable_weight(p_maxminSystem, action->getVariable(), action->m_weight);
      action->heapRemove(p_actionHeap);
      action->refreshLastUpdate();

        // if I am wearing a max_duration or normal hat
    } else if (action->getHat() == MAX_DURATION ||
        action->getHat() == NORMAL) {
        // no need to communicate anymore
        // assume that flows that reached max_duration have remaining of 0
      XBT_DEBUG("Action %p finished", action);
      action->setRemains(0);
      action->finish();
      action->setState(SURF_ACTION_DONE);
      action->heapRemove(p_actionHeap);

      action->gapRemove();
    }
  }
  return;
}
Ejemplo n.º 12
0
//dumps the trace file until the timestamp TRACE_last_timestamp_to_dump
void TRACE_paje_dump_buffer (int force)
{
  if (!TRACE_is_enabled()) return;
  XBT_DEBUG("%s: dump until %f. starts", __FUNCTION__, TRACE_last_timestamp_to_dump);
  if (force){
    paje_event_t event;
    unsigned int i;
    xbt_dynar_foreach(buffer, i, event){
      event->print (event);
      event->free (event);
    }
    xbt_dynar_free (&buffer);
    buffer = xbt_dynar_new (sizeof(paje_event_t), NULL);
  }else{
Ejemplo n.º 13
0
void instr_resume_tracing (void)
{
  if (TRACE_is_enabled()){
    XBT_DEBUG ("Tracing is already running while trying to resume, therefore do nothing.");
  }else{
    XBT_DEBUG ("Tracing is being resumed.");
  }

  if (previous_trace_state != -1){
    trace_enabled = previous_trace_state;
  }else{
    trace_enabled = 1;
  }
  XBT_DEBUG ("Tracing is resumed.");
  previous_trace_state = -1;
}
Ejemplo n.º 14
0
/** \ingroup msg_task_usage
 * \brief Sends a task on a mailbox, with support for matching requests
 *
 * This is a non blocking function: use MSG_comm_wait() or MSG_comm_test()
 * to end the communication.
 *
 * \param task a #msg_task_t to send on another location.
 * \param alias name of the mailbox to sent the task to
 * \param match_fun boolean function which parameters are:
 *        - match_data_provided_here
 *        - match_data_provided_by_other_side_if_any
 *        - the_smx_action_describing_the_other_side
 * \param match_data user provided data passed to match_fun
 * \return the msg_comm_t communication created
 */
XBT_INLINE msg_comm_t MSG_task_isend_with_matching(msg_task_t task, const char *alias,
    int (*match_fun)(void*,void*, smx_action_t),
    void *match_data)
{
  simdata_task_t t_simdata = NULL;
  msg_process_t process = MSG_process_self();
  msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);

#ifdef HAVE_TRACING
  int call_end = TRACE_msg_task_put_start(task);
#endif

  /* 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;

  xbt_assert(t_simdata->isused == 0,
              "This task is still being used somewhere else. You cannot send it now. Go fix your code!");

  t_simdata->isused = 1;
  t_simdata->comm = NULL;
  msg_global->sent_msg++;

  /* Send it by calling SIMIX network layer */
  msg_comm_t comm = xbt_new0(s_msg_comm_t, 1);
  comm->task_sent = task;
  comm->task_received = NULL;
  comm->status = MSG_OK;
  comm->s_comm =
    simcall_comm_isend(mailbox, t_simdata->message_size,
                         t_simdata->rate, task, sizeof(void *), match_fun, NULL, match_data, 0);
  t_simdata->comm = comm->s_comm; /* FIXME: is the field t_simdata->comm still useful? */
#ifdef HAVE_TRACING
    if (TRACE_is_enabled()) {
      simcall_set_category(comm->s_comm, task->category);
    }
#endif

#ifdef HAVE_TRACING
  if (call_end)
    TRACE_msg_task_put_end();
#endif

  return comm;
}
Ejemplo n.º 15
0
/* Internal function used to factorize code between MSG_task_isend_with_matching() and MSG_task_dsend(). */
static 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 = nullptr;
  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())->m_host;
  t_simdata->setUsed();
  t_simdata->comm = nullptr;
  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, nullptr, match_data,detached);
  t_simdata->comm = static_cast<simgrid::simix::Comm*>(act); /* FIXME: is the field t_simdata->comm still useful? */

  msg_comm_t comm;
  if (detached) {
    comm = nullptr;
  } else {
    comm = xbt_new0(s_msg_comm_t, 1);
    comm->task_sent = task;
    comm->task_received = nullptr;
    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;
}
Ejemplo n.º 16
0
void CpuModel::updateActionsStateFull(double now, double delta)
{
  CpuAction *action = NULL;
  ActionList *running_actions = getRunningActionSet();

  for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end())
     ; it != itend ; it=itNext) {
	++itNext;
    action = static_cast<CpuAction*>(&*it);
    if (TRACE_is_enabled()) {
      Cpu *x = static_cast<Cpu*> (lmm_constraint_id(lmm_get_cnst_from_var(getMaxminSystem(), action->getVariable(), 0)) );

      TRACE_surf_host_set_utilization(x->getName(),
                                      action->getCategory(),
                                      lmm_variable_getvalue(action->getVariable()),
                                      now - delta,
                                      delta);
      TRACE_last_timestamp_to_dump = now - delta;
    }

    action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);


    if (action->getMaxDuration() != NO_MAX_DURATION)
      action->updateMaxDuration(delta);


    if ((action->getRemainsNoUpdate() <= 0) &&
        (lmm_get_variable_weight(action->getVariable()) > 0)) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
    } else if ((action->getMaxDuration() != NO_MAX_DURATION) &&
               (action->getMaxDuration() <= 0)) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
    }
  }

  return;
}
Ejemplo n.º 17
0
/** \ingroup msg_task_usage
 * \brief Sends a task on a mailbox with a maximal rate.
 *
 * This is a non blocking detached send function.
 * Think of it as a best effort send. Keep in mind that the third parameter
 * is only called if the communication fails. If the communication does work,
 * it is responsibility of the receiver code to free anything related to
 * the task, as usual. More details on this can be obtained on
 * <a href="http://lists.gforge.inria.fr/pipermail/simgrid-user/2011-November/002649.html">this thread</a>
 * in the SimGrid-user mailing list archive.
 *
 * \param task a #msg_task_t to send on another location.
 * \param alias name of the mailbox to sent the task to
 * \param cleanup a function to destroy the task if the
 * communication fails, e.g. MSG_task_destroy
 * (if NULL, no function will be called)
 * \param maxrate the maximum communication rate for sending this task
 * 
 */
void MSG_task_dsend_bounded(msg_task_t task, const char *alias, void_f_pvoid_t cleanup, double maxrate)
{
  task->simdata->rate = maxrate;
  
  simdata_task_t t_simdata = NULL;
  msg_process_t process = MSG_process_self();
  msg_mailbox_t mailbox = MSG_mailbox_get_by_alias(alias);

  /* 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;

  xbt_assert(t_simdata->isused == 0,
              "This task is still being used somewhere else. You cannot send it now. Go fix your code!");

  t_simdata->isused = 1;
  t_simdata->comm = NULL;
  msg_global->sent_msg++;

#ifdef HAVE_TRACING
  int call_end = TRACE_msg_task_put_start(task);
#endif

  /* Send it by calling SIMIX network layer */
  smx_action_t comm = simcall_comm_isend(mailbox, t_simdata->message_size,
                       t_simdata->rate, task, sizeof(void *), NULL, cleanup, NULL, 1);
  t_simdata->comm = comm;
#ifdef HAVE_TRACING
    if (TRACE_is_enabled()) {
      simcall_set_category(comm, task->category);
    }
#endif

#ifdef HAVE_TRACING
  if (call_end)
    TRACE_msg_task_put_end();
#endif
}
Ejemplo n.º 18
0
void generic_update_action_remaining_lazy( surf_action_lmm_t action, double now)
{
  double delta = 0.0;
  surf_model_t model = action->generic_action.model_type;

  if(model == surf_network_model)
  {
    if (action->suspended != 0)
      return;
  }
  else
  {
    xbt_assert(action->generic_action.state_set == model->states.running_action_set,
        "You're updating an action that is not running.");

      /* bogus priority, skip it */
    xbt_assert(action->generic_action.priority > 0,
        "You're updating an action that seems suspended.");
  }

  delta = now - action->last_update;

  if (action->generic_action.remains > 0) {
    XBT_DEBUG("Updating action(%p): remains was %lf, last_update was: %lf", action, action->generic_action.remains, action->last_update);
    double_update(&(action->generic_action.remains),
        action->last_value * delta);

#ifdef HAVE_TRACING
    if (model == surf_cpu_model && TRACE_is_enabled()) {
      surf_resource_t cpu =
          lmm_constraint_id(lmm_get_cnst_from_var
              (model->model_private->maxmin_system,
                  action->variable, 0));
      TRACE_surf_host_set_utilization(cpu->name,
          action->generic_action.category,
          action->last_value,
          action->last_update,
          now - action->last_update);
    }
#endif
    XBT_DEBUG("Updating action(%p): remains is now %lf", action,
        action->generic_action.remains);
  }

  if(model == surf_network_model)
  {
    if (((surf_action_t)action)->max_duration != NO_MAX_DURATION)
      double_update(&(((surf_action_t)action)->max_duration), delta);

    if ((((surf_action_t)action)->remains <= 0) &&
        (lmm_get_variable_weight(action->variable) > 0)) {
      ((surf_action_t)action)->finish = surf_get_clock();
      model->action_state_set((surf_action_t) action,
          SURF_ACTION_DONE);

      surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action);
    } else if (((((surf_action_t)action)->max_duration != NO_MAX_DURATION)
        && (((surf_action_t)action)->max_duration <= 0))) {
      ((surf_action_t)action)->finish = surf_get_clock();
      model->action_state_set((surf_action_t) action,
          SURF_ACTION_DONE);
      surf_action_lmm_heap_remove(model->model_private->action_heap,(surf_action_lmm_t)action);
    }
  }

  action->last_update = now;
  action->last_value = lmm_variable_getvalue(action->variable);
}
Ejemplo n.º 19
0
void generic_update_actions_state_lazy(double now, double delta, surf_model_t model)
{
  surf_action_lmm_t action;
  while ((xbt_heap_size(model->model_private->action_heap) > 0)
         && (double_equals(xbt_heap_maxkey(model->model_private->action_heap), now))) {
    action = xbt_heap_pop(model->model_private->action_heap);
    XBT_DEBUG("Something happened to action %p", action);
#ifdef HAVE_TRACING
    if (TRACE_is_enabled()) {
      if(model == surf_cpu_model){
      surf_resource_t cpu =
          lmm_constraint_id(lmm_get_cnst_from_var
                            (model->model_private->maxmin_system,
                             action->variable, 0));
      TRACE_surf_host_set_utilization(cpu->name,
                                      ((surf_action_t)action)->category,
                                      lmm_variable_getvalue(action->variable),
                                      action->last_update,
                                      now - action->last_update);
      }
      else{
        int n = lmm_get_number_of_cnst_from_var(model->model_private->maxmin_system, action->variable);
        unsigned int i;
        for (i = 0; i < n; i++){
          lmm_constraint_t constraint = lmm_get_cnst_from_var(model->model_private->maxmin_system,
                                                              action->variable,
                                                              i);
          link_CM02_t link = lmm_constraint_id(constraint);
          TRACE_surf_link_set_utilization(link->lmm_resource.generic_resource.name,
                                          ((surf_action_t)action)->category,
                                          (lmm_variable_getvalue(action->variable)*
                                              lmm_get_cnst_weight_from_var(model->model_private->maxmin_system,
                                                  action->variable,
                                                  i)),
                                          action->last_update,
                                          now - action->last_update);
        }
      }
    }
#endif

    if(model == surf_cpu_model){
      action->generic_action.finish = surf_get_clock();

      update_resource_energy(model, action);

      /* set the remains to 0 due to precision problems when updating the remaining amount */
      action->generic_action.remains = 0;
      surf_action_state_set((surf_action_t) action, SURF_ACTION_DONE);
      surf_action_lmm_heap_remove(model->model_private->action_heap,action); //FIXME: strange call since action was already popped
    }
    else{
      // if I am wearing a latency hat
      if (action->hat == LATENCY) {
        XBT_DEBUG("Latency paid for action %p. Activating", action);
        lmm_update_variable_weight(model->model_private->maxmin_system, action->variable,
            ((surf_action_network_CM02_t)(action))->weight);
        surf_action_lmm_heap_remove(model->model_private->action_heap,action);
        action->last_update = surf_get_clock();

        // if I am wearing a max_duration or normal hat
      } else if (action->hat == MAX_DURATION ||
          action->hat == NORMAL) {
        // no need to communicate anymore
        // assume that flows that reached max_duration have remaining of 0
      	action->generic_action.finish = surf_get_clock();
     	XBT_DEBUG("Action %p finished", action);
  	action->generic_action.remains = 0;
        ((surf_action_t)action)->finish = surf_get_clock();
        model->action_state_set((surf_action_t) action,
                                             SURF_ACTION_DONE);
        surf_action_lmm_heap_remove(model->model_private->action_heap,action);

        if (model->gap_remove && model == surf_network_model)
          model->gap_remove(action);
      }
    }
  }
#ifdef HAVE_TRACING
  if (TRACE_is_enabled() && model == surf_cpu_model) {
    //defining the last timestamp that we can safely dump to trace file
    //without losing the event ascending order (considering all CPU's)
    double smaller = -1;
    xbt_swag_t running_actions = model->states.running_action_set;
    xbt_swag_foreach(action, running_actions) {
        if (smaller < 0) {
          smaller = action->last_update;
          continue;
        }
        if (action->last_update < smaller) {
          smaller = action->last_update;
        }
    }
    if (smaller > 0) {
      TRACE_last_timestamp_to_dump = smaller;
    }
  }
Ejemplo n.º 20
0
int TRACE_basic (void)
{
  return trace_basic && TRACE_is_enabled();
}
Ejemplo n.º 21
0
int TRACE_disable_destroy (void)
{
  return trace_disable_destroy && TRACE_is_enabled();
}
Ejemplo n.º 22
0
int TRACE_onelink_only (void)
{
  return trace_onelink_only && TRACE_is_enabled();
}
Ejemplo n.º 23
0
int TRACE_buffer (void)
{
  return trace_buffer && TRACE_is_enabled();
}
Ejemplo n.º 24
0
int TRACE_msg_process_is_enabled(void)
{
  return trace_msg_process_enabled && TRACE_is_enabled();
}
Ejemplo n.º 25
0
int TRACE_smpi_is_enabled(void)
{
  return (trace_smpi_enabled || TRACE_smpi_is_grouped())
    && TRACE_is_enabled();
}
Ejemplo n.º 26
0
msg_error_t
MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task,
                             double timeout)
{
  msg_error_t ret = MSG_OK;
  simdata_task_t t_simdata = NULL;
  msg_process_t process = MSG_process_self();
  simdata_process_t p_simdata = SIMIX_process_self_get_data(process);

  int call_end = TRACE_msg_task_put_start(task);    //must be after CHECK_HOST()

  /* 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++;


  p_simdata->waiting_task = task;

  xbt_ex_t e;
  /* Try to send it by calling SIMIX network layer */
  TRY {
    smx_synchro_t comm = NULL; /* MC needs the comm to be set to NULL during the simix call  */
    comm = simcall_comm_isend(SIMIX_process_self(), mailbox,t_simdata->bytes_amount,
                                  t_simdata->rate, task, sizeof(void *),
                                  NULL, NULL, NULL, task, 0);
    if (TRACE_is_enabled())
      simcall_set_category(comm, task->category);
     t_simdata->comm = comm;
     simcall_comm_wait(comm, timeout);
  }

  CATCH(e) {
    switch (e.category) {
    case cancel_error:
      ret = MSG_HOST_FAILURE;
      break;
    case network_error:
      ret = MSG_TRANSFER_FAILURE;
      break;
    case timeout_error:
      ret = MSG_TIMEOUT;
      break;
    default:
      RETHROW;
    }
    xbt_ex_free(e);

    /* If the send failed, it is not used anymore */
    if (msg_global->debug_multiple_use && t_simdata->isused!=0)
      xbt_ex_free(*(xbt_ex_t*)t_simdata->isused);
    t_simdata->isused = 0;
  }


  p_simdata->waiting_task = NULL;
  if (call_end)
    TRACE_msg_task_put_end();
  MSG_RETURN(ret);
}
Ejemplo n.º 27
0
void NetworkCm02Model::updateActionsStateFull(double now, double delta)
{
  NetworkCm02ActionPtr action;
  ActionListPtr running_actions = getRunningActionSet();

  for(ActionList::iterator it(running_actions->begin()), itNext=it, itend(running_actions->end())
     ; it != itend ; it=itNext) {
	++itNext;

    action = (NetworkCm02ActionPtr) &*it;
    XBT_DEBUG("Something happened to action %p", action);
      double deltap = delta;
      if (action->m_latency > 0) {
        if (action->m_latency > deltap) {
          double_update(&(action->m_latency), deltap, sg_surf_precision);
          deltap = 0.0;
        } else {
          double_update(&(deltap), action->m_latency, sg_surf_precision);
          action->m_latency = 0.0;
        }
        if (action->m_latency == 0.0 && !(action->isSuspended()))
          lmm_update_variable_weight(p_maxminSystem, action->getVariable(),
              action->m_weight);
      }
  #ifdef HAVE_TRACING
      if (TRACE_is_enabled()) {
        int n = lmm_get_number_of_cnst_from_var(p_maxminSystem, action->getVariable());
        int i;
        for (i = 0; i < n; i++){
          lmm_constraint_t constraint = lmm_get_cnst_from_var(p_maxminSystem,
                                                            action->getVariable(),
                                                            i);
          NetworkCm02LinkPtr link = static_cast<NetworkCm02LinkPtr>(lmm_constraint_id(constraint));
          TRACE_surf_link_set_utilization(link->getName(),
                                        action->getCategory(),
                                        (lmm_variable_getvalue(action->getVariable())*
                                            lmm_get_cnst_weight_from_var(p_maxminSystem,
                                                action->getVariable(),
                                                i)),
                                        action->getLastUpdate(),
                                        now - action->getLastUpdate());
        }
      }
  #endif
      if (!lmm_get_number_of_cnst_from_var
          (p_maxminSystem, action->getVariable())) {
        /* There is actually no link used, hence an infinite bandwidth.
         * This happens often when using models like vivaldi.
         * In such case, just make sure that the action completes immediately.
         */
        action->updateRemains(action->getRemains());
      }
    action->updateRemains(lmm_variable_getvalue(action->getVariable()) * delta);
                  
    if (action->getMaxDuration() != NO_MAX_DURATION)
      action->updateMaxDuration(delta);
      
    if ((action->getRemains() <= 0) &&
        (lmm_get_variable_weight(action->getVariable()) > 0)) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
      action->gapRemove();
    } else if (((action->getMaxDuration() != NO_MAX_DURATION)
        && (action->getMaxDuration() <= 0))) {
      action->finish();
      action->setState(SURF_ACTION_DONE);
      action->gapRemove();
    }
  }
  return;
}
Ejemplo n.º 28
0
msg_error_t
MSG_mailbox_put_with_timeout(msg_mailbox_t mailbox, msg_task_t task,
                             double timeout)
{
  xbt_ex_t e;
  msg_error_t ret = MSG_OK;
  simdata_task_t t_simdata = NULL;
  msg_process_t process = MSG_process_self();
  simdata_process_t p_simdata = SIMIX_process_self_get_data(process);

#ifdef HAVE_TRACING
  int call_end = TRACE_msg_task_put_start(task);    //must be after CHECK_HOST()
#endif

  /* 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;

  xbt_assert(t_simdata->isused == 0,
              "This task is still being used somewhere else. You cannot send it now. Go fix your code!");

  t_simdata->isused=1;
  t_simdata->comm = NULL;
  msg_global->sent_msg++;


  p_simdata->waiting_task = task;

  /* Try to send it by calling SIMIX network layer */
  TRY {
      smx_action_t comm = simcall_comm_isend(mailbox, t_simdata->message_size,
                                  t_simdata->rate, task, sizeof(void *),
                                  NULL, NULL, task, 0);
#ifdef HAVE_TRACING
    if (TRACE_is_enabled()) {
      simcall_set_category(comm, task->category);
    }
#endif
     t_simdata->comm = comm;
     simcall_comm_wait(comm, timeout);
  }

  CATCH(e) {
    switch (e.category) {
    case network_error:
      ret = MSG_TRANSFER_FAILURE;
      break;
    case timeout_error:
      ret = MSG_TIMEOUT;
      break;
    default:
      RETHROW;
    }
    xbt_ex_free(e);

    /* If the send failed, it is not used anymore */
    t_simdata->isused = 0;
  }


  p_simdata->waiting_task = NULL;
#ifdef HAVE_TRACING
  if (call_end)
    TRACE_msg_task_put_end();
#endif
  MSG_RETURN(ret);
}