#define SIMGRID_S4U_NETZONE_HPP
#include <simgrid/forward.h>
+#include <simgrid/s4u/Link.hpp>
#include <xbt/graph.h>
#include <xbt/signal.hpp>
static xbt::signal<void(NetZone const&)> on_seal;
/**
- * @brief Create a Host
+ * @brief Create a host
*
- * @param name Host name
+ * @param name Host name
* @param speed_per_state Vector of CPU's speeds
*/
s4u::Host* create_host(const std::string& name, const std::vector<double>& speed_per_pstate);
/** @brief Create a Host (string version) */
s4u::Host* create_host(const std::string& name, const std::vector<std::string>& speed_per_pstate);
+
+ /**
+ * @brief Create a link
+ *
+ * @param name Link name
+ * @param bandwidths Link's speed (vector for wifi links)
+ * @param policy Link sharing policy
+ */
+ s4u::Link* create_link(const std::string& name, const std::vector<double>& bandwidths,
+ Link::SharingPolicy policy = Link::SharingPolicy::SHARED);
+
+ /** @brief Create a link (string version) */
+ s4u::Link* create_link(const std::string& name, const std::vector<std::string>& bandwidths,
+ Link::SharingPolicy policy = Link::SharingPolicy::SHARED);
};
// External constructors so that the types (and the types of their content) remain hidden
std::vector<double> Host::convert_pstate_speed_vector(const std::vector<std::string>& speed_per_state)
{
- std::vector<double> speed_list(speed_per_state.size());
+ std::vector<double> speed_list;
+ speed_list.reserve(speed_per_state.size());
for (const auto& speed_str : speed_per_state) {
try {
double speed = xbt_parse_get_speed("", 0, speed_str.c_str(), nullptr, "");
/* 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/Exception.hpp"
#include "simgrid/kernel/routing/NetPoint.hpp"
#include "simgrid/s4u/Engine.hpp"
#include "simgrid/s4u/Host.hpp"
#include "simgrid/s4u/NetZone.hpp"
#include "simgrid/simix.hpp"
#include "simgrid/zone.h"
+#include "xbt/parse_units.hpp"
namespace simgrid {
namespace s4u {
{
return create_host(name, Host::convert_pstate_speed_vector(speed_per_pstate));
}
+
+s4u::Link* NetZone::create_link(const std::string& name, const std::vector<double>& bandwidths,
+ s4u::Link::SharingPolicy policy)
+{
+ return kernel::actor::simcall(
+ [this, &name, &bandwidths, &policy] { return pimpl_->create_link(name, bandwidths, policy); });
+}
+
+s4u::Link* NetZone::create_link(const std::string& name, const std::vector<std::string>& bandwidths,
+ s4u::Link::SharingPolicy policy)
+{
+ std::vector<double> bw;
+ bw.reserve(bandwidths.size());
+ for (const auto& speed_str : bandwidths) {
+ try {
+ double speed = xbt_parse_get_bandwidth("", 0, speed_str.c_str(), nullptr, "");
+ bw.push_back(speed);
+ } catch (const simgrid::ParseError&) {
+ xbt_die("Link: Impossible to create_link, invalid bandwidth %s", speed_str.c_str());
+ }
+ }
+ return create_link(name, bw, policy);
+}
+
} // namespace s4u
} // namespace simgrid