Knowing what CPU resources are available is key to making good use of the CPU in any application. Today’s CPUs all have more than a single core available, and many are capable of executing multiple threads in parallel on those physical cores. Windows presents that to you using the concept of physical and logical cores.
Maximising available CPU performance is especially true for games, given the demands they make of the CPU in order to do create a rich, immersive and incredibly interactive game world, and then efficiently drive the GPU to render it all.
This example code — available separately for Windows® XP and Windows 7, with Windows 10 coming soon — correctly detects the physical and logical cores of today’s modern processors, along with the processor vendor and family.
The Windows 10 version of the code will also show you how to use the CPU Set API to detect which processors are allocated to your game when the new Game Mode, released to all Windows 10 users in the latest Creators Update, is active. Look out for the Windows 10 sample code soon!
Due to architectural differences between Zen and our previous processor architecture, Bulldozer, developers need to take care when using the Windows® APIs for processor and core enumeration.