-/* Copyright (c) 2013-2018. The SimGrid Team. All rights reserved. */
+/* Copyright (c) 2013-2019. The SimGrid Team. All rights reserved. */
/* 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 <boost/intrusive/list.hpp>
-
-#include <xbt/base.h>
+#ifndef SURF_MODEL_CPUTI_H_
+#define SURF_MODEL_CPUTI_H_
+#include "src/kernel/resource/profile/trace_mgr.hpp"
#include "src/surf/cpu_interface.hpp"
-#include "src/surf/trace_mgr.hpp"
-/* Epsilon */
-#define EPSILON 0.000000001
+#include <boost/intrusive/list.hpp>
namespace simgrid {
namespace surf {
/*********
* Trace *
*********/
-class CpuTiTrace {
+class CpuTiProfile {
public:
- explicit CpuTiTrace(tmgr_trace_t speedTrace);
- CpuTiTrace(const CpuTiTrace&) = delete;
- CpuTiTrace& operator=(const CpuTiTrace&) = delete;
- ~CpuTiTrace();
+ explicit CpuTiProfile(kernel::profile::Profile* profile);
+ CpuTiProfile(const CpuTiProfile&) = delete;
+ CpuTiProfile& operator=(const CpuTiProfile&) = delete;
+ ~CpuTiProfile();
double integrate_simple(double a, double b);
double integrate_simple_point(double a);
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(kernel::profile::Profile* speed_profile, double value);
CpuTiTmgr(const CpuTiTmgr&) = delete;
CpuTiTmgr& operator=(const CpuTiTmgr&) = delete;
~CpuTiTmgr();
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 */
double last_time_ = 0.0; /*< Integral interval last point (discrete time) */
double total_ = 0.0; /*< Integral total between 0 and last_pointn */
- CpuTiTrace *trace_ = nullptr;
- tmgr_trace_t speed_trace_ = nullptr;
+ CpuTiProfile* profile_ = nullptr;
+ kernel::profile::Profile* speed_profile_ = nullptr;
};
/**********
CpuTi(CpuTiModel* model, simgrid::s4u::Host* host, std::vector<double>* speed_per_pstate, int core);
~CpuTi() override;
- void set_speed_trace(tmgr_trace_t trace) override;
+ void set_speed_profile(kernel::profile::Profile* profile) override;
- void apply_event(tmgr_trace_event_t event, double value) override;
+ void apply_event(kernel::profile::Event* event, double value) override;
void update_actions_finish_time(double now);
void update_remaining_amount(double now);
bool is_used() override;
CpuAction *execution_start(double size) override;
- simgrid::kernel::resource::Action* execution_start(double size, int requestedCores) override
+ kernel::resource::Action* execution_start(double, int) 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);
*********/
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<double>* speed_per_pstate, int core) override;
+ Cpu* create_cpu(simgrid::s4u::Host* host, std::vector<double>* 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_ */