/* Receiver actor: wait for 1 message on the mailbox identified by the hostname */
class Receiver {
public:
- void operator()()
+ void operator()() const
{
auto mbox = sg4::Mailbox::by_name(sg4::this_actor::get_host()->get_name());
auto received = mbox->get_unique<std::string>();
* @return netpoint, gateway: the netpoint to the StarZone and CPU0 as gateway
*/
static std::pair<simgrid::kernel::routing::NetPoint*, simgrid::kernel::routing::NetPoint*>
-create_hostzone(sg4::NetZone* zone, const std::vector<unsigned int>& coord, int id)
+create_hostzone(const sg4::NetZone* zone, const std::vector<unsigned int>& /*coord*/, int id)
{
constexpr int num_cpus = 8; //!< Number of CPUs in the zone
constexpr double speed = 1e9; //!< Speed of each CPU
/* setting my Torus parent zone */
host_zone->set_parent(zone);
- sg4::Host* gateway = nullptr;
+ const sg4::Host* gateway = nullptr;
/* create CPUs */
for (int i = 0; i < num_cpus; i++) {
std::string cpu_name = hostname + "-cpu" + std::to_string(i);
static void create_torus_cluster()
{
// Callback to create limiter link (1Gbs) for each host
- auto create_limiter = [](sg4::NetZone* zone, const std::vector<unsigned int>& coord, int id) -> sg4::Link* {
+ auto create_limiter = [](sg4::NetZone* zone, const std::vector<unsigned int>& /*coord*/, int id) -> sg4::Link* {
return zone->create_link("limiter-" + std::to_string(id), 1e9)->seal();
};
* @param id: Internal identifier of the element
* @return pair<NetPoint*, NetPoint*>: returns a pair of netpoint and gateway.
*/
-typedef std::pair<kernel::routing::NetPoint*, kernel::routing::NetPoint*>
-TorusNetPointCb(NetZone* zone, const std::vector<unsigned int>& coord, int id);
+using TorusNetPointCb = std::pair<kernel::routing::NetPoint*, kernel::routing::NetPoint*>(
+ NetZone* zone, const std::vector<unsigned int>& coord, int id);
/**
* @brief Callback used to set the links for some leaf of the torus
*
* @param id: Internal identifier of the element
* @return Pointer to the Link
*/
-typedef Link* TorusLinkCb(NetZone* zone, const std::vector<unsigned int>& coord, int id);
+using TorusLinkCb = Link*(NetZone* zone, const std::vector<unsigned int>& coord, int id);
/**
* @brief Create a torus zone
*
/** @brief Auxiliary function to create hosts */
static std::pair<kernel::routing::NetPoint*, kernel::routing::NetPoint*>
create_torus_host(const kernel::routing::ClusterCreationArgs* cluster, s4u::NetZone* zone,
- const std::vector<unsigned int>& coord, int id)
+ const std::vector<unsigned int>& /*coord*/, int id)
{
std::string host_id = std::string(cluster->prefix) + std::to_string(id) + cluster->suffix;
XBT_DEBUG("TorusCluster: creating host=%s speed=%f", host_id.c_str(), cluster->speeds.front());
- s4u::Host* host = zone->create_host(host_id, cluster->speeds)
- ->set_core_count(cluster->core_amount)
- ->set_properties(cluster->properties)
- ->seal();
+ const s4u::Host* host = zone->create_host(host_id, cluster->speeds)
+ ->set_core_count(cluster->core_amount)
+ ->set_properties(cluster->properties)
+ ->seal();
return std::make_pair(host->get_netpoint(), nullptr);
}
/** @brief Auxiliary function to create loopback links */
static s4u::Link* create_torus_loopback(const kernel::routing::ClusterCreationArgs* cluster, s4u::NetZone* zone,
- const std::vector<unsigned int>& coord, int id)
+ const std::vector<unsigned int>& /*coord*/, int id)
{
std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(id) + "_loopback";
XBT_DEBUG("TorusCluster: creating loopback link=%s bw=%f", link_id.c_str(), cluster->loopback_bw);
/** @brief Auxiliary function to create limiter links */
static s4u::Link* create_torus_limiter(const kernel::routing::ClusterCreationArgs* cluster, s4u::NetZone* zone,
- const std::vector<unsigned int>& coord, int id)
+ const std::vector<unsigned int>& /*coord*/, int id)
{
std::string link_id = std::string(cluster->id) + "_link_" + std::to_string(id) + "_limiter";
XBT_DEBUG("TorusCluster: creating limiter link=%s bw=%f", link_id.c_str(), cluster->limiter_link);
// auxiliary function to get dims from index
auto index_to_dims = [&dimensions](int index) {
std::vector<unsigned int> dims_array(dimensions.size());
- for (int i = dimensions.size() - 1; i >= 0 && index > 0; --i) {
+ for (unsigned long i = dimensions.size() - 1; i != 0; --i) {
+ if (index <= 0) {
+ break;
+ }
unsigned int value = index % dimensions[i];
dims_array[i] = value;
- index = ((index / dimensions[i]));
+ index = (index / dimensions[i]);
}
return dims_array;
};
zone->set_parent(parent->get_impl());
for (int i = 0; i < tot_elements; i++) {
- kernel::routing::NetPoint *netpoint = nullptr, *gw = nullptr;
- auto dims = index_to_dims(i);
- std::tie(netpoint, gw) = set_netpoint(zone->get_iface(), dims, i);
+ kernel::routing::NetPoint* netpoint = nullptr;
+ kernel::routing::NetPoint* gw = nullptr;
+ auto dims = index_to_dims(i);
+ std::tie(netpoint, gw) = set_netpoint(zone->get_iface(), dims, i);
xbt_assert(netpoint, "TorusZone::set_netpoint(elem=%d): Invalid netpoint (nullptr)", i);
if (netpoint->is_netzone()) {
xbt_assert(gw && not gw->is_netzone(),
zone->set_gateway(i, gw);
if (set_loopback) {
- Link* loopback = set_loopback(zone->get_iface(), dims, i);
+ const Link* loopback = set_loopback(zone->get_iface(), dims, i);
xbt_assert(loopback, "TorusZone::set_loopback: Invalid loopback link (nullptr) for element %d", i);
zone->set_loopback();
zone->add_private_link_at(zone->node_pos(netpoint->id()), {loopback->get_impl(), loopback->get_impl()});
}
if (set_limiter) {
- Link* limiter = set_limiter(zone->get_iface(), dims, i);
+ const Link* limiter = set_limiter(zone->get_iface(), dims, i);
xbt_assert(limiter, "TorusZone::set_limiter: Invalid limiter link (nullptr) for element %d", i);
zone->set_limiter();
zone->add_private_link_at(zone->node_pos_with_loopback(netpoint->id()),
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/s4u/Host.hpp"
#include "simgrid/s4u/NetZone.hpp"
-#include "src/surf/network_interface.hpp"
-#include "src/surf/xml/platf_private.hpp" // RouteCreationArgs and friends
namespace {
class EngineWrapper {
+public:
+ explicit EngineWrapper(std::string name) : argv(&name[0]), e(&argc, &argv) {}
int argc = 1;
char* argv;
-
-public:
simgrid::s4u::Engine e;
- explicit EngineWrapper(std::string name) : argv(&name[0]), e(&argc, &argv) {}
};
std::pair<simgrid::kernel::routing::NetPoint*, simgrid::kernel::routing::NetPoint*>
-create_host(simgrid::s4u::NetZone* zone, const std::vector<unsigned int>& coord, int id)
+create_host(simgrid::s4u::NetZone* zone, const std::vector<unsigned int>& /*coord*/, int id)
{
- simgrid::s4u::Host* host = zone->create_host(std::to_string(id), 1e9)->seal();
+ const simgrid::s4u::Host* host = zone->create_host(std::to_string(id), 1e9)->seal();
return std::make_pair(host->get_netpoint(), nullptr);
}
} // namespace
{
using namespace simgrid::s4u;
EngineWrapper e("test");
- auto create_host = [](NetZone* zone, const std::vector<unsigned int>& coord,
- int id) -> std::pair<simgrid::kernel::routing::NetPoint*, simgrid::kernel::routing::NetPoint*> {
- Host* host = zone->create_host(std::to_string(id), 1e9)->seal();
- return std::make_pair(host->get_netpoint(), nullptr);
- };
REQUIRE(create_torus_zone("test", e.e.get_netzone_root(), {3, 3, 3}, 1e9, 10,
simgrid::s4u::Link::SharingPolicy::SHARED, create_host));
}