Skip to content

Commit

Permalink
cpu_nom_freq field put outside INTEL ifdef
Browse files Browse the repository at this point in the history
  • Loading branch information
cpt-harlock committed Jan 9, 2025
1 parent f9f0de9 commit 3039458
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 9 deletions.
20 changes: 14 additions & 6 deletions src/arch.c
Original file line number Diff line number Diff line change
Expand Up @@ -773,10 +773,13 @@ HIDDEN int read_nom_freq()
hwloc_obj_type_t obj_type = HWLOC_OBJ_SOCKET;
#endif

for (unsigned i = 0; (obj = hwloc_get_obj_by_type(topology, obj_type, i)) != NULL; i++) {
for (unsigned i = 0;
(obj = hwloc_get_obj_by_type(topology, obj_type, i)) != NULL;
i++) {
if (obj->infos_count > 0) {
for (unsigned j = 0; j < obj->infos_count; j++) {
if (strcmp(obj->infos[j].name, "CPUNominalFrequency") == 0) {
if (strcmp(obj->infos[j].name,
"CPUNominalFrequency") == 0) {
freq = atol(obj->infos[j].value);
}
}
Expand All @@ -785,14 +788,19 @@ HIDDEN int read_nom_freq()

if (freq == 0) {
char driver_name[STRING_SIZE];
read_str_from_file("/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver", driver_name);
if (!strncmp(driver_name, "acpi-cpufreq", strlen("acpi-cpufreq"))) {
read_str_from_file(
"/sys/devices/system/cpu/cpu0/cpufreq/scaling_driver",
driver_name);
if (!strncmp(driver_name, "acpi-cpufreq",
strlen("acpi-cpufreq"))) {
char line[STRING_SIZE];

read_str_from_file("/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq", line);
read_str_from_file(
"/sys/devices/system/cpu/cpu0/cpufreq/cpuinfo_max_freq",
line);
freq = atol(line);
freq /= 1000.0;
if (freq % 2)
if (freq % 2)
freq -= 1;
} else {
fprintf(stderr,
Expand Down
2 changes: 1 addition & 1 deletion src/cntd.h
Original file line number Diff line number Diff line change
Expand Up @@ -557,8 +557,8 @@ typedef struct {
[5]; // 5 files: \"cpuinfo_max/min_freq\" (2), \"scaling_max/min_freq\" (2),
// \"scaling_setspeed\" (1).

#ifdef INTEL
int nom_freq_mhz;
#ifdef INTEL
int msr_fd;
int energy_pkg_fd[MAX_NUM_SOCKETS];
double energy_pkg_overflow[MAX_NUM_SOCKETS];
Expand Down
2 changes: 0 additions & 2 deletions src/tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -613,5 +613,3 @@ HIDDEN void get_rand_postfix(char *postfix, int size)

snprintf(postfix, size, "%u", jid);
}


0 comments on commit 3039458

Please sign in to comment.