| Attribute name | Mandatory | Values | Description |
| --------------- | --------- | ------ | ----------- |
| id | yes | String | The identifier of the link that should be added to the route. |
-| direction | maybe | UP\|DOWN | If the link referenced by \c id has been declared as \ref pf_sharing_policy_fullduplex "FULLDUPLEX", this indicates which direction the route traverses through this link: UP or DOWN. If you don't use FULLDUPLEX, this attribute has no effect.
+| direction | maybe | UP\|DOWN | If the link referenced by \c id has been declared as \ref pf_sharing_policy_fullduplex "FULLDUPLEX", this indicates which direction the route traverses through this link: UP or DOWN. If you don't use FULLDUPLEX, do not use this attribute or SimGrid will not find the right link.
#### Example Files ####
virtual int main(int argc, char **argv);
/** The Actor that is currently running */
- static Actor *current();
+ static Actor &self();
/** Retrieves the actor that have the given PID (or NULL if not existing) */
//static Actor *byPid(int pid); not implemented
fprintf(stderr,"Error: You should override the method main(int, char**) in Actor class %s\n",getName());
return 0;
}
-s4u::Actor *s4u::Actor::current()
+s4u::Actor &s4u::Actor::self()
{
smx_process_t smx_proc = SIMIX_process_self();
simgrid::s4u::Actor* res = (simgrid::s4u::Actor*) SIMIX_process_self_get_data();
if (res == NULL) // The smx_process was not created by S4U (but by deployment?). Embed it in a S4U object
res = new Actor(smx_proc);
- return res;
+ return *res;
}
void s4u::Actor::setAutoRestart(bool autorestart) {
routing_model_create(NULL);
- simgrid::surf::on_link.connect([](sg_platf_link_cbarg_t link){
- xbt_die("There is no link in the Constant network model. "
- "Please remove any link from your platform (and switch to routing='None')");
- });
+ simgrid::surf::on_link.connect(netlink_parse_init);
}
namespace simgrid {
namespace surf {
+ Link* NetworkConstantModel::createLink(const char *name, double bw, double lat, e_surf_link_sharing_policy_t policy,
+ xbt_dict_t properties) {
+
+ xbt_die("Refusing to create the link %s: there is no link in the Constant network model. "
+ "Please remove any link from your platform (and switch to routing='None')", name);
+ }
+
double NetworkConstantModel::next_occuring_event(double /*now*/)
{
NetworkConstantAction *action = NULL;
bool next_occuring_event_isIdempotent() override {return true;}
void updateActionsState(double now, double delta) override;
- Link* createLink(const char *name, double bw, double lat, e_surf_link_sharing_policy_t policy, xbt_dict_t properties) override
- { DIE_IMPOSSIBLE; }
+ Link* createLink(const char *name, double bw, double lat, e_surf_link_sharing_policy_t policy, xbt_dict_t properties) override;
};
/**********
}
void netlink_parse_init(sg_platf_link_cbarg_t link){
- if (link->policy == SURF_LINK_FULLDUPLEX) {
- char *link_id;
- link_id = bprintf("%s_UP", link->id);
- Link *l = surf_network_model->createLink(link_id, link->bandwidth, link->latency,
- link->policy, link->properties);
- if (link->latency_trace)
- l->setLatencyTrace(link->latency_trace);
- if (link->bandwidth_trace)
- l->setBandwidthTrace(link->bandwidth_trace);
- if (link->state_trace)
- l->setStateTrace(link->state_trace);
+ std::vector<char*> names;
- xbt_free(link_id);
- link_id = bprintf("%s_DOWN", link->id);
- l = surf_network_model->createLink(link_id, link->bandwidth, link->latency,
- link->policy, link->properties);
- if (link->latency_trace)
- l->setLatencyTrace(link->latency_trace);
- if (link->bandwidth_trace)
- l->setBandwidthTrace(link->bandwidth_trace);
- if (link->state_trace)
- l->setStateTrace(link->state_trace);
- xbt_free(link_id);
+ if (link->policy == SURF_LINK_FULLDUPLEX) {
+ names.push_back(bprintf("%s_UP", link->id));
+ names.push_back(bprintf("%s_DOWN", link->id));
} else {
- Link *l=surf_network_model->createLink(link->id, link->bandwidth, link->latency,
- link->policy, link->properties);
+ names.push_back(xbt_strdup(link->id));
+ }
+ for (auto link_name : names) {
+ Link *l = surf_network_model->createLink(link_name, link->bandwidth, link->latency, link->policy, link->properties);
+
if (link->latency_trace)
l->setLatencyTrace(link->latency_trace);
if (link->bandwidth_trace)
l->setBandwidthTrace(link->bandwidth_trace);
if (link->state_trace)
l->setStateTrace(link->state_trace);
+
+ xbt_free(link_name);
}
}
int NS3_EXTENSION_ID;
-xbt_dynar_t IPV4addr;
+xbt_dynar_t IPV4addr = xbt_dynar_new(sizeof(char*),free);
static double time_to_next_flow_completion = -1;
extern xbt_dict_t dict_socket;
{
XBT_DEBUG("NS3_ADD_LINK '%s'",link->id);
- if(!IPV4addr)
- IPV4addr = xbt_dynar_new(sizeof(char*),free);
-
- Link *l = surf_network_model->createLink(link->id, link->bandwidth, link->latency,
- link->policy, link->properties);
+ Link *l = surf_network_model->createLink(link->id, link->bandwidth, link->latency, link->policy, link->properties);
if (link->bandwidth_trace)
l->setBandwidthTrace(link->latency_trace);
if (link->latency_trace)
{
simgrid::s4u::Host::onCreation.connect(simgrid_ns3_add_host);
simgrid::surf::netcardCreatedCallbacks.connect(simgrid_ns3_add_router);
- simgrid::surf::on_link.connect (&parse_ns3_add_link);
+ simgrid::surf::on_link.connect (parse_ns3_add_link);
simgrid::surf::on_cluster.connect (&parse_ns3_add_cluster);
simgrid::surf::asCreatedCallbacks.connect(parse_ns3_add_AS);
simgrid::surf::on_postparse.connect(&create_ns3_topology); //get_one_link_routes
/**************************************/
/*** Resource Creation & Destruction **/
/**************************************/
-
-static void ptask_netlink_parse_init(sg_platf_link_cbarg_t link)
-{
- netlink_parse_init(link);
- current_property_set = NULL;
-}
-
void surf_host_model_init_ptask_L07(void)
{
XBT_CINFO(xbt_cfg,"Switching to the L07 model to handle parallel tasks.");
xbt_assert(!surf_network_model, "network model type already defined");
// Define the callbacks to parse the XML
- simgrid::surf::on_link.connect(ptask_netlink_parse_init);
+ simgrid::surf::on_link.connect(netlink_parse_init);
surf_host_model = new simgrid::surf::HostL07Model();
xbt_dynar_push(all_existing_models, &surf_host_model);
XBT_DEBUG("Add a backbone to AS '%s'", current_routing->name());
}
+void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet)
+{
+ int start, end, i;
+ char *groups , *host_id , *link_id = NULL;
+ unsigned int iter;
+ xbt_dynar_t radical_elements;
+ xbt_dynar_t radical_ends;
+
+ //Make all hosts
+ radical_elements = xbt_str_split(cabinet->radical, ",");
+ xbt_dynar_foreach(radical_elements, iter, groups) {
+
+ radical_ends = xbt_str_split(groups, "-");
+ start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
+
+ switch (xbt_dynar_length(radical_ends)) {
+ case 1:
+ end = start;
+ break;
+ case 2:
+ end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
+ break;
+ default:
+ surf_parse_error("Malformed radical");
+ break;
+ }
+ s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
+ memset(&host, 0, sizeof(host));
+ host.pstate = 0;
+ host.core_amount = 1;
+
+ s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
+ memset(&link, 0, sizeof(link));
+ link.policy = SURF_LINK_FULLDUPLEX;
+ link.latency = cabinet->lat;
+ link.bandwidth = cabinet->bw;
+
+ s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
+ memset(&host_link, 0, sizeof(host_link));
+
+ for (i = start; i <= end; i++) {
+ host_id = bprintf("%s%d%s",cabinet->prefix,i,cabinet->suffix);
+ link_id = bprintf("link_%s%d%s",cabinet->prefix,i,cabinet->suffix);
+ host.id = host_id;
+ link.id = link_id;
+ host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
+ xbt_dynar_push(host.speed_peak,&cabinet->speed);
+ sg_platf_new_host(&host);
+ xbt_dynar_free(&host.speed_peak);
+ sg_platf_new_link(&link);
+
+ char* link_up = bprintf("%s_UP",link_id);
+ char* link_down = bprintf("%s_DOWN",link_id);
+ host_link.id = host_id;
+ host_link.link_up = link_up;
+ host_link.link_down = link_down;
+ sg_platf_new_hostlink(&host_link);
+
+ free(host_id);
+ free(link_id);
+ free(link_up);
+ free(link_down);
+ }
+
+ xbt_dynar_free(&radical_ends);
+ }
+ xbt_dynar_free(&radical_elements);
+}
+
void sg_platf_new_storage(sg_platf_storage_cbarg_t storage)
{
xbt_assert(!xbt_lib_get_or_null(storage_lib, storage->id,ROUTING_STORAGE_LEVEL),
link.latency = peer->lat;
char* link_up = bprintf("%s_UP",link_id);
- XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_up,
- peer->bw_out, peer->lat);
+ XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_up, peer->bw_out, peer->lat);
link.id = link_up;
link.bandwidth = peer->bw_out;
sg_platf_new_link(&link);
char* link_down = bprintf("%s_DOWN",link_id);
- XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_down,
- peer->bw_in, peer->lat);
+ XBT_DEBUG("<link\tid=\"%s\"\tbw=\"%f\"\tlat=\"%f\"/>", link_down, peer->bw_in, peer->lat);
link.id = link_down;
link.bandwidth = peer->bw_in;
sg_platf_new_link(&link);
/* ************************************************************************** */
/* ************************* GENERIC PARSE FUNCTIONS ************************ */
-void sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet)
-{
- int start, end, i;
- char *groups , *host_id , *link_id = NULL;
- unsigned int iter;
- xbt_dynar_t radical_elements;
- xbt_dynar_t radical_ends;
-
- //Make all hosts
- radical_elements = xbt_str_split(cabinet->radical, ",");
- xbt_dynar_foreach(radical_elements, iter, groups) {
-
- radical_ends = xbt_str_split(groups, "-");
- start = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 0, char *));
-
- switch (xbt_dynar_length(radical_ends)) {
- case 1:
- end = start;
- break;
- case 2:
- end = surf_parse_get_int(xbt_dynar_get_as(radical_ends, 1, char *));
- break;
- default:
- surf_parse_error("Malformed radical");
- break;
- }
- s_sg_platf_host_cbarg_t host = SG_PLATF_HOST_INITIALIZER;
- memset(&host, 0, sizeof(host));
- host.pstate = 0;
- host.core_amount = 1;
-
- s_sg_platf_link_cbarg_t link = SG_PLATF_LINK_INITIALIZER;
- memset(&link, 0, sizeof(link));
- link.policy = SURF_LINK_FULLDUPLEX;
- link.latency = cabinet->lat;
- link.bandwidth = cabinet->bw;
-
- s_sg_platf_host_link_cbarg_t host_link = SG_PLATF_HOST_LINK_INITIALIZER;
- memset(&host_link, 0, sizeof(host_link));
-
- for (i = start; i <= end; i++) {
- host_id = bprintf("%s%d%s",cabinet->prefix,i,cabinet->suffix);
- link_id = bprintf("link_%s%d%s",cabinet->prefix,i,cabinet->suffix);
- host.id = host_id;
- link.id = link_id;
- host.speed_peak = xbt_dynar_new(sizeof(double), NULL);
- xbt_dynar_push(host.speed_peak,&cabinet->speed);
- sg_platf_new_host(&host);
- xbt_dynar_free(&host.speed_peak);
- sg_platf_new_link(&link);
-
- char* link_up = bprintf("%s_UP",link_id);
- char* link_down = bprintf("%s_DOWN",link_id);
- host_link.id = host_id;
- host_link.link_up = link_up;
- host_link.link_down = link_down;
- sg_platf_new_hostlink(&host_link);
-
- free(host_id);
- free(link_id);
- free(link_up);
- free(link_down);
- }
-
- xbt_dynar_free(&radical_ends);
- }
- xbt_dynar_free(&radical_elements);
-}
-
static void check_disk_attachment()
{
xbt_lib_cursor_t cursor;
#include "src/surf/xml/platf_private.hpp"
-XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_parse, surf,
- "Logging specific to the SURF parsing module");
+XBT_LOG_NEW_DEFAULT_SUBCATEGORY(surf_parse, surf, "Logging specific to the SURF parsing module");
#undef CLEANUP
int ETag_surfxml_include_state(void);