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. That’s especially true when using that information to make thread count and scheduling decisions in your game code. Properly distinguishing between physical and logical cores is therefore essential because it can have a significant performance impact.
To help achieve the best performance in your multi-threaded games and apps, we strongly recommend that CPU core detection logic takes into account the CPU family ID, so that Ryzen (family 17h) and Bulldozer (family 15h) are handled separately and appropriately. Depending on the AMD processor family your code is running on, we have different advice for game developers that want to make the best use of the available processor resources.
For today’s Ryzen processors with SMT enabled, we’ve found that the vast majority of multithreaded games and applications work and scale really well when managing an active thread pool up to the number of logical cores that the processor supports. However, our experience with a small number of games is that driving a hardware thread pool with more than the number of physical cores can reduce performance, primarily due to contention for available per-core resources by the multiple running hardware threads.
However, for our own prior generation of Bulldozer-based processors designs, we recommend a default thread count equal to the number of logical processor cores. Other processor vendors are encouraged to provide their own guidance to software developers. AMD does not provide guidance for other processor vendors.
Therefore no matter the processor or processor vendor, we strongly recommend that you profile your games extensively to make a decision on how to manage your thread pool for the processor designs you’ll find your game code running on. Our sample code, linked below, errs on the side of caution for our Ryzen processors and encourages you to profile: the
function draws attention to that fact, returning a starting default count equal to the number of physical processor cores on Ryzen.
We’ve provided code samples that demonstrate how to calculate a recommended starting default thread count, along with the number of physical and logical cores, on today’s modern processors. The sample code exists for Windows XP and Windows 7 now, with Windows 10 coming soon. The Windows 10 sample will take into account how CPU sets are used in Game Mode, a new feature released as part of the big Windows 10 Creators Update earlier this year.
Sample Code and Feedback
Head on over to our CPU Core Counts page for more information and a link to the sample code on GitHub.
Let us know if you have any questions or queries, especially with regards to getting the best out of our latest Ryzen and Threadripper processors in your games.