public:
/** @brief Possible update mechanisms */
enum class UpdateAlgo {
- Full, /**< Full update mechanism: the remaining time of every action is recomputed at each step */
- Lazy, /**< Lazy update mechanism: only the modified actions get recomputed.
- It may be slower than full if your system is tightly coupled to the point where every action
- gets recomputed anyway. In that case, you'd better not try to be cleaver with lazy and go for
- a simple full update. */
- Undefined /**< Mechanism not defined */
+ Full, /**< Full update mechanism: the remaining time of every action is recomputed at each step */
+ Lazy /**< Lazy update mechanism: only the modified actions get recomputed.
+ It may be slower than full if your system is tightly coupled to the point where every action
+ gets recomputed anyway. In that case, you'd better not try to be cleaver with lazy and go for
+ a simple full update. */
};
- Model();
- Model(Model::UpdateAlgo algo);
+ explicit Model(Model::UpdateAlgo algo);
virtual ~Model();
void set_maxmin_system(lmm::System* system) { maxmin_system_ = system; }
/** @brief Get the update mechanism of the current Model */
- UpdateAlgo getUpdateMechanism() const { return update_mechanism_; }
- void setUpdateMechanism(UpdateAlgo mechanism) { update_mechanism_ = mechanism; }
+ UpdateAlgo getUpdateMechanism() const { return update_algorithm_; }
/** @brief Get Action heap */
heap_type& getActionHeap() { return action_heap_; }
private:
lmm::System* maxmin_system_ = nullptr;
- UpdateAlgo update_mechanism_ = UpdateAlgo::Undefined;
+ const UpdateAlgo update_algorithm_;
Action::StateSet* ready_action_set_ = new Action::StateSet(); /**< Actions in state SURF_ACTION_READY */
Action::StateSet* running_action_set_ = new Action::StateSet(); /**< Actions in state SURF_ACTION_RUNNING */
Action::StateSet* failed_action_set_ = new Action::StateSet(); /**< Actions in state SURF_ACTION_FAILED */
namespace kernel {
namespace resource {
-Model::Model() = default;
-Model::Model(Model::UpdateAlgo algo) : update_mechanism_(algo) {}
+Model::Model(Model::UpdateAlgo algo) : update_algorithm_(algo) {}
Model::~Model()
{
double Model::next_occuring_event(double now)
{
// FIXME: set the good function once and for all
- if (update_mechanism_ == Model::UpdateAlgo::Lazy)
+ if (update_algorithm_ == Model::UpdateAlgo::Lazy)
return next_occuring_event_lazy(now);
- else if (update_mechanism_ == Model::UpdateAlgo::Full)
+ else if (update_algorithm_ == Model::UpdateAlgo::Full)
return next_occuring_event_full(now);
else
xbt_die("Invalid cpu update mechanism!");
void Model::update_actions_state(double now, double delta)
{
- if (update_mechanism_ == Model::UpdateAlgo::Full)
+ if (update_algorithm_ == Model::UpdateAlgo::Full)
update_actions_state_full(now, delta);
- else if (update_mechanism_ == Model::UpdateAlgo::Lazy)
+ else if (update_algorithm_ == Model::UpdateAlgo::Lazy)
update_actions_state_lazy(now, delta);
else
xbt_die("Invalid cpu update mechanism!");
*/
class XBT_PRIVATE HostModel : public kernel::resource::Model {
public:
- HostModel() : Model() {}
+ HostModel() : Model(Model::UpdateAlgo::Full) {}
virtual void ignore_empty_vm_in_pm_LMM();
virtual kernel::resource::Action* execute_parallel(int host_nb, sg_host_t* host_list, double* flops_amount,
* Model *
*********/
-StorageModel::StorageModel() : Model()
+StorageModel::StorageModel() : Model(Model::UpdateAlgo::Full)
{
set_maxmin_system(new simgrid::kernel::lmm::System(true /* selective update */));
}
class CpuCas01Model : public simgrid::surf::CpuModel {
public:
- CpuCas01Model(kernel::resource::Model::UpdateAlgo algo);
+ explicit CpuCas01Model(kernel::resource::Model::UpdateAlgo algo);
~CpuCas01Model() override;
Cpu *createCpu(simgrid::s4u::Host *host, std::vector<double> *speedPerPstate, int core) override;
*/
class XBT_PUBLIC CpuModel : public kernel::resource::Model {
public:
- CpuModel(kernel::resource::Model::UpdateAlgo algo) : Model(algo) {}
- CpuModel() : Model() {}
+ explicit CpuModel(kernel::resource::Model::UpdateAlgo algo) : Model(algo) {}
/**
* @brief Create a Cpu
*********/
class CpuTiModel : public CpuModel {
public:
- CpuTiModel() = default;
+ CpuTiModel() : CpuModel(Model::UpdateAlgo::Full){};
~CpuTiModel() override;
Cpu* createCpu(simgrid::s4u::Host* host, std::vector<double>* speed_per_pstate, int core) override;
double next_occuring_event(double now) override;
namespace simgrid {
namespace surf {
-NetworkCm02Model::NetworkCm02Model(kernel::lmm::System* (*make_new_lmm_system)(bool)) : NetworkModel()
+NetworkCm02Model::NetworkCm02Model(kernel::lmm::System* (*make_new_lmm_system)(bool))
+ : NetworkModel(xbt_cfg_get_string("network/optim") == "Full" ? kernel::resource::Model::UpdateAlgo::Full
+ : kernel::resource::Model::UpdateAlgo::Lazy)
{
std::string optim = xbt_cfg_get_string("network/optim");
bool select = xbt_cfg_get_boolean("network/maxmin-selective-update");
- if (optim == "Full") {
- setUpdateMechanism(kernel::resource::Model::UpdateAlgo::Full);
- } else if (optim == "Lazy") {
+ if (optim == "Lazy") {
xbt_assert(select || xbt_cfg_is_default_value("network/maxmin-selective-update"),
"You cannot disable network selective update when using the lazy update mechanism");
select = true;
- setUpdateMechanism(kernel::resource::Model::UpdateAlgo::Lazy);
- } else {
- xbt_die("Unsupported optimization (%s) for this model. Accepted: Full, Lazy.", optim.c_str());
}
set_maxmin_system(make_new_lmm_system(select));
*********/
class NetworkConstantModel : public NetworkModel {
public:
+ NetworkConstantModel() : NetworkModel(Model::UpdateAlgo::Full) {}
kernel::resource::Action* communicate(simgrid::s4u::Host* src, simgrid::s4u::Host* dst, double size,
double rate) override;
double next_occuring_event(double now) override;
class NetworkModel : public kernel::resource::Model {
public:
/** @brief Constructor */
- NetworkModel() : Model() {}
+ explicit NetworkModel(kernel::resource::Model::UpdateAlgo algo) : Model(algo) {}
/** @brief Destructor */
~NetworkModel() override;
namespace simgrid {
namespace surf {
-NetworkNS3Model::NetworkNS3Model() : NetworkModel() {
+NetworkNS3Model::NetworkNS3Model() : NetworkModel(Model::UpdateAlgo::Full)
+{
xbt_assert(not sg_link_energy_is_inited(),
"LinkEnergy plugin and NS3 network models are not compatible. Are you looking for Ecofen, maybe?");
delete surf_cpu_model_pm;
}
-CpuL07Model::CpuL07Model(HostL07Model* hmodel, kernel::lmm::System* sys) : CpuModel(), hostModel_(hmodel)
+CpuL07Model::CpuL07Model(HostL07Model* hmodel, kernel::lmm::System* sys)
+ : CpuModel(Model::UpdateAlgo::Full), hostModel_(hmodel)
{
set_maxmin_system(sys);
}
set_maxmin_system(nullptr);
}
-NetworkL07Model::NetworkL07Model(HostL07Model* hmodel, kernel::lmm::System* sys) : NetworkModel(), hostModel_(hmodel)
+NetworkL07Model::NetworkL07Model(HostL07Model* hmodel, kernel::lmm::System* sys)
+ : NetworkModel(Model::UpdateAlgo::Full), hostModel_(hmodel)
{
set_maxmin_system(sys);
loopback_ = NetworkL07Model::createLink("__loopback__", 498000000, 0.000015, SURF_LINK_FATPIPE);