default_function = code;
}
-void EngineImpl::add_model_ptask(resource::Model::Type type, resource::Model* model, bool is_default)
+void EngineImpl::add_model(resource::Model::Type type, std::shared_ptr<resource::Model> model, bool is_default)
{
if (is_default)
- models_by_type_[type].insert(models_by_type_[type].begin(), model);
+ models_by_type_[type].insert(models_by_type_[type].begin(), model.get());
else
- models_by_type_[type].push_back(model);
-}
+ models_by_type_[type].push_back(model.get());
-void EngineImpl::add_model(resource::Model::Type type, std::shared_ptr<resource::Model> model, bool is_default)
-{
- add_model_ptask(type, model.get(), is_default);
models_.push_back(std::move(model));
}
* @param is_default Is this the default model for this type of resource in this exp
*/
void add_model(resource::Model::Type type, std::shared_ptr<resource::Model> model, bool is_default = false);
- /**
- * @brief Add a model (specific for ptask)
- *
- * Ptask is special. The CPU and NETWORK models need to be in the managed
- * resources by surf_solve (model_by_type) but cannot be in the list of
- * all models (old all_existing_models global variable)
- *
- * This methods does this job while we cannot handle ptask as the remaining models
- */
- void add_model_ptask(resource::Model::Type type, resource::Model* model, bool is_default);
/** @brief Get current default model for a resource type */
resource::Model* get_default_model(resource::Model::Type type) const;
auto* maxmin_system = new simgrid::kernel::lmm::FairBottleneck(true /* selective update */);
set_maxmin_system(maxmin_system);
- net_model_ = std::make_unique<NetworkL07Model>(this, maxmin_system);
- auto engine = simgrid::kernel::EngineImpl::get_instance();
- engine->add_model_ptask(simgrid::kernel::resource::Model::Type::NETWORK, net_model_.get(), true);
+ auto net_model = std::make_shared<NetworkL07Model>(this, maxmin_system);
+ auto engine = simgrid::kernel::EngineImpl::get_instance();
+ engine->add_model(simgrid::kernel::resource::Model::Type::NETWORK, std::move(net_model), true);
- cpu_model_ = std::make_unique<CpuL07Model>(this, maxmin_system);
- engine->add_model_ptask(simgrid::kernel::resource::Model::Type::CPU_PM, cpu_model_.get(), true);
+ auto cpu_model = std::make_shared<CpuL07Model>(this, maxmin_system);
+ engine->add_model(simgrid::kernel::resource::Model::Type::CPU_PM, std::move(cpu_model), true);
}
HostL07Model::~HostL07Model() {}
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> net_model_;
- std::unique_ptr<CpuL07Model> cpu_model_;
};
class CpuL07Model : public kernel::resource::CpuModel {
CpuL07Model(const CpuL07Model&) = delete;
CpuL07Model& operator=(const CpuL07Model&) = delete;
~CpuL07Model() override;
+ /* this action is done by HostL07Model which shares the LMM system with the CPU model
+ * Overriding to an empty function here allows us to handle the Cpu07Model as a regular
+ * method in surf_presolve */
+ void update_actions_state(double now, double delta) override{};
kernel::resource::Cpu* create_cpu(s4u::Host* host, const std::vector<double>& speed_per_pstate) override;
HostL07Model* hostModel_;
s4u::Link::SharingPolicy policy) override;
kernel::resource::Action* communicate(s4u::Host* src, s4u::Host* dst, double size, double rate) override;
+ /* this action is done by HostL07Model which shares the LMM system with the CPU model
+ * Overriding to an empty function here allows us to handle the Cpu07Model as a regular
+ * method in surf_presolve */
+ void update_actions_state(double now, double delta) override{};
HostL07Model* hostModel_;
};