Generating Function Order Lists

A function order list specifies the order in which the linker should link the non-static functions of your program. The list improves the performance of your program by reducing paging and improving code locality.

Profile-Guided Optimizations supports generating a function order list to be used by the linker; the compiler determines the order using profile information.

To generate a function order list, use the profmerge and proforder Tools.

Comparison of Function Order Lists and IPO Code Layout

The Intel® 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, lets you 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.

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.

Alternately, using the -ipo (Linux and Mac OS*) or /Qipo (Windows) option 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

IPO Code Layout

Function Ordering with proforder

Static

X

No effect

Extern

X

X

Library

No effect

X

Function Order List Usage Guidelines (Windows*)

Use the following guidelines to create a function order list:

Generating a Function Order List

This section provides a general example of the process for generating a function order list. Assume you have a C++ program that consists of the following files: file1.cpp and file2.cpp. Additionally, assume you have created a directory for the profile data files called profdata. You would enter commands similar to the following to generate and use a function order list for your application.

  1. Compile your program using the -prof-genx (Linux* and Mac OS*) or /Qprof-genx (Windows) option. (This step creates an instrumented executable.)

Platform

Example commands

Linux and Mac OS

icc -o myprog -prof-genx -prof-dir ./profdata file1.cpp file2.cpp

Windows

icl /Femyprog /Qprof-genx /Qprof-dir c:\profdata file1.cpp file2.cpp

  1. Run the instrumented program with one or more sets of input data. If you specified a location other than the current directory, change to the directory where the executables are located. (The program produces a .dyn file each time it is executed. This process make take some time depending on the options specified.)

Platform

Example commands

Linux and Mac OS

./myprog

Windows

myprog.exe

  1. Merge the data from instrumented program from one or more runs of the instrumented program using the profmerge tool to produce the pgopti.dpi file. Use the -prof-dir (Linux and Mac OS*) or /Qprof-dir (Windows) option to specify the location of the .dyn files.

Platform

Example commands

Linux and Mac OS

profmerge -prof-dir ./profdat

Windows

profmerge /prof-dir c:\profdata

  1. Generate the function order list using the proforder tool. (By default, the function order list is produced in the file proford.txt.)

Platform

Example commands

Linux and Mac OS

proforder -prof-dir ./profdata -o myprog.txt

Windows

proforder /prof-dir c:\profdata /o myprog.txt

  1. Compile the application with the generated profile feedback by specifying the ORDER option to the linker. Again, use the -prof-dir (Linux and Mac OS) or /Qprof-dir (Windows) option to specify the location of the profile files.

Platform

Example commands

Linux and Mac OS

icpc -o myprog -prof-dir ./profdata file1.cpp file2.cpp -Xlinker -ORDER:@myprog.txt

Windows

icl /Femyprog /Qprof-dir c:\profdata file1.cpp file2.cpp /link -ORDER:@myprog.txt