void surf_host_model_init_compound()
{
xbt_assert(surf_cpu_model_pm, "No CPU model defined yet!");
- xbt_assert(surf_network_model, "No network model defined yet!");
- surf_host_model = new simgrid::surf::HostCLM03Model();
+ /* FIXME[donassolo]: this smells bad, but works
+ * (the constructor saves its pointer in all_existing_models and models_by_type :O).
+ * We need a manager for these models */
+ new simgrid::surf::HostCLM03Model();
}
namespace simgrid {
/* } */
void surf_network_model_init_LegrandVelho()
{
- xbt_assert(surf_network_model == nullptr, "Cannot set the network model twice");
-
- surf_network_model = new simgrid::kernel::resource::NetworkCm02Model();
+ /* FIXME[donassolo]: this smells bad, but works
+ * (the constructor saves its pointer in all_existing_models and models_by_type :O).
+ * We need a manager for these models */
+ new simgrid::kernel::resource::NetworkCm02Model();
simgrid::config::set_default<double>("network/latency-factor", 13.01);
simgrid::config::set_default<double>("network/bandwidth-factor", 0.97);
/* } */
void surf_network_model_init_CM02()
{
- xbt_assert(surf_network_model == nullptr, "Cannot set the network model twice");
-
simgrid::config::set_default<double>("network/latency-factor", 1.0);
simgrid::config::set_default<double>("network/bandwidth-factor", 1.0);
simgrid::config::set_default<double>("network/weight-S", 0.0);
- surf_network_model = new simgrid::kernel::resource::NetworkCm02Model();
+ /* FIXME[donassolo]: this smells bad, but works
+ * (the constructor saves its pointer in all_existing_models and models_by_type :O).
+ * We need a manager for these models */
+ new simgrid::kernel::resource::NetworkCm02Model();
}
namespace simgrid {
*********/
void surf_network_model_init_Constant()
{
- xbt_assert(surf_network_model == nullptr);
- surf_network_model = new simgrid::kernel::resource::NetworkConstantModel();
+ /* FIXME[donassolo]: this smells bad, but works
+ * (the constructor saves its pointer in all_existing_models and models_by_type :O).
+ * We need a manager for these models */
+ new simgrid::kernel::resource::NetworkConstantModel();
}
namespace simgrid {
/* } */
void surf_network_model_init_IB()
{
- xbt_assert(surf_network_model == nullptr, "Cannot set the network model twice");
-
- surf_network_model = new simgrid::kernel::resource::NetworkIBModel();
+ /* FIXME[donassolo]: this smells bad, but works
+ * (the constructor saves its pointer in all_existing_models and models_by_type :O).
+ * We need a manager for these models */
+ new simgrid::kernel::resource::NetworkIBModel();
simgrid::s4u::Link::on_communication_state_change.connect(IB_action_state_changed_callback);
simgrid::s4u::Link::on_communicate.connect(IB_action_init_callback);
simgrid::s4u::Host::on_creation.connect(IB_create_host_callback);
* Model *
*********/
-simgrid::kernel::resource::NetworkModel* surf_network_model = nullptr;
-
namespace simgrid {
namespace kernel {
namespace resource {
} // namespace kernel
} // namespace simgrid
-/** @ingroup SURF_models
- * @brief The network model
- */
-XBT_PUBLIC_DATA simgrid::kernel::resource::NetworkModel* surf_network_model;
-
#endif /* SURF_NETWORK_INTERFACE_HPP_ */
*********/
void surf_network_model_init_NS3()
{
- xbt_assert(surf_network_model == nullptr, "Cannot set the network model twice");
-
- surf_network_model = new simgrid::kernel::resource::NetworkNS3Model();
+ /* FIXME[donassolo]: this smells bad, but works
+ * (the constructor saves its pointer in all_existing_models and models_by_type :O).
+ * We need a manager for these models */
+ new simgrid::kernel::resource::NetworkNS3Model();
}
static simgrid::config::Flag<std::string>
/* } */
void surf_network_model_init_SMPI()
{
- if (surf_network_model)
- return;
- surf_network_model = new simgrid::kernel::resource::NetworkSmpiModel();
+ /* FIXME[donassolo]: this smells bad, but works
+ * (the constructor saves its pointer in all_existing_models and models_by_type :O).
+ * We need a manager for these models */
+ new simgrid::kernel::resource::NetworkSmpiModel();
simgrid::config::set_default<double>("network/weight-S", 8775);
}
{
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");
surf_host_model = new simgrid::surf::HostL07Model();
all_existing_models.push_back(surf_host_model);
{
auto* maxmin_system = new simgrid::kernel::lmm::FairBottleneck(true /* selective update */);
set_maxmin_system(maxmin_system);
- surf_network_model = new NetworkL07Model(this, maxmin_system);
- surf_cpu_model_pm = new CpuL07Model(this, maxmin_system);
+ network_model_ = std::make_unique<NetworkL07Model>(this, maxmin_system);
+ models_by_type[simgrid::kernel::resource::Model::Type::NETWORK].push_back(network_model_.get());
+ cpu_model_pm_ = std::make_unique<CpuL07Model>(this, maxmin_system);
+ surf_cpu_model_pm = cpu_model_pm_.get();
}
-HostL07Model::~HostL07Model()
-{
- delete surf_network_model;
- delete surf_cpu_model_pm;
-}
+HostL07Model::~HostL07Model() {}
CpuL07Model::CpuL07Model(HostL07Model* hmodel, kernel::lmm::System* sys)
: CpuModel(Model::UpdateAlgo::FULL), hostModel_(hmodel)
void update_actions_state(double now, double delta) override;
kernel::resource::CpuAction* execute_parallel(const std::vector<s4u::Host*>& host_list, const double* flops_amount,
const double* bytes_amount, double rate) override;
+
+private:
+ std::unique_ptr<NetworkL07Model> network_model_;
+ std::unique_ptr<CpuL07Model> cpu_model_pm_;
};
class CpuL07Model : public kernel::resource::CpuModel {
/* search the routing model */
simgrid::kernel::routing::NetZoneImpl* new_zone = nullptr;
simgrid::kernel::resource::NetworkModel* netmodel =
- current_routing == nullptr ? surf_network_model : current_routing->network_model_;
+ current_routing == nullptr ? static_cast<simgrid::kernel::resource::NetworkModel*>(
+ models_by_type[simgrid::kernel::resource::Model::Type::NETWORK][0])
+ : 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) {