* @param id Internal identifier in the torus (for information)
* @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(const sg4::NetZone* zone, const std::vector<unsigned long>& /*coord*/, unsigned long id)
+static sg4::NetZone* create_hostzone(const sg4::NetZone* zone, const std::vector<unsigned long>& /*coord*/, unsigned long 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);
- simgrid::kernel::routing::NetPoint* gateway = nullptr;
/* create CPUs */
for (int i = 0; i < num_cpus; i++) {
std::string cpu_name = hostname + "-cpu" + std::to_string(i);
const sg4::Host* host = host_zone->create_host(cpu_name, speed);
/* the first CPU is the gateway */
if (i == 0)
- gateway = host->get_netpoint();
+ host_zone->set_gateway(host->get_netpoint());
/* create split-duplex link */
auto* link = host_zone->create_split_duplex_link("link-" + cpu_name, link_bw)->set_latency(link_lat);
/* connecting CPU to outer world */
}
/* seal newly created netzone */
host_zone->seal();
- return std::make_pair(host_zone->get_netpoint(), gateway);
+ return host_zone;
}
/*************************************************************************************************/
* @param id: Internal identifier of the element
* @return pair<NetPoint*, NetPoint*>: returns a pair of netpoint and gateway.
*/
+ // XBT_ATTRIB_DEPRECATED_v339
using ClusterNetPointCb = std::pair<kernel::routing::NetPoint*, kernel::routing::NetPoint*>(
NetZone* zone, const std::vector<unsigned long>& coord, unsigned long id);
+
+ /**
+ * @brief Callback used to set the NetZone located at some leaf of clusters (Torus, FatTree, etc)
+ *
+ * @param zone: The parent zone, needed for creating new resources (hosts, links)
+ * @param coord: the coordinates of the element
+ * @param id: Internal identifier of the element
+ * @return NetZone*: returns newly created netzone
+ */
+ using ClusterNetZoneCb = NetZone*(NetZone* zone, const std::vector<unsigned long>& coord, unsigned long id);
+ /**
+ * @brief Callback used to set the Host located at some leaf of clusters (Torus, FatTree, etc)
+ *
+ * @param zone: The parent zone, needed for creating new resources (hosts, links)
+ * @param coord: the coordinates of the element
+ * @param id: Internal identifier of the element
+ * @return Host*: returns newly created host
+ */
+ using ClusterHostCb = Host*(NetZone* zone, const std::vector<unsigned long>& coord, unsigned long id);
+
/**
* @brief Callback used to set the links for some leaf of the cluster (Torus, FatTree, etc)
*
*/
using ClusterLinkCb = Link*(NetZone* zone, const std::vector<unsigned long>& coord, unsigned long id);
- std::function<ClusterNetPointCb> netpoint;
+ bool by_netzone_ = false;
+ bool is_by_netzone() const { return by_netzone_; }
+ bool by_netpoint_ = false; // XBT_ATTRIB_DEPRECATED_v339
+ bool is_by_netpoint() const { return by_netpoint_; } // XBT_ATTRIB_DEPRECATED_v339
+ std::function<ClusterNetPointCb> netpoint; // XBT_ATTRIB_DEPRECATED_v339
+ std::function<ClusterHostCb> host;
+ std::function<ClusterNetZoneCb> netzone;
std::function<ClusterLinkCb> loopback = {};
std::function<ClusterLinkCb> limiter = {};
+ explicit ClusterCallbacks(const std::function<ClusterNetZoneCb>& set_netzone)
+ : by_netzone_(true), netzone(set_netzone){/* nothing to do */};
+
+ ClusterCallbacks(const std::function<ClusterNetZoneCb>& set_netzone,
+ const std::function<ClusterLinkCb>& set_loopback, const std::function<ClusterLinkCb>& set_limiter)
+ : by_netzone_(true), netzone(set_netzone), loopback(set_loopback), limiter(set_limiter){/* nothing to do */};
+
+ explicit ClusterCallbacks(const std::function<ClusterHostCb>& set_host)
+ : host(set_host) {/* nothing to do */};
+
+ ClusterCallbacks(const std::function<ClusterHostCb>& set_host,
+ const std::function<ClusterLinkCb>& set_loopback, const std::function<ClusterLinkCb>& set_limiter)
+ : host(set_host), loopback(set_loopback), limiter(set_limiter){/* nothing to do */};
+
+ XBT_ATTRIB_DEPRECATED_v339("Please use callback with either a Host/NetZone creation function as first parameter")
explicit ClusterCallbacks(const std::function<ClusterNetPointCb>& set_netpoint)
- : netpoint(set_netpoint){/*nothing to do */};
+ : by_netpoint_(true), netpoint(set_netpoint){/* nothing to do */};
+ XBT_ATTRIB_DEPRECATED_v339("Please use callback with either a Host/NetZone creation function as first parameter")
ClusterCallbacks(const std::function<ClusterNetPointCb>& set_netpoint,
const std::function<ClusterLinkCb>& set_loopback, const std::function<ClusterLinkCb>& set_limiter)
- : netpoint(set_netpoint), loopback(set_loopback), limiter(set_limiter){/*nothing to do */};
+ : by_netpoint_(true), netpoint(set_netpoint), loopback(set_loopback), limiter(set_limiter){/* nothing to do */};
};
/**
* @brief Create a torus zone
/* 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. */
+#include "simgrid/s4u/Host.hpp"
#include "simgrid/kernel/routing/ClusterZone.hpp"
#include "simgrid/kernel/routing/NetPoint.hpp"
#include "src/kernel/resource/StandardLinkImpl.hpp"
kernel::routing::NetPoint* netpoint = nullptr;
kernel::routing::NetPoint* gw = nullptr;
auto dims = index_to_dims(position);
- std::tie(netpoint, gw) = set_callbacks.netpoint(get_iface(), dims, position);
+ if (set_callbacks.is_by_netpoint()) { // XBT_ATTRIB_DEPRECATED_v339
+ std::tie(netpoint, gw) = set_callbacks.netpoint(get_iface(), dims, position); // XBT_ATTRIB_DEPRECATED_v339
+ } else if (set_callbacks.is_by_netzone()) {
+ s4u::NetZone* netzone = set_callbacks.netzone(get_iface(), dims, position);
+ netpoint = netzone->get_netpoint();
+ gw = netzone->get_gateway();
+ } else {
+ s4u::Host* host = set_callbacks.host(get_iface(), dims, position);
+ netpoint = host->get_netpoint();
+ }
+
xbt_assert(netpoint, "set_netpoint(elem=%lu): Invalid netpoint (nullptr)", position);
if (netpoint->is_netzone()) {
xbt_assert(gw && not gw->is_netzone(),
#ifndef NETZONE_TEST_HPP
#define NETZONE_TEST_HPP
-#include "simgrid/kernel/routing/NetPoint.hpp"
-#include "simgrid/s4u/Host.hpp"
#include "simgrid/s4u/NetZone.hpp"
+#include "xbt/log.h"
+XBT_LOG_EXTERNAL_CATEGORY(ker_platform);
// Callback function common to several routing unit tests
struct CreateHost {
- std::pair<simgrid::kernel::routing::NetPoint*, simgrid::kernel::routing::NetPoint*>
- operator()(simgrid::s4u::NetZone* zone, const std::vector<unsigned long>& /*coord*/, unsigned long id) const
+ simgrid::s4u::NetZone* operator()(simgrid::s4u::NetZone* zone, const std::vector<unsigned long>& /*coord*/,
+ unsigned long id) const
{
- const simgrid::s4u::Host* host = zone->create_host(std::to_string(id), 1e9)->seal();
- return std::make_pair(host->get_netpoint(), nullptr);
+ XBT_CINFO(ker_platform,"PROUT");
+ auto* host_zone = simgrid::s4u::create_empty_zone("zone-" +std::to_string(id))->set_parent(zone);
+ host_zone->create_host(std::to_string(id), "1Gf");
+ host_zone->seal();
+ return host_zone;
}
};
/*************************************************************************************************/
/** @brief Auxiliary function to create hosts */
-static std::pair<simgrid::kernel::routing::NetPoint*, simgrid::kernel::routing::NetPoint*>
+static simgrid::s4u::Host*
sg_platf_cluster_create_host(const simgrid::kernel::routing::ClusterCreationArgs* cluster, simgrid::s4u::NetZone* zone,
const std::vector<unsigned long>& /*coord*/, unsigned long id)
{
std::string host_id = cluster->prefix + std::to_string(cluster->radicals[id]) + cluster->suffix;
XBT_DEBUG("Cluster: creating host=%s speed=%f", host_id.c_str(), cluster->speeds.front());
- const simgrid::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);
+ simgrid::s4u::Host* host = zone->create_host(host_id, cluster->speeds)
+ ->set_core_count(cluster->core_amount)
+ ->set_properties(cluster->properties);
+ return host;
}
/** @brief Auxiliary function to create loopback links */
using simgrid::kernel::routing::FatTreeZone;
using simgrid::kernel::routing::TorusZone;
- auto set_host = std::bind(sg_platf_cluster_create_host, cluster, _1, _2, _3);
+ std::function<simgrid::s4u::ClusterCallbacks::ClusterHostCb> set_host =
+ std::bind(sg_platf_cluster_create_host, cluster, _1, _2, _3);
std::function<simgrid::s4u::ClusterCallbacks::ClusterLinkCb> set_loopback{};
std::function<simgrid::s4u::ClusterCallbacks::ClusterLinkCb> set_limiter{};