Assembly in the real world
For the past couple of weeks, I have been working on various assembly labs for my Software Portability and Optimization (SPO600) class. We started with 6502 assembly then moved to 64-bit assembly for the aarch64 and x86_64 architectures. While those labs were fun, and albeit very challenging, it was time to take these skills and apply them to actual real world problems.
The GCC compiler is a popular open source compiler that was initially made for the C programming language but now has evolved to support other languages. It has a lot of optimization and porting capabilities that allow a program to run an various architectures. A couple of these porting features include indirect functions (IFUNC) and function multi-versioning (FMV).
IFUNC is a feature that allows you to create various implementations of a function and a resolver function to specify which functions will actually get compiled during the compilation process. This allows us to create different versions of the same function that are only optimized for specific architectures.
The problem here is that it is a lot of work to write all these functions as well as the resolver function that chooses which function to implement.
FMV is an improved version to the IFUNC such that it removes the overhead of having to write the resolver function yourself. You just need to specify an attribute before your functions to indicate what target this function is for.
However, writing all these different versions is still such tedious work and requires that you know what optimizations to make for different architectures, and after writing in aarch64 and x86_64 assembly, I know how painful that process can be.
Automatic function multi-versioning (AFMV) is a proof of concept that aims to solve just that. Wouldn't it be nice if you didn't have to worry about optimizing for different architectures and instead just have the compiler do that for you? AFMV aims to do this by essentially cloning all functions and applying the compiler's optimization process to each one. Any function that is fundamentally the same before and after the optimization process will be pruned back to a single implementation.
For the remainder of this course we will be helping out by determining how to detect if a function after optimization is fundamentally the same before the optimization.
These next series of blogs will document my journey and contributions to this project. Until then, thanks for reading.
Comments
Post a Comment