Esempio n. 1
0
/** Creates a new swag.
 * \param offset where the hookup is located in the structure
 * \see xbt_swag_offset
 *
 * Usage : xbt_swag_new(&obj.setA-&obj);
 */
XBT_INLINE xbt_swag_t xbt_swag_new(size_t offset)
{
  xbt_swag_t swag = xbt_new0(s_xbt_swag_t, 1);

  xbt_swag_init(swag, offset);

  return swag;
}
Esempio n. 2
0
lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id,
                                    double bound_value)
{
  lmm_constraint_t cnst = NULL;
  s_lmm_element_t elem;

  cnst = xbt_new0(s_lmm_constraint_t, 1);
  cnst->id = id;
  cnst->id_int = Global_const_debug_id++;
  xbt_swag_init(&(cnst->element_set),
                xbt_swag_offset(elem, element_set_hookup));
  xbt_swag_init(&(cnst->active_element_set),
                xbt_swag_offset(elem, active_element_set_hookup));

  cnst->bound = bound_value;
  cnst->usage = 0;
  cnst->shared = 1;
  insert_constraint(sys, cnst);

  return cnst;
}
Esempio n. 3
0
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;
}
Esempio n. 4
0
lmm_constraint_t lmm_constraint_new(lmm_system_t sys, void *id, double bound_value)
{
  lmm_constraint_t cnst = nullptr;
  s_lmm_element_t elem;

  cnst = xbt_new0(s_lmm_constraint_t, 1);
  cnst->id = id;
  cnst->id_int = Global_const_debug_id++;
  xbt_swag_init(&(cnst->enabled_element_set), xbt_swag_offset(elem, enabled_element_set_hookup));
  xbt_swag_init(&(cnst->disabled_element_set), xbt_swag_offset(elem, disabled_element_set_hookup));
  xbt_swag_init(&(cnst->active_element_set), xbt_swag_offset(elem, active_element_set_hookup));

  cnst->bound = bound_value;
  cnst->concurrency_maximum=0;
  cnst->concurrency_current=0;
  cnst->concurrency_limit=sg_concurrency_limit;
  cnst->usage = 0;
  cnst->sharing_policy = 1; /* FIXME: don't hardcode the value */
  insert_constraint(sys, cnst);

  return cnst;
}
void bottleneck_solve(lmm_system_t sys)
{
  void *_var, *_var_next, *_cnst, *_cnst_next, *_elem;
  lmm_variable_t var = nullptr;
  lmm_constraint_t cnst = nullptr;
  s_lmm_constraint_t s_cnst;
  lmm_element_t elem = nullptr;
  xbt_swag_t cnst_list = nullptr;
  xbt_swag_t var_list = nullptr;
  xbt_swag_t elem_list = nullptr;
  int i;

  static s_xbt_swag_t cnst_to_update;

  if (!(sys->modified))
    return;

  /* Init */
  xbt_swag_init(&(cnst_to_update),
                xbt_swag_offset(s_cnst, saturated_constraint_set_hookup));

  var_list = &(sys->variable_set);
  XBT_DEBUG("Variable set : %d", xbt_swag_size(var_list));
  xbt_swag_foreach(_var, var_list) {
  var = (lmm_variable_t)_var;
    int nb = 0;
    var->value = 0.0;
    XBT_DEBUG("Handling variable %p", var);
    xbt_swag_insert(var, &(sys->saturated_variable_set));
    for (i = 0; i < var->cnsts_number; i++) {
      if (var->cnsts[i].value == 0.0)
        nb++;
    }
    if ((nb == var->cnsts_number) && (var->weight > 0.0)) {
      XBT_DEBUG("Err, finally, there is no need to take care of variable %p",
             var);
      xbt_swag_remove(var, &(sys->saturated_variable_set));
      var->value = 1.0;
    }
    if (var->weight <= 0.0) {
      XBT_DEBUG("Err, finally, there is no need to take care of variable %p",
             var);
      xbt_swag_remove(var, &(sys->saturated_variable_set));
    }
  }