
FMV isn't widely taken advantage of since most Linux distributions don't take performance serious enough to invest that level of detail into optimizations but also because it's another code path / option that can trouble the debugging process when user problems arise. But for those wanting to ship optimized binaries while retaining compatibility with other generations of CPUs, GCC FMV is there.
Clear Linux is the only Linux distribution I am aware of employing FMV as part of their packaging process. As part of that they have a make-fmv-patch utility for helping to spin their function-multi-versioned patches. Their primary motivation with FMV is for allowing AVX-optimized code paths in programs where there is performance benefits to be exploited. Make-fmv-patch has always been open-source while now some documentation has been added that sheds some light on the process.
For generating FMV patches, first they compile the given code with the GCC vectorization flag while using -fopt-info-dev to dump the details on where the compiler could successfully vectorize a given chunk of code. The make-fmv-patch, which is a fairly small Perl script, then parses that GCC output in order to produce a patch that adds the necessary attributes for GCC FMV in the areas where the compiler could successfully vectorize the code. After patching the original source code, the code can then be compiled a final time.
Those interested in exploring it more can find make-fmv-patch on GitHub with the newly-added documentation. It's too bad though that the process isn't more streamlined by GCC itself and/or built into other toolchain processes for aiding the adoption.
If you are only hearing about FMV for the first time, you can learn more about this compiler capability via the GCC Wiki. There is also this LPC 2016 presentation on the topic.
11 Comments