The Performance Impact To AMD Zen 2 Compiler Tuning On GCC 9 + Znver2
Written by Michael Larabel in Software on 11 July 2019. Page 1 of 4. 36 Comments

One of the areas that I always have "fun" benchmarking for new CPU launches is looking at the compiler performance. Following the recent Ryzen 3000 series launch I carried out some initial benchmarks looking at the current Zen 2 performance using the newest GCC 9 stable series with its "znver2" optimizations. Here is a look at how the Znver2 optimizations work out when running some benchmarks on the optimized binaries with a Ryzen 9 3900X running Ubuntu 18.04 LTS.

AMD developers introduced the initial Znver2 support into the GNU Compiler Collection last November and thus is part of the GCC 9 stable release that debuted in May. This was their initial cut support for the updated Zen microarchitecture but sadly hasn't seen any enhancements since that initial commit. The Znver2 target does bring some alterations to the cost tables and enables the CLWB / RDPID / WBNOINVD instructions. But as we found out during the Ryzen 3000 briefings, there are more instructions new to Zen 2 besides those like RDPRU, so unfortunately this support while appreciated isn't yet fully complete and likely missing various optimizations considering there haven't been any updates since November. Sadly any improvements made now to their GCC Znver2 support won't see users until the GCC 10 release in Q2'2020 and thus not making it into the likes of Ubuntu 20.04 LTS and other distributions.

This is certainly an area where Intel has been more punctual than AMD in getting out compiler support to GCC (and LLVM Clang) in new microarchitectures often years in advance (even ignoring manufacturing delays). Having their new (and well tuned) microarchitecture support out in new compiler releases well in advance ensures that the support makes it into the annual feature releases of the GCC compiler and out far enough that those new compiler releases get picked up by the tier-one Linux distributions, thus allowing the new microarchitecture targets to be found out-of-the-box in the operating systems at the time of launch. In the case of the Znver2 support with GCC 9, the new compiler has rolled out to Fedora 30 and various rolling-release distributions while Ubuntu users notably won't see this as the default compiler until October with Ubuntu 19.10 and then carried forward to Ubuntu 20.04 LTS sticking to GCC 9. AMD has been more cautious in sending out their compiler support early as not to reveal too many microarchitecture details.

For those having GCC 9 already as their default system compiler or manually upgrading GCC otherwise, here is a look at the current Znver2 performance changes to expect when compiling performance-sensitive binaries with Znver2 compared to Znver1 and also the generic x86-64 target. These different march targets were tested along with "-O3" as the CFLAGS/CXXFLAGS during benchmarking.

Again, all tests were done on the same Ryzen 9 3900X setup and various C/C++ benchmarks via the Phoronix Test Suite.


Related Articles

Trending Linux News