add bar drawing, use pointers more
This commit is contained in:
19
src/gpu.cpp
19
src/gpu.cpp
@@ -5,12 +5,6 @@
|
||||
#include <string>
|
||||
#include <utils.hpp>
|
||||
|
||||
struct GpuMetricsHeader_t {
|
||||
uint16_t structure_size;
|
||||
uint8_t format_revision;
|
||||
uint8_t content_revision;
|
||||
};
|
||||
|
||||
struct GpuMetrics_v1_1_t {
|
||||
uint16_t temperature_edge;
|
||||
uint16_t temperature_hotspot;
|
||||
@@ -95,11 +89,11 @@ GpuMetricsHeader_t getGpuMetricsRev(std::string path) {
|
||||
std::ifstream f(path, std::ios::binary);
|
||||
if (f.good()) {
|
||||
f.read(reinterpret_cast<char *>(&header), sizeof(header));
|
||||
std::cout << "[GpuMetrics] Read GpuMetrics format v" << std::to_string(header.format_revision) << "_" << std::to_string(header.content_revision);
|
||||
std::cout << "[GpuMetrics] header at path " + path + " read, GpuMetrics_v" << std::to_string(header.format_revision) << "_" << std::to_string(header.content_revision);
|
||||
std::cout << ", size " << std::to_string(header.structure_size) << std::endl;
|
||||
f.close();
|
||||
} else {
|
||||
std::cerr << "[GpuMetrics] Error reading gpu metrics header" << std::endl;
|
||||
std::cerr << "[GpuMetrics] error reading header at path " + path << std::endl;
|
||||
}
|
||||
|
||||
return header;
|
||||
@@ -122,15 +116,14 @@ auto getGpuMetrics(GpuMetricsHeader_t h, std::string path) {
|
||||
}
|
||||
|
||||
// clean abstraction of gpu_metrics + extra metrics from fs
|
||||
gpu_t getGpu(std::string hw) {
|
||||
gpu_t getGpu(GpuMetricsHeader_t header, std::string hw) {
|
||||
gpu_t gpu;
|
||||
auto h = getGpuMetricsRev(hw + "/gpu_metrics");
|
||||
auto metrics = getGpuMetrics(h, hw + "/gpu_metrics");
|
||||
auto metrics = getGpuMetrics(header, hw + "/gpu_metrics");
|
||||
|
||||
// we want as much data as posible from gpu_metrics so we dont read filesystem as much
|
||||
gpu.fan_speed = std::stol(readFile(hw + "/hwmon/hwmon2/fan1_input"));
|
||||
gpu.core_clock = metrics.average_vclk1_frequency; // why not gfxclock?
|
||||
gpu.mem_clock = metrics.average_gfxclk_frequency; // why gfxclock? min mem clock seems to be 96mhz, this is probably including time sleeping
|
||||
gpu.core_clock = metrics.average_vclk1_frequency; // why not gfxclock?
|
||||
gpu.mem_clock = metrics.average_gfxclk_frequency; // why gfxclock? min mem clock seems to be 96mhz, this is probably including time sleeping
|
||||
gpu.vcore = std::stod(readFile(hw + "/hwmon/hwmon2/in0_input")) / 1000.0;
|
||||
gpu.power_avg = metrics.average_socket_power;
|
||||
gpu.power_cap = std::stol(readFile(hw + "/hwmon/hwmon2/power1_cap", 6));
|
||||
|
||||
Reference in New Issue
Block a user