summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKWSys Upstream <kwrobot@kitware.com>2021-04-26 14:27:48 (GMT)
committerBrad King <brad.king@kitware.com>2021-04-26 18:05:49 (GMT)
commit1ba07ff0f87101da9c7b35eee3f91a2c1cb0f86f (patch)
tree03dda505021ac9b65089c0ee52a40868226ad8cb
parentd98342d868a51f2c777f0424d2ea04f2fb1fd3ca (diff)
downloadCMake-1ba07ff0f87101da9c7b35eee3f91a2c1cb0f86f.zip
CMake-1ba07ff0f87101da9c7b35eee3f91a2c1cb0f86f.tar.gz
CMake-1ba07ff0f87101da9c7b35eee3f91a2c1cb0f86f.tar.bz2
KWSys 2021-04-26 (642ddfcc)
Code extracted from: https://gitlab.kitware.com/utils/kwsys.git at commit 642ddfccfea808632f8d4b3be03971903e3d359d (master). Upstream Shortlog ----------------- Rolf Eike Beer (1): 7b0f5c20 SystemInformation: improve CPU counting on non-standard architectures
-rw-r--r--SystemInformation.cxx21
1 files changed, 19 insertions, 2 deletions
diff --git a/SystemInformation.cxx b/SystemInformation.cxx
index 7743eab..117ff8d 100644
--- a/SystemInformation.cxx
+++ b/SystemInformation.cxx
@@ -3472,6 +3472,10 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
// We want to record the total number of cores in this->NumberOfPhysicalCPU
// (checking only the first proc)
std::string Cores = this->ExtractValueFromCpuInfoFile(buffer, "cpu cores");
+ if (Cores.empty()) {
+ // Linux Sparc is different
+ Cores = this->ExtractValueFromCpuInfoFile(buffer, "ncpus probed");
+ }
auto NumberOfCoresPerSocket = (unsigned int)atoi(Cores.c_str());
NumberOfCoresPerSocket = std::max(NumberOfCoresPerSocket, 1u);
this->NumberOfPhysicalCPU =
@@ -3490,6 +3494,9 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
if (this->NumberOfPhysicalCPU <= 0) {
this->NumberOfPhysicalCPU = 1;
}
+ if (this->NumberOfLogicalCPU == 0) {
+ this->NumberOfLogicalCPU = this->NumberOfPhysicalCPU;
+ }
// LogicalProcessorsPerPhysical>1 => SMT.
this->Features.ExtendedFeatures.LogicalProcessorsPerPhysical =
this->NumberOfLogicalCPU / this->NumberOfPhysicalCPU;
@@ -3503,8 +3510,18 @@ bool SystemInformationImplementation::RetreiveInformationFromCpuInfoFile()
else {
// Linux Sparc: CPU speed is in Hz and encoded in hexadecimal
CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer, "Cpu0ClkTck");
- this->CPUSpeedInMHz =
- static_cast<float>(strtoull(CPUSpeed.c_str(), nullptr, 16)) / 1000000.0f;
+ if (!CPUSpeed.empty()) {
+ this->CPUSpeedInMHz =
+ static_cast<float>(strtoull(CPUSpeed.c_str(), nullptr, 16)) /
+ 1000000.0f;
+ } else {
+ // if the kernel is build as Sparc32 it's in decimal, note the different
+ // case
+ CPUSpeed = this->ExtractValueFromCpuInfoFile(buffer, "CPU0ClkTck");
+ this->CPUSpeedInMHz =
+ static_cast<float>(strtoull(CPUSpeed.c_str(), nullptr, 10)) /
+ 1000000.0f;
+ }
}
#endif