Get network model from NetZoneImpl instead of using the global.
First step to remove global model variables.
Extra: clang-format modified files.
resource::NetworkModel* network_model_;
+ resource::NetworkModel* get_network_model() const { return network_model_; }
const s4u::NetZone* get_iface() const { return &piface_; }
s4u::NetZone* get_iface() { return &piface_; }
unsigned int get_table_size() const { return vertices_.size(); }
#include "src/kernel/activity/CommImpl.hpp"
#include "simgrid/Exception.hpp"
#include "simgrid/kernel/resource/Action.hpp"
+#include "simgrid/kernel/routing/NetPoint.hpp"
#include "simgrid/modelchecker.h"
#include "simgrid/s4u/Host.hpp"
#include "src/kernel/activity/MailboxImpl.hpp"
from_ = from_ != nullptr ? from_ : src_actor_->get_host();
to_ = to_ != nullptr ? to_ : dst_actor_->get_host();
- surf_action_ = surf_network_model->communicate(from_, to_, size_, rate_);
+ /* FIXME[donassolo]: getting the network_model from the origin host
+ * Soon we need to change this function to first get the routes and later
+ * create the respective surf actions */
+ auto* net_model = from_->get_netpoint()->get_englobing_zone()->get_network_model();
+
+ surf_action_ = net_model->communicate(from_, to_, size_, rate_);
surf_action_->set_activity(this);
surf_action_->set_category(get_tracing_category());
state_ = State::RUNNING;
s4u::Link* NetZoneImpl::create_link(const std::string& name, const std::vector<double>& bandwidths,
s4u::Link::SharingPolicy policy)
{
- auto* l = surf_network_model->create_link(name, bandwidths, policy);
+ auto* l = network_model_->create_link(name, bandwidths, policy);
return l->get_iface();
}
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "src/surf/network_ib.hpp"
+#include "simgrid/kernel/routing/NetPoint.hpp"
#include "simgrid/sg_config.hpp"
#include "src/surf/HostImpl.hpp"
#include "src/surf/xml/platf.hpp"
using simgrid::kernel::resource::NetworkIBModel;
static int id = 0;
-
- ((NetworkIBModel*)surf_network_model)->active_nodes.emplace(host.get_name(), IBNode(id));
+ auto* ibModel = static_cast<NetworkIBModel*>(host.get_netpoint()->get_englobing_zone()->get_network_model());
+ ibModel->active_nodes.emplace(host.get_name(), IBNode(id));
id++;
}
simgrid::kernel::resource::Action::State /*previous*/)
{
using simgrid::kernel::resource::IBNode;
- using simgrid::kernel::resource::NetworkIBModel;
if (action.get_state() != simgrid::kernel::resource::Action::State::FINISHED)
return;
- std::pair<IBNode*, IBNode*> pair = ((NetworkIBModel*)surf_network_model)->active_comms[&action];
+ auto* ibModel = static_cast<simgrid::kernel::resource::NetworkIBModel*>(action.get_model());
+ std::pair<IBNode*, IBNode*> pair = ibModel->active_comms[&action];
XBT_DEBUG("IB callback - action %p finished", &action);
- ((NetworkIBModel*)surf_network_model)->updateIBfactors(&action, pair.first, pair.second, 1);
+ ibModel->updateIBfactors(&action, pair.first, pair.second, 1);
- ((NetworkIBModel*)surf_network_model)->active_comms.erase(&action);
+ ibModel->active_comms.erase(&action);
}
static void IB_action_init_callback(simgrid::kernel::resource::NetworkAction& action)
{
- auto* ibModel = static_cast<simgrid::kernel::resource::NetworkIBModel*>(surf_network_model);
+ auto* ibModel = static_cast<simgrid::kernel::resource::NetworkIBModel*>(action.get_model());
auto* act_src = &ibModel->active_nodes.at(action.get_src().get_name());
auto* act_dst = &ibModel->active_nodes.at(action.get_dst().get_name());
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/host.h"
+#include "simgrid/kernel/routing/NetZoneImpl.hpp" // full type for NetZoneImpl object
+#include "simgrid/zone.h"
#include "src/surf/cpu_interface.hpp"
#include "src/surf/network_interface.hpp"
#include "surf/surf.hpp"
xbt_assert(argc > 1, "Usage: %s platform.xml\n", argv[0]);
parse_platform_file(argv[1]);
+ sg_netzone_t as_zone = sg_zone_get_by_name("AS0");
+ simgrid::kernel::resource::NetworkModel* net_model = as_zone->get_impl()->get_network_model();
+
XBT_DEBUG("CPU model: %p", surf_cpu_model_pm);
- XBT_DEBUG("Network model: %p", surf_network_model);
+ XBT_DEBUG("Network model: %p", net_model);
simgrid::s4u::Host* hostA = sg_host_by_name("Cpu A");
simgrid::s4u::Host* hostB = sg_host_by_name("Cpu B");
XBT_INFO("actionC state: %s", string_action(stateActionC));
/* Let's do something on it */
- surf_network_model->communicate(hostA, hostB, 150.0, -1.0);
+ net_model->communicate(hostA, hostB, 150.0, -1.0);
surf_solve(-1.0);
do {
action.unref();
}
- action_list = surf_network_model->get_failed_action_set();
+ action_list = net_model->get_failed_action_set();
while (not action_list->empty()) {
simgrid::kernel::resource::Action& action = action_list->front();
XBT_INFO(" Network Failed action");
action.unref();
}
- action_list = surf_network_model->get_finished_action_set();
+ action_list = net_model->get_finished_action_set();
while (not action_list->empty()) {
simgrid::kernel::resource::Action& action = action_list->front();
XBT_INFO(" Network Done action");
XBT_DEBUG("\t * Done : %p", &action);
action.unref();
}
- } while (
- (surf_network_model->get_started_action_set()->size() || surf_cpu_model_pm->get_started_action_set()->size()) &&
- surf_solve(-1.0) >= 0.0);
+ } while ((net_model->get_started_action_set()->size() || surf_cpu_model_pm->get_started_action_set()->size()) &&
+ surf_solve(-1.0) >= 0.0);
XBT_DEBUG("Simulation Terminated");
* under the terms of the license (GNU LGPL) which comes with this package. */
#include "simgrid/host.h"
+#include "simgrid/kernel/routing/NetZoneImpl.hpp" // full type for NetZoneImpl object
+#include "simgrid/zone.h"
#include "src/surf/cpu_interface.hpp"
#include "src/surf/network_interface.hpp"
#include "src/surf/surf_interface.hpp"
hostB->pimpl_cpu->execution_start(1000.0);
hostB->pimpl_cpu->sleep(7.32);
- surf_network_model->communicate(hostA, hostB, 150.0, -1.0);
+ sg_netzone_t as_zone = sg_zone_get_by_name("AS0");
+ simgrid::kernel::resource::NetworkModel* net_model = as_zone->get_impl()->get_network_model();
+ net_model->communicate(hostA, hostB, 150.0, -1.0);
surf_solve(-1.0); /* Takes traces into account. Returns 0.0 */
do {