Last active
May 3, 2024 15:24
-
-
Save JRodez/2a4645edb045481557af0facb4e38ecb to your computer and use it in GitHub Desktop.
3 level SimGrid platform
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright (c) 2006-2023. The SimGrid Team. All rights reserved. */ | |
/* This program is free software; you can redistribute it and/or modify it | |
* under the terms of the license (GNU LGPL) which comes with this package. */ | |
// based on routing_cluster of SimGrid official source code, modified by JRodez | |
#include <simgrid/s4u.hpp> | |
#include "simgrid/instr.h" | |
#include <simgrid/kernel/routing/NetPoint.hpp> | |
// #define GRAPHVIZ_ROUTING | |
namespace sg4 = simgrid::s4u; | |
static sg4::NetZone *create_cluster(const sg4::NetZone *root, const std::string &cluster_name, | |
const std::vector<std::string> &hosts) | |
{ | |
auto *cluster = sg4::create_star_zone(cluster_name)->set_parent(root); | |
/* create the backbone link */ | |
const sg4::Link *l_bb = cluster->create_link("backbonelink" + cluster_name, "20Gbps")->set_latency("500us"); | |
/* create all hosts and connect them to outside world */ | |
for (const auto &hostname : hosts) | |
{ | |
/* create host */ | |
sg4::Host *host = cluster->create_host(hostname, "1Gf"); | |
/* create link */ | |
const sg4::Link *l = cluster->create_link(hostname + "link", "1Gbps")->set_latency("100us"); | |
/* create route */ | |
sg4::LinkInRoute backbone{l_bb}; | |
sg4::LinkInRoute linkroute{l}; | |
cluster->add_route(host, nullptr, {linkroute, backbone}, true); | |
} | |
/* create gateway */ | |
cluster->set_gateway(cluster->create_router(cluster_name + "_router")); | |
cluster->seal(); | |
return cluster; | |
} | |
extern "C" void load_platform(const sg4::Engine &e); | |
void load_platform(const sg4::Engine &e) | |
{ | |
auto *root = sg4::create_star_zone("rootzone"); | |
/* create zone_A */ | |
auto *rootA = sg4::create_star_zone("zone_A"); | |
rootA->set_parent(root); | |
rootA->set_gateway(sg4::create_star_zone("routerAzone")->create_router(std::string("zone_A") + "_router")); | |
/* create cluster_A1 */ | |
auto *clusterA1 = create_cluster(rootA, "cluster_A1", {"host1_A1", "host2_A1", "host_3A1"}); | |
const sg4::Link *llA1 = rootA->create_link(std::string("") + "A1" + "plink", "1Gbps")->set_latency("100us"); | |
rootA->add_route(clusterA1, nullptr, {sg4::LinkInRoute(llA1)}); | |
/* create cluster_A2 */ | |
auto *clusterA2 = create_cluster(rootA, "cluster_A2", {"host1_A2", "host2_A2", "host_3A2"}); | |
const sg4::Link *llA2 = rootA->create_link(std::string("") + "A2" + "plink", "1Gbps")->set_latency("100us"); | |
rootA->add_route(clusterA2, nullptr, {sg4::LinkInRoute(llA2)}); | |
/* seal zone_A */ | |
rootA->seal(); | |
/* create zone_B */ | |
auto *rootB = sg4::create_star_zone("zone_B"); | |
rootB->set_parent(root); | |
rootB->set_gateway(sg4::create_star_zone("routerBzone")->create_router(std::string("zone_B") + "_router")); | |
/* create cluster_B1 */ | |
auto *clusterB1 = create_cluster(rootB, "cluster_B1", {"host1_B1", "host2_B1", "host_3B1"}); | |
const sg4::Link *llB1 = rootB->create_link(std::string("") + "B1" + "plink", "1Gbps")->set_latency("100us"); | |
rootB->add_route(clusterB1, nullptr, {sg4::LinkInRoute(llB1)}); | |
/* create cluster_B2 */ | |
auto *clusterB2 = create_cluster(rootB, "cluster_B2", {"host1_B2", "host2_B2", "host_3B2"}); | |
const sg4::Link *llB2 = rootB->create_link(std::string("") + "B2" + "plink", "1Gbps")->set_latency("100us"); | |
rootB->add_route(clusterB2, nullptr, {sg4::LinkInRoute(llB2)}); | |
/* seal zone_B */ | |
rootB->seal(); | |
const sg4::Link *rootlink = root->create_link(std::string("rootlink"), "1Gbps")->set_latency("100us"); | |
root->add_route(rootA, nullptr, {sg4::LinkInRoute(rootlink)}); | |
root->add_route(rootB, nullptr, {sg4::LinkInRoute(rootlink)}); | |
root->seal(); | |
#ifdef GRAPHVIZ_ROUTING | |
simgrid::instr::platform_graph_export_graphviz("routing_cluster_bugged.dot"); | |
#endif | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright (c) 2006-2023. The SimGrid Team. All rights reserved. */ | |
/* This program is free software; you can redistribute it and/or modify it | |
* under the terms of the license (GNU LGPL) which comes with this package. */ | |
// based on routing_cluster of SimGrid official source code, modified by JRodez | |
#include <simgrid/s4u.hpp> | |
#include "simgrid/instr.h" | |
#include <simgrid/kernel/routing/NetPoint.hpp> | |
// #define GRAPHVIZ_ROUTING | |
namespace sg4 = simgrid::s4u; | |
static sg4::NetZone *create_cluster(const sg4::NetZone *root, const std::string &cluster_name, | |
const std::vector<std::string> &hosts) | |
{ | |
auto *cluster = sg4::create_star_zone(cluster_name)->set_parent(root); | |
/* create the backbone link */ | |
const sg4::Link *l_bb = cluster->create_link("backbonelink" + cluster_name, "20Gbps")->set_latency("500us"); | |
/* create all hosts and connect them to outside world */ | |
for (const auto &hostname : hosts) | |
{ | |
/* create host */ | |
sg4::Host *host = cluster->create_host(hostname, "1Gf"); | |
/* create link */ | |
const sg4::Link *l = cluster->create_link(hostname + "link", "1Gbps")->set_latency("100us"); | |
/* create route */ | |
sg4::LinkInRoute backbone{l_bb}; | |
sg4::LinkInRoute linkroute{l}; | |
cluster->add_route(host, nullptr, {linkroute, backbone}, true); | |
} | |
/* create gateway */ | |
cluster->set_gateway(cluster->create_router(cluster_name + "_router")); | |
cluster->seal(); | |
return cluster; | |
} | |
simgrid::kernel::routing::NetPoint *enc_create_router(sg4::NetZone *zone, const std::string &name) | |
{ | |
sg4::NetZone *router_zone = sg4::create_star_zone(name + "_zone"); | |
router_zone->set_parent(zone); | |
simgrid::kernel::routing::NetPoint *router = router_zone->create_router(name); | |
return router; | |
} | |
extern "C" void load_platform(const sg4::Engine &e); | |
void load_platform(const sg4::Engine &e) | |
{ | |
auto *root = sg4::create_star_zone("rootzone"); | |
/* create zone_A */ | |
auto *rootA = sg4::create_star_zone("zone_A"); | |
rootA->set_parent(root); | |
rootA->set_gateway(enc_create_router(rootA, std::string("zone_Aaze") + "_router")); | |
/* create cluster_A1 */ | |
auto *clusterA1 = create_cluster(rootA, "cluster_A1", {"host1_A1", "host2_A1", "host_3A1"}); | |
const sg4::Link *llA1 = rootA->create_link(std::string("") + "A1" + "plink", "1Gbps")->set_latency("100us"); | |
rootA->add_route(clusterA1, nullptr, {sg4::LinkInRoute(llA1)}); | |
/* create cluster_A2 */ | |
auto *clusterA2 = create_cluster(rootA, "cluster_A2", {"host1_A2", "host2_A2", "host_3A2"}); | |
const sg4::Link *llA2 = rootA->create_link(std::string("") + "A2" + "plink", "1Gbps")->set_latency("100us"); | |
rootA->add_route(clusterA2, nullptr, {sg4::LinkInRoute(llA2)}); | |
/* seal zone_A */ | |
rootA->seal(); | |
/* create zone_B */ | |
auto *rootB = sg4::create_star_zone("zone_B"); | |
rootB->set_parent(root); | |
rootB->set_gateway(rootB->create_router(std::string("zone_B") + "_router")); | |
/* create cluster_B1 */ | |
auto *clusterB1 = create_cluster(rootB, "cluster_B1", {"host1_B1", "host2_B1", "host_3B1"}); | |
const sg4::Link *llB1 = rootB->create_link(std::string("") + "B1" + "plink", "1Gbps")->set_latency("100us"); | |
rootB->add_route(clusterB1, nullptr, {sg4::LinkInRoute(llB1)}); | |
/* create cluster_B2 */ | |
auto *clusterB2 = create_cluster(rootB, "cluster_B2", {"host1_B2", "host2_B2", "host_3B2"}); | |
const sg4::Link *llB2 = rootB->create_link(std::string("") + "B2" + "plink", "1Gbps")->set_latency("100us"); | |
rootB->add_route(clusterB2, nullptr, {sg4::LinkInRoute(llB2)}); | |
/* seal zone_B */ | |
rootB->seal(); | |
const sg4::Link *rootlink = root->create_link(std::string("rootlink"), "1Gbps")->set_latency("100us"); | |
root->add_route(rootA, nullptr, {sg4::LinkInRoute(rootlink)}); | |
root->add_route(rootB, nullptr, {sg4::LinkInRoute(rootlink)}); | |
root->seal(); | |
#ifdef GRAPHVIZ_ROUTING | |
simgrid::instr::platform_graph_export_graphviz("routing_cluster_bugged.dot"); | |
#endif | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* Copyright (c) 2006-2023. The SimGrid Team. All rights reserved. */ | |
/* This program is free software; you can redistribute it and/or modify it | |
* under the terms of the license (GNU LGPL) which comes with this package. */ | |
// based on routing_cluster of SimGrid official source code, modified by JRodez | |
#include <simgrid/s4u.hpp> | |
#include "simgrid/instr.h" | |
#include <simgrid/kernel/routing/NetPoint.hpp> | |
// #define GRAPHVIZ_ROUTING | |
namespace sg4 = simgrid::s4u; | |
static sg4::NetZone *create_cluster(const sg4::NetZone *root, const std::string &cluster_name, | |
const std::vector<std::string> &hosts) | |
{ | |
auto *cluster = sg4::create_star_zone(cluster_name)->set_parent(root); | |
/* create the backbone link */ | |
const sg4::Link *l_bb = cluster->create_link("backbonelink" + cluster_name, "20Gbps")->set_latency("500us"); | |
/* create all hosts and connect them to outside world */ | |
for (const auto &hostname : hosts) | |
{ | |
/* create host */ | |
sg4::Host *host = cluster->create_host(hostname, "1Gf"); | |
/* create link */ | |
const sg4::Link *l = cluster->create_link(hostname + "link", "1Gbps")->set_latency("100us"); | |
/* create route */ | |
sg4::LinkInRoute backbone{l_bb}; | |
sg4::LinkInRoute linkroute{l}; | |
cluster->add_route(host, nullptr, {linkroute, backbone}, true); | |
} | |
/* create gateway */ | |
cluster->set_gateway(cluster->create_router(cluster_name + "_router")); | |
cluster->seal(); | |
return cluster; | |
} | |
extern "C" void load_platform(const sg4::Engine &e); | |
void load_platform(const sg4::Engine &e) | |
{ | |
auto *root = sg4::create_star_zone("rootzone"); | |
/* create zone_A */ | |
auto *rootA = sg4::create_star_zone("zone_A"); | |
rootA->set_parent(root); | |
rootA->set_gateway(rootA->create_router(std::string("zone_A") + "_router")); | |
/* create cluster_A1 */ | |
auto *clusterA1 = create_cluster(rootA, "cluster_A1", {"host1_A1", "host2_A1", "host_3A1"}); | |
const sg4::Link *llA1 = rootA->create_link(std::string("") + "A1" + "plink", "1Gbps")->set_latency("100us"); | |
rootA->add_route(clusterA1, nullptr, {sg4::LinkInRoute(llA1)}); | |
/* create cluster_A2 */ | |
auto *clusterA2 = create_cluster(rootA, "cluster_A2", {"host1_A2", "host2_A2", "host_3A2"}); | |
const sg4::Link *llA2 = rootA->create_link(std::string("") + "A2" + "plink", "1Gbps")->set_latency("100us"); | |
rootA->add_route(clusterA2, nullptr, {sg4::LinkInRoute(llA2)}); | |
/* seal zone_A */ | |
rootA->seal(); | |
/* create zone_B */ | |
auto *rootB = sg4::create_star_zone("zone_B"); | |
rootB->set_parent(root); | |
rootB->set_gateway(rootB->create_router(std::string("zone_B") + "_router")); | |
/* create cluster_B1 */ | |
auto *clusterB1 = create_cluster(rootB, "cluster_B1", {"host1_B1", "host2_B1", "host_3B1"}); | |
const sg4::Link *llB1 = rootB->create_link(std::string("") + "B1" + "plink", "1Gbps")->set_latency("100us"); | |
rootB->add_route(clusterB1, nullptr, {sg4::LinkInRoute(llB1)}); | |
/* create cluster_B2 */ | |
auto *clusterB2 = create_cluster(rootB, "cluster_B2", {"host1_B2", "host2_B2", "host_3B2"}); | |
const sg4::Link *llB2 = rootB->create_link(std::string("") + "B2" + "plink", "1Gbps")->set_latency("100us"); | |
rootB->add_route(clusterB2, nullptr, {sg4::LinkInRoute(llB2)}); | |
/* seal zone_B */ | |
rootB->seal(); | |
const sg4::Link *rootlink = root->create_link(std::string("rootlink"), "1Gbps")->set_latency("100us"); | |
root->add_route(rootA, nullptr, {sg4::LinkInRoute(rootlink)}); | |
root->add_route(rootB, nullptr, {sg4::LinkInRoute(rootlink)}); | |
root->seal(); | |
#ifdef GRAPHVIZ_ROUTING | |
simgrid::instr::platform_graph_export_graphviz("routing_cluster_bugged.dot"); | |
#endif | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment