Ejemplo n.º 1
0
static xbt_dynar_t parse_factor(const char *smpi_coef_string)
{
  char *value = NULL;
  unsigned int iter = 0;
  s_smpi_factor_t fact;
  xbt_dynar_t smpi_factor, radical_elements, radical_elements2 = NULL;

  smpi_factor = xbt_dynar_new(sizeof(s_smpi_factor_t), NULL);
  radical_elements = xbt_str_split(smpi_coef_string, ";");
  xbt_dynar_foreach(radical_elements, iter, value) {

    radical_elements2 = xbt_str_split(value, ":");
    surf_parse_assert(xbt_dynar_length(radical_elements2) == 2,
        "Malformed radical '%s' for smpi factor. I was expecting something like 'a:b'", value);

    char *errmsg = bprintf("Invalid factor in chunk #%d: %%s", iter+1);
    fact.factor = xbt_str_parse_int(xbt_dynar_get_as(radical_elements2, 0, char *), errmsg);
    xbt_free(errmsg);
    fact.value = xbt_str_parse_double(xbt_dynar_get_as(radical_elements2, 1, char *), errmsg);
    errmsg = bprintf("Invalid factor value in chunk #%d: %%s", iter+1);
    xbt_free(errmsg);

    xbt_dynar_push_as(smpi_factor, s_smpi_factor_t, fact);
    XBT_DEBUG("smpi_factor:\t%ld : %f", fact.factor, fact.value);
    xbt_dynar_free(&radical_elements2);
  }
Ejemplo n.º 2
0
void STag_surfxml_link___ctn()
{
  simgrid::kernel::resource::LinkImpl* link = nullptr;
  switch (A_surfxml_link___ctn_direction) {
  case AU_surfxml_link___ctn_direction:
  case A_surfxml_link___ctn_direction_NONE:
    link = simgrid::s4u::Link::by_name(std::string(A_surfxml_link___ctn_id))->get_impl();
    break;
  case A_surfxml_link___ctn_direction_UP:
    link = simgrid::s4u::Link::by_name(std::string(A_surfxml_link___ctn_id) + "_UP")->get_impl();
    break;
  case A_surfxml_link___ctn_direction_DOWN:
    link = simgrid::s4u::Link::by_name(std::string(A_surfxml_link___ctn_id) + "_DOWN")->get_impl();
    break;
  default:
    surf_parse_error(std::string("Invalid direction for link ") + A_surfxml_link___ctn_id);
    break;
  }

  const char* dirname = "";
  switch (A_surfxml_link___ctn_direction) {
    case A_surfxml_link___ctn_direction_UP:
      dirname = " (upward)";
      break;
    case A_surfxml_link___ctn_direction_DOWN:
      dirname = " (downward)";
      break;
    default:
      dirname = "";
  }
  surf_parse_assert(link != nullptr, std::string("No such link: '") + A_surfxml_link___ctn_id + "'" + dirname);
  parsed_link_list.push_back(link);
}