Пример #1
0
int main(int argc, char **argv)
{
  surf_init(&argc, argv);

  simgrid::trace_mgr::future_evt_set *fes = new simgrid::trace_mgr::future_evt_set();
  tmgr_trace_t trace_A = tmgr_trace_new_from_file("trace_A.txt");
  tmgr_trace_t trace_B = tmgr_trace_new_from_file("trace_B.txt");
  double value = -1.0;
  simgrid::surf::Resource *resource = nullptr;
  simgrid::surf::Resource *hostA = new DummyTestResource("Host A");
  simgrid::surf::Resource *hostB = new DummyTestResource("Host B");

  fes->add_trace(trace_A, 1.0, hostA);
  fes->add_trace(trace_B, 0.0, hostB);

  double next_event_date = fes->next_date();
  while (next_event_date > -1.0) {
    XBT_INFO("%g:", next_event_date);
    while (fes->pop_leq(next_event_date, &value, &resource)) {
      XBT_INFO("   %s: %g", resource->getName(), value);
    }
    if (next_event_date > 100)
      break;
    next_event_date = fes->next_date();
  }

  delete fes;
  delete hostA;
  delete hostB;

  surf_exit();
  return 0;
}
Пример #2
0
void test(void)
{
  tmgr_history_t history = tmgr_history_new();
  tmgr_trace_t trace_A = tmgr_trace_new_from_file("trace_A.txt");
  tmgr_trace_t trace_B = tmgr_trace_new_from_file("trace_B.txt");
  double next_event_date = -1.0;
  double value = -1.0;
  char *resource = NULL;
  char *host_A = strdup("Host A");
  char *host_B = strdup("Host B");

  tmgr_history_add_trace(history, trace_A, 1.0, 2, host_A);
  tmgr_history_add_trace(history, trace_B, 0.0, 0, host_B);

  while ((next_event_date = tmgr_history_next_date(history)) != -1.0) {
    XBT_DEBUG("%g" " : \n", next_event_date);
    while (tmgr_history_get_next_event_leq(history, next_event_date,
                                           &value, (void **) &resource)) {
      XBT_DEBUG("\t %s : " "%g" "\n", resource, value);
    }
    if (next_event_date > 1000)
      break;
  }

  tmgr_history_free(history);
  free(host_B);
  free(host_A);
}
Пример #3
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);
}
Пример #4
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;
}
Пример #5
0
void STag_surfxml_peer(){
  simgrid::kernel::routing::PeerCreationArgs peer;

  peer.id          = std::string(A_surfxml_peer_id);
  peer.speed       = surf_parse_get_speed(A_surfxml_peer_speed, "speed of peer", peer.id.c_str());
  peer.bw_in       = surf_parse_get_bandwidth(A_surfxml_peer_bw___in, "bw_in of peer", peer.id.c_str());
  peer.bw_out      = surf_parse_get_bandwidth(A_surfxml_peer_bw___out, "bw_out of peer", peer.id.c_str());
  peer.coord       = A_surfxml_peer_coordinates;
  peer.speed_trace = A_surfxml_peer_availability___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_availability___file) : nullptr;
  peer.state_trace = A_surfxml_peer_state___file[0] ? tmgr_trace_new_from_file(A_surfxml_peer_state___file) : nullptr;

  if (A_surfxml_peer_lat[0] != '\0')
    XBT_WARN("The latency parameter in <peer> is now deprecated. Use the z coordinate instead of '%s'.",
             A_surfxml_peer_lat);

  sg_platf_new_peer(&peer);
}
Пример #6
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);
}
Пример #7
0
void sg_platf_new_trace(sg_platf_trace_cbarg_t trace)
{
  tmgr_trace_t tmgr_trace;
  if (trace->file && strcmp(trace->file, "") != 0) {
    tmgr_trace = tmgr_trace_new_from_file(trace->file);
  } else {
    xbt_assert(strcmp(trace->pc_data, ""),
        "Trace '%s' must have either a content, or point to a file on disk.",trace->id);
    tmgr_trace = tmgr_trace_new_from_string(trace->id, trace->pc_data, trace->periodicity);
  }
  xbt_dict_set(traces_set_list, trace->id, (void *) tmgr_trace, nullptr);
}
Пример #8
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;
}