-
Notifications
You must be signed in to change notification settings - Fork 0
/
gpu.h
89 lines (74 loc) · 2.95 KB
/
gpu.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* Copyright (C) 2015 Mountassir El Hafi, ([email protected])
*
* Gpu.h: Part of gmonitor
*
* gmonitor is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License version 3 as
* published by the Free Software Foundation.
*
* gmonitor is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* You should have received a copy of the GNU General Public License
* along with gmonitor. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef GPU_H_
#define GPU_H_
#include <iostream>
#include <vector>
#include "constants.h"
using namespace std;
/*
* This class represents a single graphics card,
* stores, updates and exports all available statistics;
* gpu usage, memory usage ...
*/
class Gpu
{
private:
Graph graph; //a list of previous status of this gpu
std::string gpuId; //gpu id (from Nvidia drivers)
std::string gpuName; //gpu name (from Nvidia drivers)
double totalMemory; //total memory available on this gpu
double usedMemory; //memory used on this gpu
double memoryUsage; //memory usage (%)
double gpuUsage; //gpu usage
double memoryBandwidth; //memory bus usage
double pciBandwidth; //pci-e bus usage
double temperature; //gpu temperature
public:
Gpu(const std::string &id, const std::string &name);
//getters
string getGpuId() { return gpuId; };
string getGpuName() { return gpuName; };
double getTotalMemory() { return totalMemory; };
double getUsedMemory() { return usedMemory; };
double getMemoryUsage() { return memoryUsage; };
double getGpuUsage() { return gpuUsage; };
double getMemoryBandwidth() { return memoryBandwidth;};
double getPciBandwidth() { return pciBandwidth; };
double getTemperature() { return temperature; };
//setters
void setTotalMemory (double value) { totalMemory = value;};
void setUsedMemory (double value) { usedMemory = value;};
void setMemoryUsage (double value) { memoryUsage = value;};
void setGpuUsage (double value) { gpuUsage = value;};
void setMemoryBandwidth(double value) { memoryBandwidth = value;};
void setPciBandwidth (double value) { pciBandwidth = value;};
void setTemperature (double value) { temperature = value;};
//update this gpu's states
void updateAllStates(const GpuStates &state);
//export this gpu's all states
//(current one and all stored in -graph- list)
void exportAllStates(vector<GpuStates> *states) const;
//export this gpu's current states
void exportCurrentState(GpuStates *state) const;
//create an empty list of states
void createGraph();
//print all previous states
void dumpGraph() const;
};
ostream & operator<<(ostream &os, Gpu &gpu);
#endif