Beispiel #1
0
CpuCas01Model::CpuCas01Model() : simgrid::surf::CpuModel()
{
  char *optim = xbt_cfg_get_string("cpu/optim");
  bool select = xbt_cfg_get_boolean("cpu/maxmin-selective-update");

  if (!strcmp(optim, "Full")) {
    updateMechanism_ = UM_FULL;
    selectiveUpdate_ = select;
  } else if (!strcmp(optim, "Lazy")) {
    updateMechanism_ = UM_LAZY;
    selectiveUpdate_ = true;
    xbt_assert(select || (xbt_cfg_is_default_value("cpu/maxmin-selective-update")),
               "Disabling selective update while using the lazy update mechanism is dumb!");
  } else {
    xbt_die("Unsupported optimization (%s) for this model", optim);
  }

  p_cpuRunningActionSetThatDoesNotNeedBeingChecked = new ActionList();
  maxminSystem_ = lmm_system_new(selectiveUpdate_);

  if (getUpdateMechanism() == UM_LAZY) {
    actionHeap_ = xbt_heap_new(8, nullptr);
    xbt_heap_set_update_callback(actionHeap_,  surf_action_lmm_update_index_heap);
    modifiedSet_ = new ActionLmmList();
    maxminSystem_->keep_track = modifiedSet_;
  }
}
Beispiel #2
0
static void surf_new_model_init_internal(void)
{
    s_surf_action_t action;

    XBT_DEBUG("surf_new_model_model_init_internal");
    surf_new_model = surf_model_init();

    new_model_running_action_set_that_does_not_need_being_checked =
        xbt_swag_new(xbt_swag_offset(action, state_hookup));

    surf_new_model->name = "New Model";
    surf_new_model->action_unref = new_model_action_unref;
    surf_new_model->action_cancel = new_model_action_cancel;
    surf_new_model->action_state_set = new_model_action_state_set;

    surf_new_model->model_private->finalize = new_model_finalize;
    surf_new_model->model_private->update_actions_state = new_model_update_actions_state;
    surf_new_model->model_private->share_resources = new_model_share_resources;
    surf_new_model->model_private->resource_used = new_model_resource_used;
    surf_new_model->model_private->update_resource_state = new_model_resources_state;

    surf_new_model->suspend = new_model_action_suspend;
    surf_new_model->resume = new_model_action_resume;
    surf_new_model->is_suspended = new_model_action_is_suspended;
    surf_new_model->set_max_duration = new_model_action_set_max_duration;
    surf_new_model->set_priority = new_model_action_set_priority;

    surf_new_model->extension.new_model.fct = new_model_action_fct;
    surf_new_model->extension.new_model.create_resource = new_model_create_resource;

    if (!new_model_maxmin_system) {
        new_model_maxmin_system = lmm_system_new(new_model_selective_update);
    }

}
Beispiel #3
0
StorageN11Model::StorageN11Model() : StorageModel() {
  Action *action = nullptr;

  XBT_DEBUG("surf_storage_model_init_internal");

  storage_running_action_set_that_does_not_need_being_checked = xbt_swag_new(xbt_swag_offset(*action, stateHookup_));
  if (!maxminSystem_) {
    maxminSystem_ = lmm_system_new(storage_selective_update);
  }
}
WorkstationL07Model::WorkstationL07Model() : WorkstationModel("Workstation ptask_L07") {
  if (!ptask_maxmin_system)
	ptask_maxmin_system = lmm_system_new(1);
  surf_workstation_model = NULL;
  surf_network_model = new NetworkL07Model();
  surf_cpu_model_pm = new CpuL07Model();
  routing_model_create(surf_network_model->createNetworkLink("__loopback__",
	                                                  498000000, NULL,
	                                                  0.000015, NULL,
	                                                  SURF_RESOURCE_ON, NULL,
	                                                  SURF_LINK_FATPIPE, NULL));
  p_cpuModel = surf_cpu_model_pm;
}
Beispiel #5
0
CpuCas01Model::CpuCas01Model() : CpuModel("cpu")
{
  char *optim = xbt_cfg_get_string(_sg_cfg_set, "cpu/optim");
  int select = xbt_cfg_get_boolean(_sg_cfg_set, "cpu/maxmin_selective_update");

  if (!strcmp(optim, "Full")) {
    p_updateMechanism = UM_FULL;
    m_selectiveUpdate = select;
  } else if (!strcmp(optim, "Lazy")) {
    p_updateMechanism = UM_LAZY;
    m_selectiveUpdate = 1;
    xbt_assert((select == 1)
               ||
               (xbt_cfg_is_default_value
                (_sg_cfg_set, "cpu/maxmin_selective_update")),
               "Disabling selective update while using the lazy update mechanism is dumb!");
  } else {
    xbt_die("Unsupported optimization (%s) for this model", optim);
  }

  p_cpuRunningActionSetThatDoesNotNeedBeingChecked = new ActionList();

  if (getUpdateMechanism() == UM_LAZY) {
	shareResources = &CpuCas01Model::shareResourcesLazy;
	updateActionsState = &CpuCas01Model::updateActionsStateLazy;

  } else if (getUpdateMechanism() == UM_FULL) {
	shareResources = &CpuCas01Model::shareResourcesFull;
	updateActionsState = &CpuCas01Model::updateActionsStateFull;
  } else
    xbt_die("Invalid cpu update mechanism!");

  if (!p_maxminSystem) {
    p_maxminSystem = lmm_system_new(m_selectiveUpdate);
  }

  if (getUpdateMechanism() == UM_LAZY) {
    p_actionHeap = xbt_heap_new(8, NULL);
    xbt_heap_set_update_callback(p_actionHeap,  surf_action_lmm_update_index_heap);
    p_modifiedSet = new ActionLmmList();
    p_maxminSystem->keep_track = p_modifiedSet;
  }
}
Beispiel #6
0
void test(int nb_cnst, int nb_var, int nb_elem)
{
  lmm_system_t Sys = NULL;
  lmm_constraint_t *cnst = xbt_new0(lmm_constraint_t, nb_cnst);
  lmm_variable_t *var = xbt_new0(lmm_variable_t, nb_var);
  int *used = xbt_new0(int, nb_cnst);
  int i, j, k;

  Sys = lmm_system_new(1);

  for (i = 0; i < nb_cnst; i++) {
    cnst[i] = lmm_constraint_new(Sys, NULL, float_random(10.0));
  }

  for (i = 0; i < nb_var; i++) {
    var[i] = lmm_variable_new(Sys, NULL, 1.0, -1.0, nb_elem);
    for (j = 0; j < nb_cnst; j++)
      used[j] = 0;
    for (j = 0; j < nb_elem; j++) {
      k = int_random(nb_cnst);
      if (used[k]) {
        j--;
        continue;
      }
      lmm_expand(Sys, cnst[k], var[i], float_random(1.0));
      used[k] = 1;
    }
  }

  printf("Starting to solve\n");
  date = xbt_os_time() * 1000000;
  lmm_solve(Sys);
  date = xbt_os_time() * 1000000 - date;

  for (i = 0; i < nb_var; i++)
    lmm_variable_free(Sys, var[i]);
  lmm_system_free(Sys);
  free(cnst);
  free(var);
  free(used);
}
Beispiel #7
0
void NetworkCm02Model::initialize()
{
  char *optim = xbt_cfg_get_string(_sg_cfg_set, "network/optim");
  int select =
      xbt_cfg_get_boolean(_sg_cfg_set, "network/maxmin_selective_update");

  if (!strcmp(optim, "Full")) {
    p_updateMechanism = UM_FULL;
    m_selectiveUpdate = select;
  } else if (!strcmp(optim, "Lazy")) {
    p_updateMechanism = UM_LAZY;
    m_selectiveUpdate = 1;
    xbt_assert((select == 1)
               ||
               (xbt_cfg_is_default_value
                (_sg_cfg_set, "network/maxmin_selective_update")),
               "Disabling selective update while using the lazy update mechanism is dumb!");
  } else {
    xbt_die("Unsupported optimization (%s) for this model", optim);
  }

  if (!p_maxminSystem)
	p_maxminSystem = lmm_system_new(m_selectiveUpdate);

  const char* lb_name = "__loopback__";
  routing_model_create(createNetworkLink(lb_name,
	                                           498000000, NULL, 0.000015, NULL,
	                                           SURF_RESOURCE_ON, NULL,
	                                           SURF_LINK_FATPIPE, NULL));

  if (p_updateMechanism == UM_LAZY) {
	p_actionHeap = xbt_heap_new(8, NULL);
	xbt_heap_set_update_callback(p_actionHeap, surf_action_lmm_update_index_heap);
	p_modifiedSet = new ActionLmmList();
	p_maxminSystem->keep_track = p_modifiedSet;
  }

  m_haveGap = false;
}
Beispiel #8
0
static void test(int nb_cnst, int nb_var, int nb_elem, unsigned int pw_base_limit, unsigned int pw_max_limit,
                 float rate_no_limit, int max_share, int mode)
{
  lmm_system_t Sys = NULL;
  lmm_constraint_t *cnst = xbt_new0(lmm_constraint_t, nb_cnst);
  lmm_variable_t *var = xbt_new0(lmm_variable_t, nb_var);
  int *used = xbt_new0(int, nb_cnst);
  int i;
  int j;
  int k;
  int l;
  int concurrency_share;

  Sys = lmm_system_new(1);

  for (i = 0; i < nb_cnst; i++) {
    cnst[i] = lmm_constraint_new(Sys, NULL, float_random(10.0));
    if(rate_no_limit>float_random(1.0))
      //Look at what happens when there is no concurrency limit 
      l=-1;
    else
      //Badly logarithmically random concurrency limit in [2^pw_base_limit+1,2^pw_base_limit+2^pw_max_limit]
      l=(1<<pw_base_limit)+(1<<int_random(pw_max_limit));

    lmm_constraint_concurrency_limit_set(cnst[i],l );
  }

  for (i = 0; i < nb_var; i++) {
    var[i] = lmm_variable_new(Sys, NULL, 1.0, -1.0, nb_elem);
    //Have a few variables with a concurrency share of two (e.g. cross-traffic in some cases)
    concurrency_share=1+int_random(max_share);
    lmm_variable_concurrency_share_set(var[i],concurrency_share);

    for (j = 0; j < nb_cnst; j++)
      used[j] = 0;
    for (j = 0; j < nb_elem; j++) {
      k = int_random(nb_cnst);
      if (used[k]>=concurrency_share) {
        j--;
        continue;
      }
      lmm_expand(Sys, cnst[k], var[i], float_random(1.5));
      lmm_expand_add(Sys, cnst[k], var[i], float_random(1.5));
      used[k]++;
    }
  }

  fprintf(stderr,"Starting to solve(%i)\n",myrand()%1000);
  date = xbt_os_time() * 1000000;
  lmm_solve(Sys);
  date = xbt_os_time() * 1000000 - date;

  if(mode==2){
    fprintf(stderr,"Max concurrency:\n");
    l=0;
    for (i = 0; i < nb_cnst; i++) {
      j=lmm_constraint_concurrency_maximum_get(cnst[i]);
      k=lmm_constraint_concurrency_limit_get(cnst[i]);
      xbt_assert(k<0 || j<=k);
      if(j>l)
        l=j;
      fprintf(stderr,"(%i):%i/%i ",i,j,k);
      lmm_constraint_concurrency_maximum_reset(cnst[i]);
      xbt_assert(!lmm_constraint_concurrency_maximum_get(cnst[i]));
      if(i%10==9)
        fprintf(stderr,"\n");
    }
    fprintf(stderr,"\nTotal maximum concurrency is %i\n",l);

    lmm_print(Sys);
  }

  for (i = 0; i < nb_var; i++)
    lmm_variable_free(Sys, var[i]);
  lmm_system_free(Sys);
  free(cnst);
  free(var);
  free(used);
}