Skip to content

Commit

Permalink
Merge pull request #2517 from PaulBone/num_cores
Browse files Browse the repository at this point in the history
Make the number of physical CPU cores detection more robust
  • Loading branch information
senhuang42 authored Mar 8, 2021
2 parents 3d6c903 + 4d6c78f commit a3feed8
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions programs/util.c
Original file line number Diff line number Diff line change
Expand Up @@ -1212,12 +1212,17 @@ int UTIL_countPhysicalCores(void)
/* fall back on the sysconf value */
goto failed;
} }
if (siblings && cpu_cores) {
if (siblings && cpu_cores && siblings > cpu_cores) {
ratio = siblings / cpu_cores;
}

if (ratio && numPhysicalCores > ratio) {
numPhysicalCores = numPhysicalCores / ratio;
}

failed:
fclose(cpuinfo);
return numPhysicalCores = numPhysicalCores / ratio;
return numPhysicalCores;
}
}

Expand Down

0 comments on commit a3feed8

Please sign in to comment.