I'm trying to compile Boost 1.49.0 for WinRT. I've got it down to one method: GetSystemInfo(), which is used in boost::thread::hardware_concurrency() to obtain the number of logical processors on the system.
I haven't found any replacement in WinRT yet.
Is there an alternative method I could use?
You can call the Windows API function GetNativeSystemInfo
, which is permitted in Metro style apps.
There doesn't seem to be a simple way to get this information in WinRT. If you just want to know the processor architecture then you can use Windows.System.ProcessorArchitecture
but this will not tell you how many logical CPUs are available. Windows.System.Threading
doesn't tell you this information either.
To get information about the physical CPU I've found this question on the MSDN forum which suggests that we can use DeviceEnumeration to get to this information. By using the GUID for GUID_DEVICE_PROCESSOR ({97FADB10-4E33-40AE-359C-8BEF029DBDD0}) you can enumerate over all processors.
In Javascript this should look something like this - for a C++ example see the Device Enumeration example on MSDN:
Windows.Devices.Enumeration.DeviceInformation.findAllAsync('"System.Devices.InterfaceClassGuid:="{97FADB10-4E33-40AE-359C-8BEF029DBDD0}""')
.then(function (info) {
for (var i = 0; i < info.length; i++) {
var device = info[i];
}
});
On my machine this gives me all sorts of devices, sound card, PCI and USB processors so I'm not sure if there is a better way to just get the CPU but I did get the info what CPU I have
"Intel(R) Core(TM) i7 CPU Q 740 @ 1.73GHz"
Unfortunately this info doesn't seem to include a simple flag that tells you the number of CPUs and therefore I think it would be difficult to get to a number of logical CPUs. I suggest you ask on the MSDN forum. They are usually quite responsive.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With