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; }
static std::vector<double> surf_parse_get_all_speeds(char* speeds, const char* entity_kind, std::string id) { std::vector<double> speed_per_pstate; if (strchr(speeds, ',') == nullptr){ double speed = surf_parse_get_speed(speeds, entity_kind, id); speed_per_pstate.push_back(speed); } else { std::vector<std::string> pstate_list; boost::split(pstate_list, speeds, boost::is_any_of(",")); for (auto speed_str : pstate_list) { boost::trim(speed_str); double speed = surf_parse_get_speed(speed_str.c_str(), entity_kind, id); speed_per_pstate.push_back(speed); XBT_DEBUG("Speed value: %f", speed); } } return speed_per_pstate; }
void STag_surfxml_cabinet(){ simgrid::kernel::routing::CabinetCreationArgs cabinet; cabinet.id = A_surfxml_cabinet_id; cabinet.prefix = A_surfxml_cabinet_prefix; cabinet.suffix = A_surfxml_cabinet_suffix; cabinet.speed = surf_parse_get_speed(A_surfxml_cabinet_speed, "speed of cabinet", cabinet.id.c_str()); cabinet.bw = surf_parse_get_bandwidth(A_surfxml_cabinet_bw, "bw of cabinet", cabinet.id.c_str()); cabinet.lat = surf_parse_get_time(A_surfxml_cabinet_lat, "lat of cabinet", cabinet.id.c_str()); cabinet.radicals = explodesRadical(A_surfxml_cabinet_radical); sg_platf_new_cabinet(&cabinet); }
void ETag_surfxml_host(void) { s_sg_platf_host_cbarg_t host; memset(&host,0,sizeof(host)); char* buf; host.properties = current_property_set; host.id = A_surfxml_host_id; buf = A_surfxml_host_speed; XBT_DEBUG("Buffer: %s", buf); host.speed_per_pstate = xbt_dynar_new(sizeof(double), nullptr); if (strchr(buf, ',') == nullptr){ double speed = surf_parse_get_speed(A_surfxml_host_speed,"speed of host", host.id); xbt_dynar_push_as(host.speed_per_pstate,double, speed); }
void ETag_surfxml_host(void) { s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER; char* buf; memset(&host,0,sizeof(host)); host.properties = current_property_set; host.id = A_surfxml_host_id; buf = A_surfxml_host_speed; XBT_DEBUG("Buffer: %s", buf); host.speed_peak = xbt_dynar_new(sizeof(double), NULL); if (strchr(buf, ',') == NULL){ double speed = surf_parse_get_speed(A_surfxml_host_speed,"speed of host", host.id); xbt_dynar_push_as(host.speed_peak,double, speed); }
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); }