Ejemplo n.º 1
0
void ETag_surfxml_link(){
  simgrid::kernel::routing::LinkCreationArgs link;

  link.properties          = current_property_set;
  current_property_set     = nullptr;

  link.id                  = std::string(A_surfxml_link_id);
  link.bandwidth           = surf_parse_get_bandwidth(A_surfxml_link_bandwidth, "bandwidth of link", link.id.c_str());
  link.bandwidth_trace     = A_surfxml_link_bandwidth___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_bandwidth___file) : nullptr;
  link.latency             = surf_parse_get_time(A_surfxml_link_latency, "latency of link", link.id.c_str());
  link.latency_trace       = A_surfxml_link_latency___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_latency___file) : nullptr;
  link.state_trace         = A_surfxml_link_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_link_state___file):nullptr;

  switch (A_surfxml_link_sharing___policy) {
  case A_surfxml_link_sharing___policy_SHARED:
    link.policy = simgrid::s4u::Link::SharingPolicy::SHARED;
    break;
  case A_surfxml_link_sharing___policy_FATPIPE:
    link.policy = simgrid::s4u::Link::SharingPolicy::FATPIPE;
    break;
  case A_surfxml_link_sharing___policy_FULLDUPLEX:
    XBT_WARN("FULLDUPLEX is now deprecated. Please update your platform file to use SPLITDUPLEX instead.");
    link.policy = simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX;
    break;
  case A_surfxml_link_sharing___policy_SPLITDUPLEX:
    link.policy = simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX;
    break;
  default:
    surf_parse_error(std::string("Invalid sharing policy in link ") + link.id);
    break;
  }

  sg_platf_new_link(&link);
}
Ejemplo n.º 2
0
void AsCluster::create_links_for_node(sg_platf_cluster_cbarg_t cluster, int id, int , int position){
  s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
  s_surf_parsing_link_up_down_t info;
  char* link_id = bprintf("%s_link_%d", cluster->id, id);

  memset(&link, 0, sizeof(link));
  link.id = link_id;
  link.bandwidth = cluster->bw;
  link.latency = cluster->lat;
  link.policy = cluster->sharing_policy;
  sg_platf_new_link(&link);

  if (link.policy == SURF_LINK_FULLDUPLEX) {
    char *tmp_link = bprintf("%s_UP", link_id);
    info.link_up = sg_link_by_name(tmp_link);
    xbt_free(tmp_link);
    tmp_link = bprintf("%s_DOWN", link_id);
    info.link_down = sg_link_by_name(tmp_link);
    xbt_free(tmp_link);
  } else {
    info.link_up = sg_link_by_name(link_id);
    info.link_down = info.link_up;
  }
  xbt_dynar_set(upDownLinks, position, &info);
  xbt_free(link_id);
}
Ejemplo n.º 3
0
void ETag_surfxml_backbone(){
  simgrid::kernel::routing::LinkCreationArgs link;

  link.properties = nullptr;
  link.id = std::string(A_surfxml_backbone_id);
  link.bandwidth = surf_parse_get_bandwidth(A_surfxml_backbone_bandwidth, "bandwidth of backbone", link.id.c_str());
  link.latency = surf_parse_get_time(A_surfxml_backbone_latency, "latency of backbone", link.id.c_str());
  link.policy     = simgrid::s4u::Link::SharingPolicy::SHARED;

  sg_platf_new_link(&link);
  routing_cluster_add_backbone(simgrid::s4u::Link::by_name(std::string(A_surfxml_backbone_id))->get_impl());
}
Ejemplo n.º 4
0
int console_add_backbone(lua_State *L) {
  s_sg_platf_link_cbarg_t link;
  memset(&link,0,sizeof(link));
  int type;

  link.properties = nullptr;

  lua_ensure(lua_istable(L, -1),"Bad Arguments to create backbone in Lua. Should be a table with named arguments.");

  lua_pushstring(L, "id");
  type = lua_gettable(L, -2);
  lua_ensure(type == LUA_TSTRING, "Attribute 'id' must be specified for backbone and must be a string.");
  link.id = lua_tostring(L, -1);
  lua_pop(L, 1);

  lua_pushstring(L, "bandwidth");
  type = lua_gettable(L, -2);
  lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER,
      "Attribute 'bandwidth' must be specified for backbone and must either be a string (in the right format; see docs) or a number.");
  link.bandwidth = surf_parse_get_bandwidth(lua_tostring(L, -1),"bandwidth of backbone",link.id);
  lua_pop(L, 1);

  lua_pushstring(L, "lat");
  type = lua_gettable(L, -2);
  lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER,
      "Attribute 'lat' must be specified for backbone and must either be a string (in the right format; see docs) or a number.");
  link.latency = surf_parse_get_time(lua_tostring(L, -1),"latency of backbone",link.id);
  lua_pop(L, 1);

  lua_pushstring(L, "sharing_policy");
  type = lua_gettable(L, -2);
  const char* policy = lua_tostring(L, -1);
  if (policy && !strcmp(policy,"FULLDUPLEX")) {
    link.policy = SURF_LINK_FULLDUPLEX;
  } else if (policy && !strcmp(policy,"FATPIPE")) {
    link.policy = SURF_LINK_FATPIPE;
  } else {
    link.policy = SURF_LINK_SHARED;
  }

  sg_platf_new_link(&link);
  routing_cluster_add_backbone(sg_link_by_name(link.id));

  return 0;
}
Ejemplo n.º 5
0
void ClusterZone::create_links_for_node(ClusterCreationArgs* cluster, int id, int /*rank*/, unsigned int position)
{
  std::string link_id = cluster->id + "_link_" + std::to_string(id);

  LinkCreationArgs link;
  link.id        = link_id;
  link.bandwidth = cluster->bw;
  link.latency   = cluster->lat;
  link.policy    = cluster->sharing_policy;
  sg_platf_new_link(&link);

  s4u::Link* linkUp;
  s4u::Link* linkDown;
  if (link.policy == simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX) {
    linkUp   = s4u::Link::by_name(link_id + "_UP");
    linkDown = s4u::Link::by_name(link_id + "_DOWN");
  } else {
    linkUp   = s4u::Link::by_name(link_id);
    linkDown = linkUp;
  }
  private_links_.insert({position, {linkUp->get_impl(), linkDown->get_impl()}});
}
Ejemplo n.º 6
0
static int surf_parse_bypass_platform(void)
{
  sg_platf_begin();
  s_sg_platf_AS_cbarg_t AS = SG_PLATF_AS_INITIALIZER;
  AS.id = "AS0";
  AS.routing = A_surfxml_AS_routing_Full;
  sg_platf_new_AS_begin(&AS);

  s_sg_platf_host_cbarg_t bob = SG_PLATF_HOST_INITIALIZER;
  bob.id = "bob";
  bob.power_peak = xbt_dynar_new(sizeof(double), NULL);
  xbt_dynar_push_as(bob.power_peak, double, 98095000.0);
  sg_platf_new_host(&bob);

  s_sg_platf_host_cbarg_t alice = SG_PLATF_HOST_INITIALIZER;
  alice.id = "alice";
  alice.power_peak = xbt_dynar_new(sizeof(double), NULL);
  xbt_dynar_push_as(alice.power_peak, double, 98095000.0);
  sg_platf_new_host(&alice);

  s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
  link.id = "link1";
  link.latency = 0.000278066;
  link.bandwidth = 27946250;
  sg_platf_new_link(&link);

  s_sg_platf_route_cbarg_t route= SG_PLATF_ROUTE_INITIALIZER;
  route.src = "bob";
  route.dst = "alice";
  sg_platf_route_begin(&route);
  sg_platf_route_add_link("link1", &route);
  sg_platf_route_end(&route);

  sg_platf_new_AS_end();
  sg_platf_end();
  sg_platf_exit();
  return 0;
}
Ejemplo n.º 7
0
int  console_add_link(lua_State *L) {
  s_sg_platf_link_cbarg_t link;
  memset(&link,0,sizeof(link));

  int type;
  const char* policy;

  lua_ensure(lua_istable(L, -1), "Bad Arguments to create link, Should be a table with named arguments");

  // get Id Value
  lua_pushstring(L, "id");
  type = lua_gettable(L, -2);
  lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER,
      "Attribute 'id' must be specified for any link and must be a string.");
  link.id = lua_tostring(L, -1);
  lua_pop(L, 1);

  // get bandwidth value
  lua_pushstring(L, "bandwidth");
  type = lua_gettable(L, -2);
  lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER,
      "Attribute 'bandwidth' must be specified for any link and must either be either a string (in the right format; see docs) or a number.");
  if (type == LUA_TNUMBER)
    link.bandwidth = lua_tonumber(L, -1);
  else // LUA_TSTRING
    link.bandwidth = surf_parse_get_bandwidth(lua_tostring(L, -1),"bandwidth of link", link.id);
  lua_pop(L, 1);

  //get latency value
  lua_pushstring(L, "lat");
  type = lua_gettable(L, -2);
  lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER,
      "Attribute 'lat' must be specified for any link and must either be a string (in the right format; see docs) or a number.");
  if (type == LUA_TNUMBER)
    link.latency = lua_tonumber(L, -1);
  else // LUA_TSTRING
    link.latency = surf_parse_get_time(lua_tostring(L, -1),"latency of link", link.id);
  lua_pop(L, 1);

  /*Optional Arguments  */

  //get bandwidth_trace value
  lua_pushstring(L, "bandwidth_file");
  lua_gettable(L, -2);
  const char *filename = lua_tostring(L, -1);
  if (filename)
    link.bandwidth_trace = tmgr_trace_new_from_file(filename);
  lua_pop(L, 1);

  //get latency_trace value
  lua_pushstring(L, "latency_file");
  lua_gettable(L, -2);
  filename = lua_tostring(L, -1);
  if (filename)
    link.latency_trace = tmgr_trace_new_from_file(filename);
  lua_pop(L, 1);

  //get state_trace value
  lua_pushstring(L, "state_file");
  lua_gettable(L, -2);
  filename = lua_tostring(L, -1);
  if (filename)
    link.state_trace = tmgr_trace_new_from_file(filename);
  lua_pop(L, 1);

  //get policy value
  lua_pushstring(L, "sharing_policy");
  lua_gettable(L, -2);
  policy = lua_tostring(L, -1);
  lua_pop(L, 1);
  if (policy && !strcmp(policy,"FULLDUPLEX")) {
    link.policy = SURF_LINK_FULLDUPLEX;
  } else if (policy && !strcmp(policy,"FATPIPE")) {
    link.policy = SURF_LINK_FATPIPE;
  } else {
    link.policy = SURF_LINK_SHARED;
  }

  sg_platf_new_link(&link);

  return 0;
}