use numcores
This commit is contained in:
@@ -4,8 +4,6 @@
|
||||
#include <cstdint>
|
||||
#include <string>
|
||||
|
||||
#define N_CPU 16
|
||||
|
||||
namespace cpu {
|
||||
|
||||
enum Module : uint8_t { unknown,
|
||||
|
||||
@@ -4,6 +4,7 @@
|
||||
#include <cstdint>
|
||||
#include <log.hpp>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <utils.hpp>
|
||||
|
||||
namespace cpu {
|
||||
@@ -19,7 +20,8 @@ void detectHwmon(cpuSensors* target, const std::string& pci) {
|
||||
}
|
||||
|
||||
target->module = utils::fileExists(target->hwmon + "/in1_input") ? zenpower : k10temp; // idk if this is reliable, we're trying to avoid just reading the name
|
||||
applog(LOG::INF, "Detected module no. {} in path \"{}\"", target->module ? "zenpower" : "k10temp", target->hwmon);
|
||||
target->num_cores = std::thread::hardware_concurrency();
|
||||
applog(LOG::INF, "Detected {} cores, module no. {} in path \"{}\"", target->num_cores, static_cast<uint8_t>(target->module), target->hwmon);
|
||||
}
|
||||
|
||||
void update(cpuSensors* c) {
|
||||
@@ -41,12 +43,12 @@ void update(cpuSensors* c) {
|
||||
|
||||
// lots of reads but still faster than reading /proc/cpuinfo
|
||||
c->avg_freq = 0;
|
||||
for (uint8_t i = 0; i < N_CPU; i++) {
|
||||
for (uint8_t i = 0; i < c->num_cores; i++) {
|
||||
uint32_t t = 0;
|
||||
utils::fastReadNum<1000>("/sys/devices/system/cpu/cpu" + std::to_string(i) + "/cpufreq/cpuinfo_avg_freq", buf, t);
|
||||
c->avg_freq += t;
|
||||
}
|
||||
c->avg_freq /= N_CPU;
|
||||
c->avg_freq /= c->num_cores;
|
||||
|
||||
// commented out unused values so its faster
|
||||
if (c->module == zenpower) {
|
||||
|
||||
Reference in New Issue
Block a user