1
0
mirror of https://github.com/facebook/zstd.git synced 2025-11-08 06:42:18 +03:00

Merge pull request #2517 from PaulBone/num_cores

Make the number of physical CPU cores detection more robust
This commit is contained in:
sen
2021-03-08 11:14:34 -05:00
committed by GitHub

View File

@@ -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;
}
}