Exemple #1
0
int console_add_host(lua_State *L) {
  s_sg_platf_host_cbarg_t host;
  memset(&host,0,sizeof(host));
  int type;

  // we get values from the table passed as argument
  lua_ensure(lua_istable(L, -1),
      "Bad Arguments to create host. Should be a table with named arguments");

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

  // get power value
  lua_pushstring(L, "speed");
  type = lua_gettable(L, -2);
  lua_ensure(type == LUA_TSTRING || type == LUA_TNUMBER,
      "Attribute 'speed' must be specified for host and must either be a string (in the correct format; check documentation) or a number.");
  if (type == LUA_TNUMBER)
    host.speed_per_pstate.push_back(lua_tointeger(L, -1));
  else // LUA_TSTRING
    host.speed_per_pstate.push_back(surf_parse_get_speed(lua_tostring(L, -1), "speed of host", host.id));
  lua_pop(L, 1);

  // get core
  lua_pushstring(L, "core");
  lua_gettable(L, -2);
  if(!lua_isnumber(L,-1))
      host.core_amount = 1;// Default value
  else
    host.core_amount = lua_tonumber(L, -1);
  if (host.core_amount == 0)
    host.core_amount = 1;
  lua_pop(L, 1);

  //get power_trace
  lua_pushstring(L, "availability_file");
  lua_gettable(L, -2);
  const char *filename = lua_tostring(L, -1);
  if (filename)
    host.speed_trace = tmgr_trace_new_from_file(filename);
  lua_pop(L, 1);

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

  sg_platf_new_host(&host);

  return 0;
}
Exemple #2
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;
}
Exemple #3
0
void ETag_surfxml_host()    {
  simgrid::kernel::routing::HostCreationArgs host;

  host.properties = current_property_set;
  current_property_set = nullptr;

  host.id = A_surfxml_host_id;

  host.speed_per_pstate = surf_parse_get_all_speeds(A_surfxml_host_speed, "speed of host", host.id);

  XBT_DEBUG("pstate: %s", A_surfxml_host_pstate);
  host.core_amount = surf_parse_get_int(A_surfxml_host_core);
  host.speed_trace = A_surfxml_host_availability___file[0] ? tmgr_trace_new_from_file(A_surfxml_host_availability___file) : nullptr;
  host.state_trace = A_surfxml_host_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_host_state___file) : nullptr;
  host.pstate      = surf_parse_get_int(A_surfxml_host_pstate);
  host.coord       = A_surfxml_host_coordinates;

  sg_platf_new_host(&host);
}