Actually, we should stop using sg_platf_new_link and use
NetZone::createLink() but this later function is not ready yet.
And I don't want to revert the work of Fred so I'd better fix it.
}
int console_add_backbone(lua_State *L) {
}
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");
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);
+ int 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_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);
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.");
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);
+ link.bandwidth = surf_parse_get_bandwidth(lua_tostring(L, -1), "bandwidth of backbone", link.id.c_str());
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.");
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);
+ link.latency = surf_parse_get_time(lua_tostring(L, -1), "latency of backbone", link.id.c_str());
lua_pop(L, 1);
lua_pushstring(L, "sharing_policy");
lua_pop(L, 1);
lua_pushstring(L, "sharing_policy");
}
sg_platf_new_link(&link);
}
sg_platf_new_link(&link);
- routing_cluster_add_backbone(simgrid::surf::LinkImpl::byName(link.id));
+ routing_cluster_add_backbone(simgrid::surf::LinkImpl::byName(link.id.c_str()));
}
int console_add_link(lua_State *L) {
}
int console_add_link(lua_State *L) {
- s_sg_platf_link_cbarg_t link;
- memset(&link,0,sizeof(link));
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");
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);
+ int 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_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);
if (type == LUA_TNUMBER)
link.bandwidth = lua_tonumber(L, -1);
else // LUA_TSTRING
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);
+ link.bandwidth = surf_parse_get_bandwidth(lua_tostring(L, -1), "bandwidth of link", link.id.c_str());
lua_pop(L, 1);
//get latency value
lua_pop(L, 1);
//get latency value
if (type == LUA_TNUMBER)
link.latency = lua_tonumber(L, -1);
else // LUA_TSTRING
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);
+ link.latency = surf_parse_get_time(lua_tostring(L, -1), "latency of link", link.id.c_str());
lua_pop(L, 1);
/*Optional Arguments */
lua_pop(L, 1);
/*Optional Arguments */
{
char* link_id = bprintf("%s_link_%d", cluster->id, id);
{
char* link_id = bprintf("%s_link_%d", cluster->id, id);
- s_sg_platf_link_cbarg_t link;
- memset(&link, 0, sizeof(link));
link.id = link_id;
link.bandwidth = cluster->bw;
link.latency = cluster->lat;
link.id = link_id;
link.bandwidth = cluster->bw;
link.latency = cluster->lat;
linkDown = linkUp;
}
privateLinks_.insert({position, {linkUp, linkDown}});
linkDown = linkUp;
}
privateLinks_.insert({position, {linkUp, linkDown}});
{
*linkup = nullptr;
*linkdown = nullptr;
{
*linkup = nullptr;
*linkdown = nullptr;
- s_sg_platf_link_cbarg_t linkTemplate;
- memset(&linkTemplate, 0, sizeof(linkTemplate));
+ LinkCreationArgs linkTemplate;
linkTemplate.bandwidth = this->cluster_->bw * numlinks;
linkTemplate.latency = this->cluster_->lat;
linkTemplate.policy = this->cluster_->sharing_policy; // sthg to do with that ?
linkTemplate.bandwidth = this->cluster_->bw * numlinks;
linkTemplate.latency = this->cluster_->lat;
linkTemplate.policy = this->cluster_->sharing_policy; // sthg to do with that ?
FatTreeNode::FatTreeNode(sg_platf_cluster_cbarg_t cluster, int id, int level, int position)
: id(id), level(level), position(position)
{
FatTreeNode::FatTreeNode(sg_platf_cluster_cbarg_t cluster, int id, int level, int position)
: id(id), level(level), position(position)
{
- s_sg_platf_link_cbarg_t linkTemplate;
+ LinkCreationArgs linkTemplate;
if (cluster->limiter_link) {
if (cluster->limiter_link) {
- memset(&linkTemplate, 0, sizeof(linkTemplate));
linkTemplate.bandwidth = cluster->limiter_link;
linkTemplate.latency = 0;
linkTemplate.policy = SURF_LINK_SHARED;
linkTemplate.bandwidth = cluster->limiter_link;
linkTemplate.latency = 0;
linkTemplate.policy = SURF_LINK_SHARED;
this->limiterLink = surf::LinkImpl::byName(linkTemplate.id.c_str());
}
if (cluster->loopback_bw || cluster->loopback_lat) {
this->limiterLink = surf::LinkImpl::byName(linkTemplate.id.c_str());
}
if (cluster->loopback_bw || cluster->loopback_lat) {
- memset(&linkTemplate, 0, sizeof(linkTemplate));
linkTemplate.bandwidth = cluster->loopback_bw;
linkTemplate.latency = cluster->loopback_lat;
linkTemplate.policy = SURF_LINK_FATPIPE;
linkTemplate.bandwidth = cluster->loopback_bw;
linkTemplate.latency = cluster->loopback_lat;
linkTemplate.policy = SURF_LINK_FATPIPE;
: upNode(upNode), downNode(downNode)
{
static int uniqueId = 0;
: upNode(upNode), downNode(downNode)
{
static int uniqueId = 0;
- s_sg_platf_link_cbarg_t linkTemplate;
- memset(&linkTemplate, 0, sizeof(linkTemplate));
+ LinkCreationArgs linkTemplate;
linkTemplate.bandwidth = cluster->bw;
linkTemplate.latency = cluster->lat;
linkTemplate.policy = cluster->sharing_policy; // sthg to do with that ?
linkTemplate.bandwidth = cluster->bw;
linkTemplate.latency = cluster->lat;
linkTemplate.policy = cluster->sharing_policy; // sthg to do with that ?
- linkTemplate.id =
- "link_from_" + std::to_string( downNode->id) + "_" + std::to_string(upNode->id) + "_" + std::to_string(uniqueId);
+ linkTemplate.id =
+ "link_from_" + std::to_string(downNode->id) + "_" + std::to_string(upNode->id) + "_" + std::to_string(uniqueId);
sg_platf_new_link(&linkTemplate);
if (cluster->sharing_policy == SURF_LINK_FULLDUPLEX) {
sg_platf_new_link(&linkTemplate);
if (cluster->sharing_policy == SURF_LINK_FULLDUPLEX) {
int dim_product = 1; // Needed to calculate the next neighbor_id
for (unsigned int j = 0; j < xbt_dynar_length(dimensions_); j++) {
int dim_product = 1; // Needed to calculate the next neighbor_id
for (unsigned int j = 0; j < xbt_dynar_length(dimensions_); j++) {
- s_sg_platf_link_cbarg_t link;
- memset(&link, 0, sizeof(link));
current_dimension = xbt_dynar_get_as(dimensions_, j, int);
neighbor_rank_id = ((static_cast<int>(rank) / dim_product) % current_dimension == current_dimension - 1)
? rank - (current_dimension - 1) * dim_product
current_dimension = xbt_dynar_get_as(dimensions_, j, int);
neighbor_rank_id = ((static_cast<int>(rank) / dim_product) % current_dimension == current_dimension - 1)
? rank - (current_dimension - 1) * dim_product
-void sg_platf_new_link(sg_platf_link_cbarg_t link){
+void sg_platf_new_link(LinkCreationArgs* link)
+{
std::vector<std::string> names;
if (link->policy == SURF_LINK_FULLDUPLEX) {
std::vector<std::string> names;
if (link->policy == SURF_LINK_FULLDUPLEX) {
- s_sg_platf_link_cbarg_t link;
// What an inventive way of initializing the AS that I have as ancestor :-(
s_sg_platf_AS_cbarg_t AS;
// What an inventive way of initializing the AS that I have as ancestor :-(
s_sg_platf_AS_cbarg_t AS;
char *tmp_link = bprintf("%s_loopback", link_id);
XBT_DEBUG("<loopback\tid=\"%s\"\tbw=\"%f\"/>", tmp_link, cluster->loopback_bw);
char *tmp_link = bprintf("%s_loopback", link_id);
XBT_DEBUG("<loopback\tid=\"%s\"\tbw=\"%f\"/>", tmp_link, cluster->loopback_bw);
- memset(&link, 0, sizeof(link));
link.id = tmp_link;
link.bandwidth = cluster->loopback_bw;
link.latency = cluster->loopback_lat;
link.id = tmp_link;
link.bandwidth = cluster->loopback_bw;
link.latency = cluster->loopback_lat;
char *tmp_link = bprintf("%s_limiter", link_id);
XBT_DEBUG("<limiter\tid=\"%s\"\tbw=\"%f\"/>", tmp_link, cluster->limiter_link);
char *tmp_link = bprintf("%s_limiter", link_id);
XBT_DEBUG("<limiter\tid=\"%s\"\tbw=\"%f\"/>", tmp_link, cluster->limiter_link);
- memset(&link, 0, sizeof(link));
link.id = tmp_link;
link.bandwidth = cluster->limiter_link;
link.latency = 0;
link.id = tmp_link;
link.bandwidth = cluster->limiter_link;
link.latency = 0;
//Make the backbone
if ((cluster->bb_bw != 0) || (cluster->bb_lat != 0)) {
//Make the backbone
if ((cluster->bb_bw != 0) || (cluster->bb_lat != 0)) {
- memset(&link, 0, sizeof(link));
link.id = std::string(cluster->id)+ "_backbone";
link.bandwidth = cluster->bb_bw;
link.latency = cluster->bb_lat;
link.id = std::string(cluster->id)+ "_backbone";
link.bandwidth = cluster->bb_bw;
link.latency = cluster->bb_lat;
host.speed_per_pstate.push_back(cabinet->speed);
sg_platf_new_host(&host);
host.speed_per_pstate.push_back(cabinet->speed);
sg_platf_new_host(&host);
- s_sg_platf_link_cbarg_t link;
- memset(&link, 0, sizeof(link));
link.policy = SURF_LINK_FULLDUPLEX;
link.latency = cabinet->lat;
link.bandwidth = cabinet->bw;
link.policy = SURF_LINK_FULLDUPLEX;
link.latency = cabinet->lat;
link.bandwidth = cabinet->bw;
const char* link_down;
} s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
const char* link_down;
} s_sg_platf_host_link_cbarg_t, *sg_platf_host_link_cbarg_t;
+class LinkCreationArgs {
+public:
- double bandwidth;
- tmgr_trace_t bandwidth_trace;
- double latency;
- tmgr_trace_t latency_trace;
- tmgr_trace_t state_trace;
- e_surf_link_sharing_policy_t policy;
- xbt_dict_t properties;
-} s_sg_platf_link_cbarg_t, *sg_platf_link_cbarg_t;
+ double bandwidth = 0;
+ tmgr_trace_t bandwidth_trace = nullptr;
+ double latency = 0;
+ tmgr_trace_t latency_trace = nullptr;
+ tmgr_trace_t state_trace = nullptr;
+ e_surf_link_sharing_policy_t policy = SURF_LINK_FATPIPE;
+ xbt_dict_t properties = nullptr;
+};
typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
typedef struct s_sg_platf_peer_cbarg {
typedef struct s_sg_platf_peer_cbarg *sg_platf_peer_cbarg_t;
typedef struct s_sg_platf_peer_cbarg {
XBT_PUBLIC(void) sg_platf_new_hostlink(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
XBT_PUBLIC(simgrid::kernel::routing::NetPoint*)
sg_platf_new_router(const char* name, const char* coords); // Add a router to the currently described AS
XBT_PUBLIC(void) sg_platf_new_hostlink(sg_platf_host_link_cbarg_t h); // Add an host_link to the currently described AS
XBT_PUBLIC(simgrid::kernel::routing::NetPoint*)
sg_platf_new_router(const char* name, const char* coords); // Add a router to the currently described AS
-XBT_PUBLIC(void) sg_platf_new_link (sg_platf_link_cbarg_t link); // Add a link to the currently described AS
+XBT_PUBLIC(void) sg_platf_new_link(LinkCreationArgs* link); // Add a link to the currently described AS
XBT_PUBLIC(void) sg_platf_new_peer (sg_platf_peer_cbarg_t peer); // Add a peer to the currently described AS
XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
XBT_PUBLIC(void) sg_platf_new_peer (sg_platf_peer_cbarg_t peer); // Add a peer to the currently described AS
XBT_PUBLIC(void) sg_platf_new_cluster(sg_platf_cluster_cbarg_t clust); // Add a cluster to the currently described AS
XBT_PUBLIC(void) sg_platf_new_cabinet(sg_platf_cabinet_cbarg_t cabinet); // Add a cabinet to the currently described AS
}
void ETag_surfxml_link(){
}
void ETag_surfxml_link(){
- s_sg_platf_link_cbarg_t link;
- memset(&link,0,sizeof(link));
link.properties = current_property_set;
current_property_set = nullptr;
link.properties = current_property_set;
current_property_set = nullptr;
}
void ETag_surfxml_backbone(){
}
void ETag_surfxml_backbone(){
- s_sg_platf_link_cbarg_t link;
- memset(&link,0,sizeof(link));
link.properties = nullptr;
link.id = std::string(A_surfxml_backbone_id);
link.properties = nullptr;
link.id = std::string(A_surfxml_backbone_id);