X-Git-Url: http://info.iut-bm.univ-fcomte.fr/pub/gitweb/simgrid.git/blobdiff_plain/a21681e5aca1a37efb2e9001e5055dec94c5de41..f3da0e53f20a27db79c661314020550b7b9d0bcd:/src/surf/cpu_cas01.hpp diff --git a/src/surf/cpu_cas01.hpp b/src/surf/cpu_cas01.hpp index ccac472ce1..da01315ea7 100644 --- a/src/surf/cpu_cas01.hpp +++ b/src/surf/cpu_cas01.hpp @@ -1,93 +1,70 @@ +/* Copyright (c) 2013-2018. 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 "cpu_interface.hpp" +#include "xbt/base.h" /*********** * Classes * ***********/ -class CpuCas01Model; -typedef CpuCas01Model *CpuCas01ModelPtr; -class CpuCas01Lmm; -typedef CpuCas01Lmm *CpuCas01LmmPtr; +namespace simgrid { +namespace surf { -class CpuCas01ActionLmm; -typedef CpuCas01ActionLmm *CpuCas01ActionLmmPtr; +class XBT_PRIVATE CpuCas01Model; +class XBT_PRIVATE CpuCas01; +class XBT_PRIVATE CpuCas01Action; /********* * Model * *********/ -class CpuCas01Model : public CpuModel { -public: - CpuCas01Model(); - ~CpuCas01Model(); - double (CpuCas01Model::*shareResources)(double now); - void (CpuCas01Model::*updateActionsState)(double now, double delta); +class CpuCas01Model : public simgrid::surf::CpuModel { +public: + explicit CpuCas01Model(kernel::resource::Model::UpdateAlgo algo); + ~CpuCas01Model() override; - void parseInit(sg_platf_host_cbarg_t host); - CpuPtr createResource(const char *name, xbt_dynar_t power_peak, int pstate, - double power_scale, - tmgr_trace_t power_trace, int core, - e_surf_resource_state_t state_initial, - tmgr_trace_t state_trace, - xbt_dict_t cpu_properties); - double shareResourcesFull(double now); - void addTraces(); - ActionListPtr p_cpuRunningActionSetThatDoesNotNeedBeingChecked; + Cpu *createCpu(simgrid::s4u::Host *host, std::vector *speedPerPstate, int core) override; }; /************ * Resource * ************/ -/* - * Energy-related properties for the cpu_cas01 model - */ -typedef struct energy_cpu_cas01 { - xbt_dynar_t power_range_watts_list; /*< List of (min_power,max_power) pairs corresponding to each cpu pstate */ - double total_energy; /*< Total energy consumed by the host */ - double last_updated; /*< Timestamp of the last energy update event*/ -} s_energy_cpu_cas01_t, *energy_cpu_cas01_t; -class CpuCas01Lmm : public CpuLmm { -public://FIXME: - tmgr_trace_event_t p_stateEvent; +class CpuCas01 : public Cpu { public: - CpuCas01Lmm(CpuCas01ModelPtr model, const char *name, xbt_dynar_t power_peak, - int pstate, double powerScale, tmgr_trace_t powerTrace, int core, - e_surf_resource_state_t stateInitial, tmgr_trace_t stateTrace, - xbt_dict_t properties) ; - ~CpuCas01Lmm(); - void updateState(tmgr_trace_event_t event_type, double value, double date); - CpuActionPtr execute(double size); - CpuActionPtr sleep(double duration); + CpuCas01(CpuCas01Model *model, simgrid::s4u::Host *host, std::vector *speedPerPstate, int core); + ~CpuCas01() override; + void apply_event(tmgr_trace_event_t event, double value) override; + CpuAction* execution_start(double size) override; + CpuAction* execution_start(double size, int requestedCore) override; + CpuAction* sleep(double duration) override; - xbt_dynar_t getWattsRangeList(); - double getCurrentWattsValue(double cpu_load); - void updateEnergy(double cpu_load); + bool is_used() override; - double getCurrentPowerPeak(); - double getPowerPeakAt(int pstate_index); - int getNbPstates(); - void setPowerPeakAt(int pstate_index); - double getConsumedEnergy(); - - bool isUsed(); - - tmgr_trace_event_t p_powerEvent; - xbt_dynar_t p_powerPeakList; /*< List of supported CPU capacities */ - int m_pstate; /*< Current pstate (index in the power_peak_list)*/ - energy_cpu_cas01_t p_energy; /*< Structure with energy-consumption data */ +protected: + void onSpeedChange() override; }; /********** * Action * **********/ -class CpuCas01ActionLmm: public CpuActionLmm { - friend CpuActionPtr CpuCas01Lmm::execute(double size); - friend CpuActionPtr CpuCas01Lmm::sleep(double duration); +class CpuCas01Action: public CpuAction { + friend CpuAction *CpuCas01::execution_start(double size); + friend CpuAction *CpuCas01::sleep(double duration); public: - CpuCas01ActionLmm() {}; - CpuCas01ActionLmm(ModelPtr model, double cost, bool failed, double power, lmm_constraint_t constraint); + CpuCas01Action(kernel::resource::Model* model, double cost, bool failed, double speed, + kernel::lmm::Constraint* constraint, int coreAmount); + CpuCas01Action(kernel::resource::Model* model, double cost, bool failed, double speed, + kernel::lmm::Constraint* constraint); + ~CpuCas01Action() override; + int requested_core(); - ~CpuCas01ActionLmm() {}; - void updateEnergy(); +private: + int requested_core_ = 1; }; + +} +}