コード例 #1
0
ファイル: surfxml_sax_cb.cpp プロジェクト: mpoquet/simgrid
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());
}
コード例 #2
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;
}