Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions programs/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1593,6 +1593,7 @@ int UTIL_countCores(int logical)

int siblings = 0;
int cpu_cores = 0;
int procs = 0;
int ratio = 1;

if (cpuinfo == NULL) {
Expand Down Expand Up @@ -1622,6 +1623,15 @@ int UTIL_countCores(int logical)

cpu_cores = atoi(sep + 1);
}
if (strncmp(buff, "processor", 9) == 0) {
const char* const sep = strchr(buff, ':');
if (sep == NULL || *sep == '\0') {
/* formatting was broken? */
goto failed;
}

procs++;
}
} else if (ferror(cpuinfo)) {
/* fall back on the sysconf value */
goto failed;
Expand All @@ -1633,6 +1643,9 @@ int UTIL_countCores(int logical)
if (ratio && numCores > ratio && !logical) {
numCores = numCores / ratio;
}
if (procs) {
numCores = procs;
}

failed:
fclose(cpuinfo);
Expand Down
Loading