diff options
| author | MDBijman <matthijs@bijman.org> | 2017-01-24 12:15:26 +0100 |
|---|---|---|
| committer | MDBijman <matthijs@bijman.org> | 2017-01-24 12:15:26 +0100 |
| commit | 070ce923574dcc57435cb3fb2dfe86b6a38cd249 (patch) | |
| tree | ffd69a842ac4ad22aaf7161f923b9f0b47c7147a /Simulator/include/modeling/machine | |
Initial code commit with organized dependencies
Diffstat (limited to 'Simulator/include/modeling/machine')
| -rw-r--r-- | Simulator/include/modeling/machine/CPU.h | 34 | ||||
| -rw-r--r-- | Simulator/include/modeling/machine/GPU.h | 33 | ||||
| -rw-r--r-- | Simulator/include/modeling/machine/Machine.h | 112 |
3 files changed, 179 insertions, 0 deletions
diff --git a/Simulator/include/modeling/machine/CPU.h b/Simulator/include/modeling/machine/CPU.h new file mode 100644 index 00000000..dce4d2c5 --- /dev/null +++ b/Simulator/include/modeling/machine/CPU.h @@ -0,0 +1,34 @@ +#pragma once + +namespace Modeling +{ + class CPU + { + public: + CPU(int speed, int cores, int energyConsumption, int failureModelId); + + /* + Returns the speed of this CPU. + */ + int getSpeed(); + + /* + Returns the nr of cores of this CPU. + */ + int getCores(); + + /* + Returns the energy consumed by this CPU. + */ + int getEnergyConsumption(); + + /* + Returns the failure model id of this CPU. + */ + int getFailureModelId(); + + + private: + int speed, cores, energyConsumption, failureModelId; + }; +} diff --git a/Simulator/include/modeling/machine/GPU.h b/Simulator/include/modeling/machine/GPU.h new file mode 100644 index 00000000..049b928e --- /dev/null +++ b/Simulator/include/modeling/machine/GPU.h @@ -0,0 +1,33 @@ +#pragma once + +namespace Modeling +{ + class GPU + { + public: + GPU(int speed, int cores, int energyConsumption, int failureModelId); + + /* + Returns the speed of this CPU. + */ + int getSpeed(); + + /* + Returns the nr of cores of this CPU. + */ + int getCores(); + + /* + Returns the energy consumed by this CPU. + */ + int getEnergyConsumption(); + + /* + Returns the failure model id of this CPU. + */ + int getFailureModelId(); + + private: + int speed, cores, energyConsumption, failureModelId; + }; +} diff --git a/Simulator/include/modeling/machine/Machine.h b/Simulator/include/modeling/machine/Machine.h new file mode 100644 index 00000000..c89d32d1 --- /dev/null +++ b/Simulator/include/modeling/machine/Machine.h @@ -0,0 +1,112 @@ +#pragma once +#include "simulation/workloads/Workload.h" +#include "modeling/machine/CPU.h" +#include "modeling/machine/GPU.h" + +#include <stdint.h> +#include <vector> +#include <memory> + +namespace Modeling +{ + // Defines the initial temperature of machine + constexpr float ROOM_TEMPERATURE_CELCIUS = 23.0f; + + // Defines the usage of memory by the kernel + constexpr uint32_t KERNEL_MEMORY_USAGE_MB = 50; + + /* + The Machine class models a physical machine in a rack. It has a speed, and can be given a workload on which it will work until finished or interrupted. + */ + class Machine + { + public: + /* + Initializes the machine as idle with the given speed. + */ + Machine(int id); + + /* + Adds a cpu to the list of this machine. + */ + void addCPU(CPU cpu); + + /* + Adds a cpu to the list of this machine. + */ + void addGPU(GPU gpu); + + /* + Gives the task to this machine. If the machine is already busy this does nothing. + */ + void giveTask(Simulation::Workload* workload); + + /* + Returns true if the machine is busy. + */ + bool isBusy() const; + + /* + Does work on the given task and updates temperature and load appropriately. + */ + void work(); + + /* + Returns the id of the current workload of this machine. + */ + int getWorkloadId() const; + + /* + Returns the id of this machine. + */ + int getId() const; + + /* + Returns the temperature of this machine. + */ + float getTemperature() const; + + /* + Returns the memory used by this machine. + */ + int getMemory() const; + + /* + Returns the load fraction on this machine. + */ + float getLoad() const; + + private: + // A list of cpus in this machine. + std::vector<CPU> cpus; + + // A list of gpus in this machine. + std::vector<GPU> gpus; + + // True if the machine is working on a task. + bool busy = false; + + // The current workload the machine is working on. + Simulation::Workload* currentWorkload; + + // Db id of this machine. + int id; + + // Temperature of this machine. + float temperature = ROOM_TEMPERATURE_CELCIUS; + float maxTemperature = 80.0f; + float minTemperature = 0.0f; + float temperatureIncrease = 10.f; + + // Memory used by this machine. + int memory = KERNEL_MEMORY_USAGE_MB; + + // The fraction of load on this machine. + float load = 0.0f; + + /* + Returns the speed of the machine. + */ + uint32_t getSpeed(); + }; +} |
