X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/3eb46e730c0eeedb08609b2303d288a140934ded..88ed441e729f7c69e091ebcfb4404fead8676f66:/src/surf/cpu_ti.hpp diff --git a/src/surf/cpu_ti.hpp b/src/surf/cpu_ti.hpp index 76017eba7a..014789a0fc 100644 --- a/src/surf/cpu_ti.hpp +++ b/src/surf/cpu_ti.hpp @@ -3,15 +3,13 @@ /* 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 - -#include +#ifndef SURF_MODEL_CPUTI_H_ +#define SURF_MODEL_CPUTI_H_ #include "src/surf/cpu_interface.hpp" #include "src/surf/trace_mgr.hpp" -/* Epsilon */ -#define EPSILON 0.000000001 +#include namespace simgrid { namespace surf { @@ -42,16 +40,15 @@ public: int binary_search(double* array, double a, int low, int high); }; -enum trace_type { - - TRACE_FIXED, /*< Trace fixed, no availability file */ - TRACE_DYNAMIC /*< Dynamic, have an availability file */ -}; - class CpuTiTmgr { + enum class Type { + FIXED, /*< Trace fixed, no availability file */ + DYNAMIC /*< Dynamic, have an availability file */ + }; + public: - CpuTiTmgr(trace_type type, double value) : type_(type), value_(value){}; - CpuTiTmgr(tmgr_trace_t speedTrace, double value); + explicit CpuTiTmgr(double value) : type_(Type::FIXED), value_(value){}; + CpuTiTmgr(tmgr_trace_t speed_trace, double value); CpuTiTmgr(const CpuTiTmgr&) = delete; CpuTiTmgr& operator=(const CpuTiTmgr&) = delete; ~CpuTiTmgr(); @@ -60,7 +57,8 @@ public: double solve(double a, double amount); double get_power_scale(double a); - trace_type type_; +private: + Type type_; double value_; /*< Percentage of cpu speed available. Value fixed between 0 and 1 */ /* Dynamic */ @@ -78,10 +76,10 @@ public: class XBT_PRIVATE CpuTiAction : public CpuAction { friend class CpuTi; public: - CpuTiAction(CpuTiModel *model, double cost, bool failed, CpuTi *cpu); + CpuTiAction(CpuTi* cpu, double cost); ~CpuTiAction(); - void set_state(simgrid::kernel::resource::Action::State state) override; + void set_state(kernel::resource::Action::State state) override; void cancel() override; void suspend() override; void resume() override; @@ -113,13 +111,13 @@ public: bool is_used() override; CpuAction *execution_start(double size) override; - simgrid::kernel::resource::Action* execution_start(double size, int requestedCores) override + simgrid::kernel::resource::Action* execution_start(double size, int requested_cores) override { THROW_UNIMPLEMENTED; return nullptr; } CpuAction *sleep(double duration) override; - double get_available_speed() override; + double get_speed_ratio() override; void set_modified(bool modified); @@ -128,8 +126,6 @@ public: double sum_priority_ = 0; /*< the sum of actions' priority that are running on cpu */ double last_update_ = 0; /*< last update of actions' remaining amount done */ - double current_frequency_; - boost::intrusive::list_member_hook<> cpu_ti_hook; }; @@ -141,15 +137,18 @@ typedef boost::intrusive::list CpuTiList; *********/ class CpuTiModel : public CpuModel { public: - CpuTiModel() : CpuModel(Model::UpdateAlgo::Full){}; + static void create_pm_vm_models(); // Make both models be TI models + + CpuTiModel(); ~CpuTiModel() override; - Cpu* createCpu(simgrid::s4u::Host* host, std::vector* speed_per_pstate, int core) override; + Cpu* create_cpu(simgrid::s4u::Host* host, std::vector* speed_per_pstate, int core) override; double next_occuring_event(double now) override; void update_actions_state(double now, double delta) override; - kernel::resource::Action::StateSet runningActionSetThatDoesNotNeedBeingChecked_; CpuTiList modified_cpus_; }; } } + +#endif /* SURF_MODEL_CPUTI_H_ */