Function Order List Usage Guidelines

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:

Function Order List Example

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 c:/profdata. Do the following to generate and use a function order list.

  1. Compile your program by specifying -prof_gen[x] and -prof_dir:

    IA-32 Systems

    prompt>
    icc -oMYPROG -prof_genx -prof_dir /home/usr/profdata file1.c file2.c

    Itanium(TM)-based Systems

    prompt>
    ecc -oMYPROG -prof_genx -prof_dir /home/usr/profdata file1.c file2.c

  1. Run the instrumented program on one or more sets of input data
    prompt>./MYPROG

  2. The program produces a .dyn file each time it is executed.

  3. Merge the data from one or more runs of the instrumented program using the profmerge tool to produce the pgopti.dpi file.
    prompt>
    profmerge -prof_dir /home/usr/profdata

  4. Generate the function order list using the proforder tool. By default, the function order list is produced in the file proford.txt.
    prompt>
    proforder -prof_dir /home/usr/profdata -o MYPROG.txt

  5. Compile your application with profile feedback by specifying the -prof_use and the /ORDER option to the linker. Again, use the -prof_dir option to specify the location of the profile files.

    IA-32 Systems

    prompt>
    icc -oMYPROG -prof_use -prof_dir /home/usr/profdata file1.c file2.c -link /ORDER:@MYPROG.txt

    Itanium(TM)-based Systems

    prompt>
    ecc -oMYPROG -prof_use -prof_dir /home/usr/profdata file1.c file2.c -link /ORDER:@MYPROG.txt

Comparison of Function Order Lists and IPO Code Layout

The Intel C++ Compiler provides two methods of optimizing the layout of functions in the executable:

  1. use of a function order list

  2. use of -ipo

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 Order List Effects

Function Type Code Layout with -ipo Function Ordering with proforder
Static X No effect.
Extern X X
Library No effect. X

Function Call to Dump Profile Data Explicitly

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.