A function order list is a text file that specifies the order in which the linker should link the non-static functions of your program. This improves the performance of your program by reducing paging and improving code locality. Profile-guided optimizations support the generation of a function order list to be used by the linker. The compiler determines the order using profile information.
To enable the Intel® C++ Compiler and proforder tool to generate a function order list, you must use the -prof_gen[x] and -prof_dir options described in the table below.
Option | Description |
---|---|
-prof_gen[x] | Generates an instrumented object file and creates a static profile information file (.spi), which contains source position information for the calls of each compiled function. This information, combined with the dynamic profile information from the .dpi file, enables optimized ordering of functions. When you use -prof_gen[x] instead of -prof_gen[x], you can use the proforder tool to create a function order list for the linker. However, -prof_gen[x] also requires more memory at runtime, produces larger .dyn files, and disables execution of parallel make files. |
-prof_dir dirname | Specifies the directory where .dyn files are to be created. The default is the directory where the program is compiled. The specified directory must already exist. You should specify the same -prof_dir option for both the instrumentation and feedback compilations. If you move the .dyn files, you need to specify the new path. |
You will need to use the utilities profmerge and proforder described in Utilities for Profile-Guided Optimization.
Use the following guidelines to create a function order list:
Assume you have a C program that consists of files file1.c and file2.c and that you have created a directory for the profile data files in /home/usr/profdata. Do the following to generate and use a function order list.
The Intel C++ Compiler provides two methods of optimizing the layout of functions in the executable:
Each method has its advantages. A function order list, created with proforder, enables you to optimize the layout of non-static functions; that is, external and library functions whose names are exposed to the linker. The linker cannot directly affect the layout order for static functions because the names of these functions are not available in the object files.
On the other hand, using -ipo allows you to optimize the layout of all static or extern functions compiled with the Intel C++ Compiler. The compiler cannot affect the layout order for functions it does not compile, such as library functions. The function layout optimization is performed automatically when IPO is active.
Function Type | Code Layout with -ipo | Function Ordering with proforder |
---|---|---|
Static | X | No effect. |
Extern | X | X |
Library | No effect. | X |
As part of the instrumented execution phase of profile-guided optimization, the instrumented program writes profile data to the dynamic information file (.dyn file). The file is written after the instrumented program returns normally from main() or calls the standard C exit function. For programs that do not terminate normally, the _PGOPTI_Prof_Dump function is provided. During the instrumentation compilation ( -prof_gen ), you can add a call to this function to your program. You should add the following function prototype prior to the call:
void _cdec _PGOPTI_Prof_Dump(void);
Note
You must remove the call or comment it out prior to the feedback compilation with -prof_use.