}
/* Setup the communication synchro */
- other_comm->src_actor_ = src_proc;
- other_comm->src_data_ = data;
+ other_comm->src_actor_ = src_proc;
+ other_comm->src_data_ = data;
(*other_comm).set_src_buff(src_buff, src_buff_size).set_size(task_size).set_rate(rate);
other_comm->match_fun = match_fun;
}
/* Setup communication synchro */
- other_comm->dst_actor_ = receiver;
- other_comm->dst_data_ = data;
+ other_comm->dst_actor_ = receiver;
+ other_comm->dst_data_ = data;
other_comm->set_dst_buff(dst_buff, dst_buff_size);
if (rate > -1.0 && (other_comm->get_rate() < 0.0 || rate < other_comm->get_rate()))
DiskImpl* DiskImpl::set_read_constraint(lmm::Constraint* constraint_read)
{
- constraint_read_ = constraint_read;
+ constraint_read_ = constraint_read;
return this;
}
DiskImpl* DiskImpl::set_write_constraint(lmm::Constraint* constraint_write)
{
- constraint_write_ = constraint_write;
+ constraint_write_ = constraint_write;
return this;
}
for (int max = 0; max <= max_index && not bypassedRoute; max++) {
for (int i = 0; i < max && not bypassedRoute; i++) {
if (i <= max_index_src && max <= max_index_dst) {
- key = {path_src.at(i)->netpoint_, path_dst.at(max)->netpoint_};
+ key = {path_src.at(i)->netpoint_, path_dst.at(max)->netpoint_};
auto bpr = bypass_routes_.find(key);
if (bpr != bypass_routes_.end()) {
bypassedRoute = bpr->second;
}
}
if (not bypassedRoute && max <= max_index_src && i <= max_index_dst) {
- key = {path_src.at(max)->netpoint_, path_dst.at(i)->netpoint_};
+ key = {path_src.at(max)->netpoint_, path_dst.at(i)->netpoint_};
auto bpr = bypass_routes_.find(key);
if (bpr != bypass_routes_.end()) {
bypassedRoute = bpr->second;
}
if (not bypassedRoute && max <= max_index_src && max <= max_index_dst) {
- key = {path_src.at(max)->netpoint_, path_dst.at(max)->netpoint_};
+ key = {path_src.at(max)->netpoint_, path_dst.at(max)->netpoint_};
auto bpr = bypass_routes_.find(key);
if (bpr != bypass_routes_.end()) {
bypassedRoute = bpr->second;
XBT_DEBUG("Resolve route from '%s' to '%s'", src->get_cname(), dst->get_cname());
/* Find how src and dst are interconnected */
- NetZoneImpl *common_ancestor;
- NetZoneImpl *src_ancestor;
- NetZoneImpl *dst_ancestor;
+ NetZoneImpl* common_ancestor;
+ NetZoneImpl* src_ancestor;
+ NetZoneImpl* dst_ancestor;
find_common_ancestors(src, dst, &common_ancestor, &src_ancestor, &dst_ancestor);
XBT_DEBUG("elements_father: common ancestor '%s' src ancestor '%s' dst ancestor '%s'", common_ancestor->get_cname(),
src_ancestor->get_cname(), dst_ancestor->get_cname());
{
const s4u::VirtualMachine* vm = get_vm_from_activity(act);
if (vm != nullptr) {
- VirtualMachineImpl *vm_impl = vm->get_impl();
+ VirtualMachineImpl* vm_impl = vm->get_impl();
vm_impl->add_active_exec();
vm_impl->update_action_weight();
}
{
const s4u::VirtualMachine* vm = get_vm_from_activity(act);
if (vm != nullptr) {
- VirtualMachineImpl *vm_impl = vm->get_impl();
+ VirtualMachineImpl* vm_impl = vm->get_impl();
vm_impl->remove_active_exec();
vm_impl->update_action_weight();
}
update_action_weight();
}
-void VirtualMachineImpl::update_action_weight(){
+void VirtualMachineImpl::update_action_weight()
+{
/* The impact of the VM over its PM is the min between its vCPU amount and the amount of tasks it contains */
int impact = std::min(active_execs_, get_core_amount());
action_->set_bound(std::min(impact * physical_host_->get_speed(), user_bound_));
}
-}
-}
+} // namespace vm
+} // namespace simgrid
return requested_core_;
}
-CpuCas01Action::~CpuCas01Action()=default;
+CpuCas01Action::~CpuCas01Action() = default;
} // namespace resource
} // namespace kernel
CpuTiProfile::CpuTiProfile(const profile::Profile* profile)
{
- double integral = 0;
- double time = 0;
+ double integral = 0;
+ double time = 0;
unsigned nb_points = profile->event_list.size() + 1;
time_points_.reserve(nb_points);
integral_.reserve(nb_points);
{
if ((a < 0.0) || (a > b)) {
xbt_die("Error, invalid integration interval [%.2f,%.2f]. "
- "You probably have a task executing with negative computation amount. Check your code.", a, b);
+ "You probably have a task executing with negative computation amount. Check your code.",
+ a, b);
}
if (fabs(a - b) < EPSILON)
return 0.0;
a_index = ceil(a / last_time_);
double b_index = floor(b / last_time_);
- if (a_index > b_index) { /* Same chunk */
+ if (a_index > b_index) { /* Same chunk */
return profile_->integrate_simple(a - (a_index - 1) * last_time_, b - b_index * last_time_);
}
double CpuTiProfile::integrate_simple_point(double a) const
{
double integral = 0;
- double a_aux = a;
+ double a_aux = a;
int ind = binary_search(time_points_, a);
integral += integral_[ind];
/* Sanity checks */
if ((a < 0.0) || (amount < 0.0)) {
- XBT_CRITICAL ("Error, invalid parameters [a = %.2f, amount = %.2f]. "
- "You probably have a task executing with negative computation amount. Check your code.", a, amount);
+ XBT_CRITICAL("Error, invalid parameters [a = %.2f, amount = %.2f]. "
+ "You probably have a task executing with negative computation amount. Check your code.",
+ a, amount);
xbt_abort();
}
*/
double CpuTiTmgr::get_power_scale(double a) const
{
- double reduced_a = a - floor(a / last_time_) * last_time_;
+ double reduced_a = a - floor(a / last_time_) * last_time_;
int point = CpuTiProfile::binary_search(profile_->time_points_, reduced_a);
kernel::profile::DatedValue val = speed_profile_->event_list.at(point);
return val.value_;
surf_network_model->next_occurring_event_is_idempotent() ? surf_network_model->next_occurring_event(now) : -1;
double min_by_dsk = surf_disk_model->next_occurring_event(now);
- XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_dsk %f", this,
- typeid(surf_cpu_model_pm).name(), min_by_cpu, typeid(surf_network_model).name(), min_by_net,
- typeid(surf_disk_model).name(), min_by_dsk);
+ XBT_DEBUG("model %p, %s min_by_cpu %f, %s min_by_net %f, %s min_by_dsk %f", this, typeid(surf_cpu_model_pm).name(),
+ min_by_cpu, typeid(surf_network_model).name(), min_by_net, typeid(surf_disk_model).name(), min_by_dsk);
double res = min_by_cpu;
if (res < 0 || (min_by_net >= 0.0 && min_by_net < res))
XBT_LOG_EXTERNAL_DEFAULT_CATEGORY(res_network);
-double sg_latency_factor = 1.0; /* default value; can be set by model or from command line */
-double sg_bandwidth_factor = 1.0; /* default value; can be set by model or from command line */
-double sg_weight_S_parameter = 0.0; /* default value; can be set by model or from command line */
+double sg_latency_factor = 1.0; /* default value; can be set by model or from command line */
+double sg_bandwidth_factor = 1.0; /* default value; can be set by model or from command line */
+double sg_weight_S_parameter = 0.0; /* default value; can be set by model or from command line */
/************************************************************************/
/* New model based on optimizations discussed during Pedro Velho's thesis*/
action = new NetworkCm02Action(this, *src, *dst, size, failed);
else
action = new NetworkWifiAction(this, *src, *dst, size, failed, src_wifi_link, dst_wifi_link);
- action->sharing_penalty_ = latency;
- action->latency_ = latency;
+ action->sharing_penalty_ = latency;
+ action->latency_ = latency;
action->set_user_bound(rate);
if (is_update_lazy()) {
const kernel::lmm::Variable* var;
const kernel::lmm::Element* elem = nullptr;
const kernel::lmm::Element* nextelem = nullptr;
- int numelem = 0;
+ int numelem = 0;
while ((var = get_constraint()->get_variable_safe(&elem, &nextelem, &numelem))) {
auto* action = static_cast<NetworkCm02Action*>(var->get_id());
action->sharing_penalty_ += delta;
{
latency_check(value);
- double delta = value - latency_.peak;
+ double delta = value - latency_.peak;
const kernel::lmm::Variable* var;
const kernel::lmm::Element* elem = nullptr;
const kernel::lmm::Element* nextelem = nullptr;
- int numelem = 0;
+ int numelem = 0;
latency_.scale = 1.0;
- latency_.peak = value;
+ latency_.peak = value;
while ((var = get_constraint()->get_variable_safe(&elem, &nextelem, &numelem))) {
auto* action = static_cast<NetworkCm02Action*>(var->get_id());
using simgrid::kernel::resource::IBNode;
using simgrid::kernel::resource::NetworkIBModel;
- static int id=0;
+ static int id = 0;
((NetworkIBModel*)surf_network_model)->active_nodes.emplace(host.get_name(), IBNode(id));
id++;
#include "xbt/string.hpp"
#include "xbt/utility.hpp"
+#include <ns3/application-container.h>
#include <ns3/core-module.h>
#include <ns3/csma-helper.h>
+#include <ns3/event-id.h>
#include <ns3/global-route-manager.h>
#include <ns3/internet-stack-helper.h>
#include <ns3/ipv4-address-helper.h>
#include <ns3/packet-sink-helper.h>
#include <ns3/point-to-point-helper.h>
-#include <ns3/application-container.h>
-#include <ns3/event-id.h>
#include "ns3/mobility-module.h"
#include "ns3/wifi-module.h"
static ns3::InternetStackHelper stack;
-static int number_of_links = 1;
+static int number_of_links = 1;
static int number_of_networks = 1;
/* wifi globals */
* Callbacks *
*************/
-static void zoneCreation_cb(simgrid::s4u::NetZone const& zone) {
- simgrid::kernel::routing::WifiZone* wifizone = dynamic_cast<simgrid::kernel::routing::WifiZone*> (zone.get_impl());
- if (wifizone == nullptr) return;
+static void zoneCreation_cb(simgrid::s4u::NetZone const& zone)
+{
+ simgrid::kernel::routing::WifiZone* wifizone = dynamic_cast<simgrid::kernel::routing::WifiZone*>(zone.get_impl());
+ if (wifizone == nullptr)
+ return;
#if NS3_MINOR_VERSION < 32
- wifi.SetStandard(ns3::WIFI_PHY_STANDARD_80211n_5GHZ);
+ wifi.SetStandard(ns3::WIFI_PHY_STANDARD_80211n_5GHZ);
#else
- wifi.SetStandard(ns3::WIFI_STANDARD_80211n_5GHZ);
+ wifi.SetStandard(ns3::WIFI_STANDARD_80211n_5GHZ);
#endif
- std::string ssid = wifizone->get_name();
- const char* mcs = wifizone->get_property("mcs");
- const char* nss = wifizone->get_property("nss");
- int mcs_value = mcs ? atoi(mcs) : 3;
- int nss_value = nss ? atoi(nss) : 1;
+ std::string ssid = wifizone->get_name();
+ const char* mcs = wifizone->get_property("mcs");
+ const char* nss = wifizone->get_property("nss");
+ int mcs_value = mcs ? atoi(mcs) : 3;
+ int nss_value = nss ? atoi(nss) : 1;
#if NS3_MINOR_VERSION < 30
- if(nss_value != 1+(mcs_value/8))
- xbt_die("On NS3 < 3.30, NSS value has to satisfy NSS == 1+(MCS/8) constraint. Bailing out");
+ if (nss_value != 1 + (mcs_value / 8))
+ xbt_die("On NS3 < 3.30, NSS value has to satisfy NSS == 1+(MCS/8) constraint. Bailing out");
#endif
- wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager",
- "ControlMode", ns3::StringValue("HtMcs0"),
- "DataMode", ns3::StringValue("HtMcs" + std::to_string(mcs_value)));
- wifiPhy.SetChannel(wifiChannel.Create());
- wifiPhy.Set("Antennas", ns3::UintegerValue(nss_value));
- wifiPhy.Set("MaxSupportedTxSpatialStreams", ns3::UintegerValue(nss_value));
- wifiPhy.Set("MaxSupportedRxSpatialStreams", ns3::UintegerValue(nss_value));
- wifiMac.SetType("ns3::ApWifiMac",
- "Ssid", ns3::SsidValue(ssid));
-
- mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
- ns3::Ptr<ns3::ListPositionAllocator> positionAllocS = ns3::CreateObject<ns3::ListPositionAllocator>();
- positionAllocS->Add(ns3::Vector(0, 0, 255 * 100 * number_of_networks + 100 * number_of_links));
-
- ns3::NetDeviceContainer netDevices;
- NetPointNs3* access_point_netpoint_ns3 = wifizone->get_access_point()->extension<NetPointNs3>();
-
- ns3::Ptr<ns3::Node> access_point_ns3_node = access_point_netpoint_ns3->ns3_node_;
- ns3::NodeContainer nodes = {access_point_ns3_node};
- std::vector<NetPointNs3*> hosts_netpoints = {access_point_netpoint_ns3};
- netDevices.Add(wifi.Install(wifiPhy, wifiMac,access_point_ns3_node));
-
- wifiMac.SetType ("ns3::StaWifiMac",
- "Ssid", ns3::SsidValue(ssid),
- "ActiveProbing", ns3::BooleanValue(false));
-
- NetPointNs3* station_netpoint_ns3 = nullptr;
- ns3::Ptr<ns3::Node> station_ns3_node = nullptr;
- double distance;
- double angle = 0;
- int nb_stations = wifizone->get_all_hosts().size() - 1;
- double step = 2 * M_PI / nb_stations;
- for (auto station_host : wifizone->get_all_hosts()) {
- station_netpoint_ns3 = station_host->get_netpoint()->extension<NetPointNs3>();
- if (station_netpoint_ns3 == access_point_netpoint_ns3)
- continue;
- hosts_netpoints.push_back(station_netpoint_ns3);
- distance = station_host->get_property("wifi_distance") ? atof(station_host->get_property("wifi_distance")) : 10.0;
- positionAllocS->Add(ns3::Vector(distance * std::cos(angle), distance * std::sin(angle), 255 * 100 * number_of_networks + 100 * number_of_links));
- angle += step;
- station_ns3_node = station_netpoint_ns3->ns3_node_;
- nodes.Add(station_ns3_node);
- netDevices.Add(wifi.Install(wifiPhy, wifiMac, station_ns3_node));
- }
+ wifi.SetRemoteStationManager("ns3::ConstantRateWifiManager", "ControlMode", ns3::StringValue("HtMcs0"), "DataMode",
+ ns3::StringValue("HtMcs" + std::to_string(mcs_value)));
+ wifiPhy.SetChannel(wifiChannel.Create());
+ wifiPhy.Set("Antennas", ns3::UintegerValue(nss_value));
+ wifiPhy.Set("MaxSupportedTxSpatialStreams", ns3::UintegerValue(nss_value));
+ wifiPhy.Set("MaxSupportedRxSpatialStreams", ns3::UintegerValue(nss_value));
+ wifiMac.SetType("ns3::ApWifiMac", "Ssid", ns3::SsidValue(ssid));
+
+ mobility.SetMobilityModel("ns3::ConstantPositionMobilityModel");
+ ns3::Ptr<ns3::ListPositionAllocator> positionAllocS = ns3::CreateObject<ns3::ListPositionAllocator>();
+ positionAllocS->Add(ns3::Vector(0, 0, 255 * 100 * number_of_networks + 100 * number_of_links));
+
+ ns3::NetDeviceContainer netDevices;
+ NetPointNs3* access_point_netpoint_ns3 = wifizone->get_access_point()->extension<NetPointNs3>();
+
+ ns3::Ptr<ns3::Node> access_point_ns3_node = access_point_netpoint_ns3->ns3_node_;
+ ns3::NodeContainer nodes = {access_point_ns3_node};
+ std::vector<NetPointNs3*> hosts_netpoints = {access_point_netpoint_ns3};
+ netDevices.Add(wifi.Install(wifiPhy, wifiMac, access_point_ns3_node));
+
+ wifiMac.SetType("ns3::StaWifiMac", "Ssid", ns3::SsidValue(ssid), "ActiveProbing", ns3::BooleanValue(false));
+
+ NetPointNs3* station_netpoint_ns3 = nullptr;
+ ns3::Ptr<ns3::Node> station_ns3_node = nullptr;
+ double distance;
+ double angle = 0;
+ int nb_stations = wifizone->get_all_hosts().size() - 1;
+ double step = 2 * M_PI / nb_stations;
+ for (auto station_host : wifizone->get_all_hosts()) {
+ station_netpoint_ns3 = station_host->get_netpoint()->extension<NetPointNs3>();
+ if (station_netpoint_ns3 == access_point_netpoint_ns3)
+ continue;
+ hosts_netpoints.push_back(station_netpoint_ns3);
+ distance = station_host->get_property("wifi_distance") ? atof(station_host->get_property("wifi_distance")) : 10.0;
+ positionAllocS->Add(ns3::Vector(distance * std::cos(angle), distance * std::sin(angle),
+ 255 * 100 * number_of_networks + 100 * number_of_links));
+ angle += step;
+ station_ns3_node = station_netpoint_ns3->ns3_node_;
+ nodes.Add(station_ns3_node);
+ netDevices.Add(wifi.Install(wifiPhy, wifiMac, station_ns3_node));
+ }
- const char* start_time = wifizone->get_property("start_time");
- int start_time_value = start_time ? atoi(start_time) : 0;
- for (uint32_t i = 0; i < netDevices.GetN(); i++) {
- ns3::Ptr<ns3::WifiNetDevice> device = ns3::StaticCast<ns3::WifiNetDevice>(netDevices.Get(i));
- device->GetPhy()->SetOffMode();
- ns3::Simulator::Schedule(ns3::Seconds(start_time_value), &resumeWifiDevice, device);
- }
+ const char* start_time = wifizone->get_property("start_time");
+ int start_time_value = start_time ? atoi(start_time) : 0;
+ for (uint32_t i = 0; i < netDevices.GetN(); i++) {
+ ns3::Ptr<ns3::WifiNetDevice> device = ns3::StaticCast<ns3::WifiNetDevice>(netDevices.Get(i));
+ device->GetPhy()->SetOffMode();
+ ns3::Simulator::Schedule(ns3::Seconds(start_time_value), &resumeWifiDevice, device);
+ }
- ns3::Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", ns3::UintegerValue(40));
+ ns3::Config::Set("/NodeList/*/DeviceList/*/$ns3::WifiNetDevice/Phy/ChannelWidth", ns3::UintegerValue(40));
- mobility.SetPositionAllocator(positionAllocS);
- mobility.Install(nodes);
+ mobility.SetPositionAllocator(positionAllocS);
+ mobility.Install(nodes);
- ns3::Ipv4AddressHelper address;
- std::string addr = simgrid::xbt::string_printf("%d.%d.0.0", number_of_networks, number_of_links);
- address.SetBase(addr.c_str(), "255.255.0.0");
- XBT_DEBUG("\tInterface stack '%s'", addr.c_str());
- ns3::Ipv4InterfaceContainer addresses = address.Assign(netDevices);
- for (unsigned int i = 0; i < hosts_netpoints.size(); i++) {
- hosts_netpoints[i]->ipv4_address_ = transformIpv4Address(addresses.GetAddress(i));
- }
+ ns3::Ipv4AddressHelper address;
+ std::string addr = simgrid::xbt::string_printf("%d.%d.0.0", number_of_networks, number_of_links);
+ address.SetBase(addr.c_str(), "255.255.0.0");
+ XBT_DEBUG("\tInterface stack '%s'", addr.c_str());
+ ns3::Ipv4InterfaceContainer addresses = address.Assign(netDevices);
+ for (unsigned int i = 0; i < hosts_netpoints.size(); i++) {
+ hosts_netpoints[i]->ipv4_address_ = transformIpv4Address(addresses.GetAddress(i));
+ }
- if (number_of_links == 255) {
- xbt_assert(number_of_networks < 255, "Number of links and networks exceed 255*255");
- number_of_links = 1;
- number_of_networks++;
- } else {
- number_of_links++;
- }
+ if (number_of_links == 255) {
+ xbt_assert(number_of_networks < 255, "Number of links and networks exceed 255*255");
+ number_of_links = 1;
+ number_of_networks++;
+ } else {
+ number_of_links++;
+ }
}
static void clusterCreation_cb(simgrid::kernel::routing::ClusterCreationArgs const& cluster)
double time_to_next_flow_completion = 0.0;
XBT_DEBUG("ns3_next_occurring_event");
- //get the first relevant value from the running_actions list
+ // get the first relevant value from the running_actions list
// If there is no comms in NS-3, then we do not move it forward.
// We will synchronize NS-3 with SimGrid when starting a new communication.
// NS-3 stops as soon as a flow ends,
// but it does not process the other flows that may finish at the same (simulated) time.
// If another flow ends at the same time, time_to_next_flow_completion = 0
- if(double_equals(time_to_next_flow_completion, 0, sg_surf_precision))
+ if (double_equals(time_to_next_flow_completion, 0, sg_surf_precision))
time_to_next_flow_completion = 0.0;
XBT_DEBUG("min : %f", now);
std::string ns3_socket;
for (const auto& elm : flow_from_sock) {
- ns3_socket = elm.first;
- SgFlow* sgFlow = elm.second;
- NetworkNS3Action * action = sgFlow->action_;
+ ns3_socket = elm.first;
+ SgFlow* sgFlow = elm.second;
+ NetworkNS3Action* action = sgFlow->action_;
XBT_DEBUG("Processing flow %p (socket %s, action %p)", sgFlow, ns3_socket.c_str(), action);
// Because NS3 stops as soon as a flow is finished, the other flows that ends at the same time may remains in an
// inconsistent state (i.e. remains_ == 0 but finished_ == false).
// However, SimGrid considers sometimes that an action with remains_ == 0 is finished.
// Thus, to avoid inconsistencies between SimGrid and NS3, set remains to 0 only when the flow is finished in NS3
int remains = action->get_cost() - sgFlow->sent_bytes_;
- if(remains > 0)
+ if (remains > 0)
action->set_remains(remains);
if (TRACE_is_enabled() && action->get_state() == kernel::resource::Action::State::STARTED) {
action->last_sent_ = sgFlow->sent_bytes_;
}
- if ((sgFlow->finished_) && (remains <= 0)) { // finished_ should not become true before remains gets to 0, but it sometimes does. Let's play safe, here.
+ if ((sgFlow->finished_) && (remains <= 0)) { // finished_ should not become true before remains gets to 0, but it
+ // sometimes does. Let's play safe, here.
socket_to_destroy.push_back(ns3_socket);
XBT_DEBUG("Destroy socket %s of action %p", ns3_socket.c_str(), action);
action->set_remains(0);
}
// If there is no other started actions, we need to move NS-3 forward to be sync with SimGrid
- if (model->get_started_action_set()->size()==1){
- while(double_positive(surf_get_clock() - ns3::Simulator::Now().GetSeconds(), sg_surf_precision)){
- XBT_DEBUG("Synchronizing NS-3 (time %f) with SimGrid (time %f)", ns3::Simulator::Now().GetSeconds(), surf_get_clock());
+ if (model->get_started_action_set()->size() == 1) {
+ while (double_positive(surf_get_clock() - ns3::Simulator::Now().GetSeconds(), sg_surf_precision)) {
+ XBT_DEBUG("Synchronizing NS-3 (time %f) with SimGrid (time %f)", ns3::Simulator::Now().GetSeconds(),
+ surf_get_clock());
ns3_simulator(surf_get_clock() - ns3::Simulator::Now().GetSeconds());
}
}
s4u::Link::on_communicate(*this);
}
-void NetworkNS3Action::suspend() {
+void NetworkNS3Action::suspend()
+{
THROW_UNIMPLEMENTED;
}
-void NetworkNS3Action::resume() {
+void NetworkNS3Action::resume()
+{
THROW_UNIMPLEMENTED;
}
id = ns3::Simulator::Schedule(ns3::Seconds(maxSeconds), &ns3::Simulator::Stop);
XBT_DEBUG("Start simulator for at most %fs (current time: %f)", maxSeconds, surf_get_clock());
- ns3::Simulator::Run ();
+ ns3::Simulator::Run();
XBT_DEBUG("Simulator stopped at %fs", ns3::Simulator::Now().GetSeconds());
- if(maxSeconds > 0.0)
+ if (maxSeconds > 0.0)
id.Cancel();
}
xbt_assert(host_dst != nullptr, "Network element %s does not seem to be ns-3-ready", dst->get_cname());
if (policy == simgrid::s4u::Link::SharingPolicy::WIFI) {
- xbt_die("The wifi sharing policy is not supported for links. You want to use a wifi zone (see documentation).");
+ xbt_die("The wifi sharing policy is not supported for links. You want to use a wifi zone (see documentation).");
} else {
ns3::PointToPointHelper pointToPoint;
/**************************************/
void surf_host_model_init_ptask_L07()
{
- XBT_CINFO(xbt_cfg,"Switching to the L07 model to handle parallel tasks.");
+ XBT_CINFO(xbt_cfg, "Switching to the L07 model to handle parallel tasks.");
xbt_assert(not surf_cpu_model_pm, "Cannot switch to ptasks: CPU model already defined");
xbt_assert(not surf_network_model, "Cannot switch to ptasks: network model already defined");
namespace simgrid {
namespace surf {
-HostL07Model::HostL07Model() : HostModel() {
+HostL07Model::HostL07Model() : HostModel()
+{
auto* maxmin_system = new simgrid::kernel::lmm::FairBottleneck(true /* selective update */);
set_maxmin_system(maxmin_system);
surf_network_model = new NetworkL07Model(this, maxmin_system);
: NetworkModel(Model::UpdateAlgo::FULL), hostModel_(hmodel)
{
set_maxmin_system(sys);
- loopback_ = NetworkL07Model::create_link("__loopback__",
- std::vector<double>{simgrid::config::get_value<double>("network/loopback-bw")},
- s4u::Link::SharingPolicy::FATPIPE)->set_latency(simgrid::config::get_value<double>("network/loopback-lat"));
+ loopback_ = NetworkL07Model::create_link(
+ "__loopback__", std::vector<double>{simgrid::config::get_value<double>("network/loopback-bw")},
+ s4u::Link::SharingPolicy::FATPIPE)
+ ->set_latency(simgrid::config::get_value<double>("network/loopback-lat"));
loopback_->seal();
}
}
/* Need to check that none of the model has failed */
- int i = 0;
+ int i = 0;
const kernel::lmm::Constraint* cnst = action.get_variable()->get_constraint(i);
while (cnst != nullptr) {
i++;
{
size_t link_nb = 0;
size_t used_host_nb = 0; /* Only the hosts with something to compute (>0 flops) are counted) */
- double latency = 0.0;
+ double latency = 0.0;
this->set_last_update();
hostList_.insert(hostList_.end(), host_list.begin(), host_list.end());
used_host_nb += std::count_if(flops_amount, flops_amount + host_list.size(), [](double x) { return x > 0.0; });
/* Compute the number of affected resources... */
- if(bytes_amount != nullptr) {
+ if (bytes_amount != nullptr) {
std::unordered_set<const char*> affected_links;
for (size_t k = 0; k < host_list.size() * host_list.size(); k++) {
std::vector<s4u::Host*> host_list = {get_iface()};
auto* flops_amount = new double[host_list.size()]();
- flops_amount[0] = size;
+ flops_amount[0] = size;
kernel::resource::CpuAction* res =
static_cast<CpuL07Model*>(get_model())->hostModel_->execute_parallel(host_list, flops_amount, nullptr, -1);
{
latency_check(value);
const kernel::lmm::Variable* var;
- L07Action *action;
+ L07Action* action;
const kernel::lmm::Element* elem = nullptr;
latency_.peak = value;
/* 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 "src/surf/HostImpl.hpp"
#include <cstdlib>
#include <vector>
#include <xbt/base.h>
-#include "src/surf/HostImpl.hpp"
#ifndef HOST_L07_HPP_
#define HOST_L07_HPP_
~CpuL07Model() override;
kernel::resource::Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
- HostL07Model *hostModel_;
+ HostL07Model* hostModel_;
};
class NetworkL07Model : public kernel::resource::NetworkModel {
kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
- HostL07Model *hostModel_;
+ HostL07Model* hostModel_;
};
/************
}
/** Module management function: frees all internal data structures */
-void sg_platf_exit() {
+void sg_platf_exit()
+{
simgrid::kernel::routing::on_cluster_creation.disconnect_slots();
simgrid::s4u::Engine::on_platform_created.disconnect_slots();
if (coords && strcmp(coords, ""))
new simgrid::kernel::routing::vivaldi::Coords(netpoint, coords);
-
return netpoint;
}
using simgrid::kernel::routing::FatTreeZone;
using simgrid::kernel::routing::TorusZone;
- int rankId=0;
+ int rankId = 0;
// What an inventive way of initializing the AS that I have as ancestor :-(
simgrid::kernel::routing::ZoneCreationArgs zone;
for (auto const& elm : *cluster->properties)
current_as->get_iface()->set_property(elm.first, elm.second);
- if(cluster->loopback_bw > 0 || cluster->loopback_lat > 0){
+ if (cluster->loopback_bw > 0 || cluster->loopback_lat > 0) {
current_as->num_links_per_node_++;
current_as->has_loopback_ = true;
}
- if(cluster->limiter_link > 0){
+ if (cluster->limiter_link > 0) {
current_as->num_links_per_node_++;
current_as->has_limiter_ = true;
}
}
host.speed_per_pstate = cluster->speeds;
- host.pstate = 0;
- host.core_amount = cluster->core_amount;
- host.coord = "";
+ host.pstate = 0;
+ host.core_amount = cluster->core_amount;
+ host.coord = "";
sg_platf_new_host(&host);
XBT_DEBUG("</host>");
// the second column may store a limiter link if p_has_limiter is set
// other columns are to store one or more link for the node
- //add a loopback link
+ // add a loopback link
const simgrid::s4u::Link* linkUp = nullptr;
const simgrid::s4u::Link* linkDown = nullptr;
- if(cluster->loopback_bw > 0 || cluster->loopback_lat > 0){
+ if (cluster->loopback_bw > 0 || cluster->loopback_lat > 0) {
std::string tmp_link = link_id + "_loopback";
XBT_DEBUG("<loopback\tid=\"%s\"\tbw=\"%f\"/>", tmp_link.c_str(), cluster->loopback_bw);
simgrid::kernel::routing::LinkCreationArgs link;
- link.id = tmp_link;
+ link.id = tmp_link;
link.bandwidths.push_back(cluster->loopback_bw);
- link.latency = cluster->loopback_lat;
- link.policy = simgrid::s4u::Link::SharingPolicy::FATPIPE;
+ link.latency = cluster->loopback_lat;
+ link.policy = simgrid::s4u::Link::SharingPolicy::FATPIPE;
sg_platf_new_link(&link);
linkUp = simgrid::s4u::Link::by_name_or_null(tmp_link);
linkDown = simgrid::s4u::Link::by_name_or_null(tmp_link);
as_cluster->private_links_.insert({as_cluster->node_pos(rankId), {linkUp->get_impl(), linkDown->get_impl()}});
}
- //add a limiter link (shared link to account for maximal bandwidth of the node)
+ // add a limiter link (shared link to account for maximal bandwidth of the node)
linkUp = nullptr;
linkDown = nullptr;
- if(cluster->limiter_link > 0){
+ if (cluster->limiter_link > 0) {
std::string tmp_link = std::string(link_id) + "_limiter";
XBT_DEBUG("<limiter\tid=\"%s\"\tbw=\"%f\"/>", tmp_link.c_str(), cluster->limiter_link);
simgrid::kernel::routing::LinkCreationArgs link;
- link.id = tmp_link;
+ link.id = tmp_link;
link.bandwidths.push_back(cluster->limiter_link);
link.latency = 0;
- link.policy = simgrid::s4u::Link::SharingPolicy::SHARED;
+ link.policy = simgrid::s4u::Link::SharingPolicy::SHARED;
sg_platf_new_link(&link);
linkDown = simgrid::s4u::Link::by_name_or_null(tmp_link);
linkUp = linkDown;
{current_as->node_pos_with_loopback(rankId), {linkUp->get_impl(), linkDown->get_impl()}});
}
- //call the cluster function that adds the others links
+ // call the cluster function that adds the others links
if (cluster->topology == simgrid::kernel::routing::ClusterTopology::FAT_TREE) {
static_cast<FatTreeZone*>(current_as)->add_processing_node(i);
} else {
cluster->router_id = std::string(cluster->prefix) + cluster->id + "_router" + cluster->suffix;
current_as->router_ = sg_platf_new_router(cluster->router_id, nullptr);
- //Make the backbone
+ // Make the backbone
if ((cluster->bb_bw > 0) || (cluster->bb_lat > 0)) {
simgrid::kernel::routing::LinkCreationArgs link;
- link.id = std::string(cluster->id)+ "_backbone";
+ link.id = std::string(cluster->id) + "_backbone";
link.bandwidths.push_back(cluster->bb_bw);
- link.latency = cluster->bb_lat;
- link.policy = cluster->bb_sharing_policy;
+ link.latency = cluster->bb_lat;
+ link.policy = cluster->bb_sharing_policy;
XBT_DEBUG("<link\tid=\"%s\" bw=\"%f\" lat=\"%f\"/>", link.id.c_str(), cluster->bb_bw, cluster->bb_lat);
sg_platf_new_link(&link);
for (int const& radical : *cabinet->radicals) {
std::string hostname = cabinet->prefix + std::to_string(radical) + cabinet->suffix;
simgrid::kernel::routing::HostCreationArgs host;
- host.pstate = 0;
- host.core_amount = 1;
- host.id = hostname;
+ host.pstate = 0;
+ host.core_amount = 1;
+ host.id = hostname;
host.speed_per_pstate.push_back(cabinet->speed);
sg_platf_new_host(&host);
simgrid::kernel::routing::LinkCreationArgs link;
- link.policy = simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX;
- link.latency = cabinet->lat;
+ link.policy = simgrid::s4u::Link::SharingPolicy::SPLITDUPLEX;
+ link.latency = cabinet->lat;
link.bandwidths.push_back(cabinet->bw);
- link.id = "link_" + hostname;
+ link.id = "link_" + hostname;
sg_platf_new_link(&link);
simgrid::kernel::routing::HostLinkCreationArgs host_link;
double kill_time = actor->kill_time;
bool auto_restart = actor->restart_on_failure;
- std::string actor_name = actor->args[0];
+ std::string actor_name = actor->args[0];
simgrid::kernel::actor::ActorCode code = factory(std::move(actor->args));
std::shared_ptr<std::unordered_map<std::string, std::string>> properties(actor->properties);
new_actor->set_auto_restart(auto_restart);
delete arg;
});
- } else { // start_time <= SIMIX_get_clock()
+ } else { // start_time <= SIMIX_get_clock()
XBT_DEBUG("Starting Process %s(%s) right now", arg->name.c_str(), host->get_cname());
try {
simgrid::kernel::resource::NetworkModel* netmodel =
current_routing == nullptr ? surf_network_model : current_routing->network_model_;
if (strcasecmp(zone->routing.c_str(), "Cluster") == 0) {
- new_zone = new simgrid::kernel::routing::ClusterZone(current_routing, zone->id, netmodel);
- } else if (strcasecmp(zone->routing.c_str(),"ClusterDragonfly") == 0) {
- new_zone = new simgrid::kernel::routing::DragonflyZone(current_routing, zone->id, netmodel);
- } else if (strcasecmp(zone->routing.c_str(),"ClusterTorus") == 0) {
- new_zone = new simgrid::kernel::routing::TorusZone(current_routing, zone->id, netmodel);
- } else if (strcasecmp(zone->routing.c_str(),"ClusterFatTree") == 0) {
- new_zone = new simgrid::kernel::routing::FatTreeZone(current_routing, zone->id, netmodel);
- } else if (strcasecmp(zone->routing.c_str(),"Dijkstra") == 0) {
- new_zone = new simgrid::kernel::routing::DijkstraZone(current_routing, zone->id, netmodel, false);
- } else if (strcasecmp(zone->routing.c_str(),"DijkstraCache") == 0) {
- new_zone = new simgrid::kernel::routing::DijkstraZone(current_routing, zone->id, netmodel, true);
- } else if (strcasecmp(zone->routing.c_str(),"Floyd") == 0) {
- new_zone = new simgrid::kernel::routing::FloydZone(current_routing, zone->id, netmodel);
- } else if (strcasecmp(zone->routing.c_str(),"Full") == 0) {
- new_zone = new simgrid::kernel::routing::FullZone(current_routing, zone->id, netmodel);
- } else if (strcasecmp(zone->routing.c_str(),"None") == 0) {
- new_zone = new simgrid::kernel::routing::EmptyZone(current_routing, zone->id, netmodel);
- } else if (strcasecmp(zone->routing.c_str(),"Vivaldi") == 0) {
- new_zone = new simgrid::kernel::routing::VivaldiZone(current_routing, zone->id, netmodel);
+ new_zone = new simgrid::kernel::routing::ClusterZone(current_routing, zone->id, netmodel);
+ } else if (strcasecmp(zone->routing.c_str(), "ClusterDragonfly") == 0) {
+ new_zone = new simgrid::kernel::routing::DragonflyZone(current_routing, zone->id, netmodel);
+ } else if (strcasecmp(zone->routing.c_str(), "ClusterTorus") == 0) {
+ new_zone = new simgrid::kernel::routing::TorusZone(current_routing, zone->id, netmodel);
+ } else if (strcasecmp(zone->routing.c_str(), "ClusterFatTree") == 0) {
+ new_zone = new simgrid::kernel::routing::FatTreeZone(current_routing, zone->id, netmodel);
+ } else if (strcasecmp(zone->routing.c_str(), "Dijkstra") == 0) {
+ new_zone = new simgrid::kernel::routing::DijkstraZone(current_routing, zone->id, netmodel, false);
+ } else if (strcasecmp(zone->routing.c_str(), "DijkstraCache") == 0) {
+ new_zone = new simgrid::kernel::routing::DijkstraZone(current_routing, zone->id, netmodel, true);
+ } else if (strcasecmp(zone->routing.c_str(), "Floyd") == 0) {
+ new_zone = new simgrid::kernel::routing::FloydZone(current_routing, zone->id, netmodel);
+ } else if (strcasecmp(zone->routing.c_str(), "Full") == 0) {
+ new_zone = new simgrid::kernel::routing::FullZone(current_routing, zone->id, netmodel);
+ } else if (strcasecmp(zone->routing.c_str(), "None") == 0) {
+ new_zone = new simgrid::kernel::routing::EmptyZone(current_routing, zone->id, netmodel);
+ } else if (strcasecmp(zone->routing.c_str(), "Vivaldi") == 0) {
+ new_zone = new simgrid::kernel::routing::VivaldiZone(current_routing, zone->id, netmodel);
} else if (strcasecmp(zone->routing.c_str(), "Wifi") == 0) {
new_zone = new simgrid::kernel::routing::WifiZone(current_routing, zone->id, netmodel);
} else {
void surf_presolve()
{
- XBT_DEBUG ("Consume all trace events occurring before the starting time.");
+ XBT_DEBUG("Consume all trace events occurring before the starting time.");
double next_event_date;
while ((next_event_date = simgrid::kernel::profile::future_evt_set.next_date()) != -1.0) {
if (next_event_date > NOW)
}
}
- XBT_DEBUG ("Set every models in the right state by updating them to 0.");
+ XBT_DEBUG("Set every models in the right state by updating them to 0.");
for (auto const& model : all_existing_models)
model->update_actions_state(NOW, 0.0);
}
double surf_solve(double max_date)
{
- double time_delta = -1.0; /* duration */
- double value = -1.0;
+ double time_delta = -1.0; /* duration */
+ double value = -1.0;
simgrid::kernel::resource::Resource* resource = nullptr;
simgrid::kernel::profile::Event* event = nullptr;
}
for (auto const& model : all_existing_models) {
- if (model != surf_host_model && model != surf_vm_model && model != surf_network_model &&
- model != surf_disk_model) {
+ if (model != surf_host_model && model != surf_vm_model && model != surf_network_model && model != surf_disk_model) {
double next_event_model = model->next_occurring_event(NOW);
if ((time_delta < 0.0 || next_event_model < time_delta) && next_event_model >= 0.0)
time_delta = next_event_model;
XBT_DEBUG("This event invalidates the next_occurring_event() computation of models. Next event set to %f",
time_delta);
}
- // FIXME: I'm too lame to update NOW live, so I change it and restore it so that the real update with surf_min will work
+ // FIXME: I'm too lame to update NOW live, so I change it and restore it so that the real update with surf_min
+ // will work
double round_start = NOW;
- NOW = next_event_date;
+ NOW = next_event_date;
/* update state of the corresponding resource to the new value. Does not touch lmm.
It will be modified if needed when updating actions */
XBT_DEBUG("Calling update_resource_state for resource %s", resource->get_cname());
}
}
- /* FIXME: Moved this test to here to avoid stopping simulation if there are actions running on cpus and all cpus are with availability = 0.
- * This may cause an infinite loop if one cpu has a trace with periodicity = 0 and the other a trace with periodicity > 0.
- * The options are: all traces with same periodicity(0 or >0) or we need to change the way how the events are managed */
+ /* FIXME: Moved this test to here to avoid stopping simulation if there are actions running on cpus and all cpus are
+ * with availability = 0. This may cause an infinite loop if one cpu has a trace with periodicity = 0 and the other a
+ * trace with periodicity > 0.
+ * The options are: all traces with same periodicity(0 or >0) or we need to change the way how the events are managed
+ */
if (time_delta < 0) {
XBT_DEBUG("No next event at all. Bail out now.");
return -1.0;
&surf_network_model_init_NS3},
};
-#if ! HAVE_SMPI
-void surf_network_model_init_SMPI() {
+#if !HAVE_SMPI
+void surf_network_model_init_SMPI()
+{
xbt_die("Please activate SMPI support in cmake to use the SMPI network model.");
}
-void surf_network_model_init_IB() {
+void surf_network_model_init_IB()
+{
xbt_die("Please activate SMPI support in cmake to use the IB network model.");
}
#endif
#if !SIMGRID_HAVE_NS3
-void surf_network_model_init_NS3() {
+void surf_network_model_init_NS3()
+{
xbt_die("Please activate ns-3 support in cmake and install the dependencies to use the NS3 network model.");
}
#endif
const std::vector<surf_model_description_t> surf_optimization_mode_description = {
{"Lazy", "Lazy action management (partial invalidation in lmm + heap in action remaining).", nullptr},
- {"TI", "Trace integration. Highly optimized mode when using availability traces (only available for the Cas01 CPU "
- "model for now).",
+ {"TI",
+ "Trace integration. Highly optimized mode when using availability traces (only available for the Cas01 CPU "
+ "model for now).",
nullptr},
{"Full", "Full update of remaining and variables. Slow but may be useful when debugging.", nullptr},
};
FILE* surf_fopen(const std::string& name, const char* mode)
{
- FILE *file = nullptr;
+ FILE* file = nullptr;
if (is_absolute_file_path(name)) /* don't mess with absolute file names */
return fopen(name.c_str(), mode);
return -1;
}
-
-void surf_init(int *argc, char **argv)
+void surf_init(int* argc, char** argv)
{
if (xbt_initialized > 0)
return;
tmgr_finalize();
sg_platf_exit();
- NOW = 0; /* Just in case the user plans to restart the simulation afterward */
+ NOW = 0; /* Just in case the user plans to restart the simulation afterward */
}
}
}
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
- surf_init(&argc, argv); /* Initialize some common structures */
+ surf_init(&argc, argv); /* Initialize some common structures */
simgrid::config::set_parse("cpu/model:Cas01");
simgrid::config::set_parse("network/model:CM02");
XBT_INFO("actionB state: %s", string_action(stateActionB));
XBT_INFO("actionC state: %s", string_action(stateActionC));
-
/* Let's do something on it */
surf_network_model->communicate(hostA, hostB, 150.0, -1.0);
XBT_LOG_NEW_DEFAULT_CATEGORY(surf_test, "Messages specific for surf example");
-int main(int argc, char **argv)
+int main(int argc, char** argv)
{
int running;
- surf_init(&argc, argv); /* Initialize some common structures */
+ surf_init(&argc, argv); /* Initialize some common structures */
simgrid::config::set_parse("network/model:CM02");
simgrid::config::set_parse("cpu/model:Cas01");
surf_network_model->communicate(hostA, hostB, 150.0, -1.0);
- surf_solve(-1.0); /* Takes traces into account. Returns 0.0 */
+ surf_solve(-1.0); /* Takes traces into account. Returns 0.0 */
do {
simgrid::kernel::resource::Action* action = nullptr;
- running = 0;
+ running = 0;
double now = surf_get_clock();
XBT_INFO("Next Event : %g", now);
}
action = model->extract_done_action();
- while (action != nullptr){
+ while (action != nullptr) {
XBT_INFO(" * Done Action");
XBT_DEBUG("\t * Done Action: %p", action);
action->unref();